Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Journal of rafael (2125)

Monday February 09, 2004
06:13 PM

-f -x -w $file

[ #17311 ]
It's new language features time !

Since a few hours, you can now write with bleadperl:

-f -w -x $file

and perl acts as if it were

-x $file && -w _ && -f _

As I added in perlfunc, this is only syntax fancy : if you use the return value of -f $file as an argument to another filetest operator, no special magic will happen. If I remember correctly, Perl 6 will provide a full-fledged form of this syntax (with filehandle context and all). (To be appearing in the next p5p summary...)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Yay! (Score:2, Interesting)

    I love it! Thank you.

    How about extending _ to mean the article passed to the previous test to apply to other tests?

    if ( exists $foo->{member} and defined $foo->{member}) {}


    if ( exists $foo->{member} and defined _ ) {}

    It's now just a little shorter ...
    • That would break existing programs. Besides, it's not equivalent to the file tests, since you're not caching the info needed for future tests when you do the first one.