Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Is there any way to override "file test operator"?

by Tux (Canon)
on Aug 09, 2011 at 06:46 UTC ( [id://919395]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://919395]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-26 07:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found