Reputation: 4722
I have a loop similar to :
if ( -e "$hash->{'key'}/filename" ) {
print $_
}
I though $_ would refer to the argument of '-e' but that is not the case. Any special variable I could use here?
Upvotes: 2
Views: 355
Reputation: 57600
You can assign to a variable inside the test:
if ( -e (my $_ = "...")) {
print;
}
-e
will test on $_
if no argument is given, but it does not assign its argument to $_
. To learn more about filetest operators, read the perlfunc
entry.
Upvotes: 5