in reply to checking file permissions

die "$file does not exist!\n" unless -e $file; my @perms; push @perms, 'read' if -r $file; push @perms, 'write' if -w $file; push @perms, 'execute' if -x $file; print @perms ? "You have @perms perms\n" : "You got zip\n";

cheers

tachyon

Replies are listed 'Best First'.
Re^2: checking file permissions
by freddo411 (Chaplain) on Nov 14, 2004 at 01:10 UTC
    Looks like you just did this tyke's homework. Bad Tachyon.

    -------------------------------------
    Nothing is too wonderful to be true
    -- Michael Faraday

      Actually he has since added a clarification that places him on Win32, so he probably really wants Dave Roth's Win32::Perms

      cheers

      tachyon

Re^2: checking file permissions
by Your Mother (Archbishop) on Nov 14, 2004 at 18:16 UTC

    Also a good place to introduce _ even if it's not saving much here (discussed in JediWizard's perldoc.com link; _ is a hard thing to search for).

    die "$file does not exist!\n" unless -e $file; my @perms; push @perms, 'read' if -r _; push @perms, 'write' if -w _; push @perms, 'execute' if -x _; if ( @perms ) { printf "You have %s perms\n", join(", ", @perms); } else { print "You got zip\n"; }