in reply to Re^3: Unsuccessful stat on file test
in thread Unsuccessful stat on file test
Where I was falling down (mainly) was in the subroutine where I was confusing $_ with $_[0]. It was a few chapters ago, and sort of leaked out of my brain. There's a lot to retain to this Perl stuff! ;)#!/usr/bin/perl use warnings; use strict; sub filetest { my @answer; print "\n\$_[0] now holds $_[0] \n"; return "File does not exist\n" unless -e $_[0]; push @answer, "readable " if -r $_[0]; push @answer, "writable " if -w $_[0]; push @answer, "executable " if -x $_[0]; print "function result: "; print @answer; return @answer; } while (@ARGV) { my $file = shift @ARGV; $file =~ s/\s*$//; print "\$file is $file"; my @answer = filetest($file); #thanks for the style tip! print "\nmain answer: "; print @answer; print "\n"; }
|
|---|