in reply to Re: Is there any way to override "file test operator"?
in thread Is there any way to override "file test operator"?

And I - as a simple bystander - would read that as

if ( - e ($filename)) { ^

that is "the negative value returned by the function e with argument $filename".


Enjoy, Have FUN! H.Merijn

Replies are listed 'Best First'.
Re^3: Is there any way to override "file test operator"?
by Marshall (Canon) on Aug 09, 2011 at 07:09 UTC
    #!usr/bin/perl -w use strict; my $file = 'C:\temp\test20.pl'; if ( -e $file) { print "$file EXISTS!\n"; } print "$0 \n"; if ( - e $file) #this does not work! { print "$file WILD!\n"; } __END__ Can't locate object method "e" via package "C:\temp\test20.pl" (perhaps you forgot to load "C:\temp\test20.pl"?) at C:\TEMP\test20.pl line 13. C:\temp\test20.pl EXISTS! C:\TEMP\test20.pl

      I said that this was how I read that, and parens do matter here:

      $ cat test.pl #!/pro/bin/perl use strict; use warnings; my $file = "/tmp/test20.pl"; -e $file and print "$file EXISTS!\n"; print "$0 \n"; - e $file and print "$file WILD!\n"; $ perl test.pl test.pl Can't call method "e" without a package or object reference at test.pl + line 10. $

      versus

      $ cat test.pl #!/pro/bin/perl use strict; use warnings; my $file = "/tmp/test20.pl"; -e $file and print "$file EXISTS!\n"; print "$0 \n"; - e ($file) and print "$file WILD!\n"; $ perl test.pl test.pl Undefined subroutine &main::e called at test.pl line 10.

      Enjoy, Have FUN! H.Merijn