in reply to Re^2: Perl::Improved Volume 0, Number 0
in thread Perl::Improved Volume 0, Number 0

File::exists( 'filename' );

This seems like a natural addition to English, but I think it would need something more like a source filter and less like the typeglob diddling of English, so it's not an easy addition.

Update: demerphq has the right of it... just a sub File::exists($) { -f $_[0] } would do it.

--Solo

--
You said you wanted to be around when I made a mistake; well, this could be it, sweetheart.

Replies are listed 'Best First'.
Re^4: Perl::Improved Volume 0, Number 0
by demerphq (Chancellor) on Aug 27, 2004 at 13:18 UTC

    demerphq has the right of it...

    Well to be picky i think that that code will have a minor incompatibility with the normal file test operators regarding the magic filehandle '_', since File::stat() shares this problem I dont think its a showstopper really. And I guess if one doesn't like the current filetest names its unlikely that one would be happy with using the special filehandle:

    $filesize=-s _ if (-e $foo);

    would become

    $filesize=File::size($foo) if File::exists($foo);

    Which is of course less efficient.


    ---
    demerphq

      First they ignore you, then they laugh at you, then they fight you, then you win.
      -- Gandhi


Re^4: Perl::Improved Volume 0, Number 0
by Anonymous Monk on Aug 30, 2004 at 09:47 UTC
    In 5.10, one will be able to write:
    if (-w -x -r $file) {....}