Vikki Vikki -3 years ago 49
Perl Question

How can I correct the following perl program to check directory existence


$path = <STDIN>;

if (-e $path) {
print "present";
else {
print "Not present";

Why is it always printing "Not present"?

Answer Source

You need to remove the newline character from your variable using chomp:

$path = <STDIN>;
chomp $path;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download