in reply to Passing file check operators to a function

Thanks you all, In deed Grandfather gave me exactly what I'm lookin for... I will make sure to provide the right permission operators on the functin call.

Can I apply something similar to check if a certain Directory exists and I also have permissions to create a new file in this Directory?

Peter
  • Comment on Re: Passing file check operators to a function

Replies are listed 'Best First'.
Re^2: Passing file check operators to a function
by Zaxo (Archbishop) on Sep 08, 2005 at 03:32 UTC

    On unix, the same test on a directory name will indicate you can create a file in the directory. You need write permission on the directory inode to insert a new file's metadata. You may want to test -d where -e is tested above, just to verify it's a directory.

    I don't know whether the win32 file tests emulate that or not.

    After Compline,
    Zaxo

Re^2: Passing file check operators to a function
by sk (Curate) on Sep 08, 2005 at 04:11 UTC
    Modified GrandFather's code a bit so that you don't have to loop through to test

    sub checkit { my ($tests, $filename) = @_; my @testList = split ",", $tests; my $teststr = shift(@testList) . " '" . $filename . "'" . " && " . join (' _ && ', @testList) . " _"; return eval ("($teststr)"); return 1; }

    Not very clean but at least it saves you too many stat calls.