Reputation: 19
I tried -e
and -f
switch, but they don't work.
print "Enter Board File:";
$brdFile = <>;
$a = -e $brdFile;
printf("Value of A is %d\n",$a);
Output:
Enter Board File:C:\SATAHDD.brd Value of A is 0
Location shown above is correct.
Upvotes: 1
Views: 68
Reputation: 223
I'd like to suggest a few improvements to your original code, although I agree with toolic that your problem is almost certainly the missing call to chomp. I present this version of the code that I think represents best practices for this problem.
use strict; # Prevents use of undeclared variables, barewords, etc.
use warnings; # Lets you know about runtime problems such as the chomp
print "Enter Board File: ";
my ($brdFile) = <>;
chomp $brdfile;
# Unless you need it later in your program for some reason there is
# no requirement that you store the result in a variable. You can also
# glue together an output line without using printf if all you need
# is concatenation of string literals and variables
print "\nResult of -e $brdFile is ", -e $brdFile, "\n";
Upvotes: 0