cbgb wrote:
> ATM I can use @ARGV by forcing it to read specified files
> (see sample below). But how can I turn it into a subroutine
> that accepts any filenames and can be called within a script, eg:
> &myroutine("fileA","fileB") ?
>
> thanks
> Chris
>
>
> #!/usr/bin/perl -Tw
>
> @ARGV=("textfile","craig");
>
> foreach $arg (@ARGV){
> if (-e $arg) {
> print "$arg is a file\n";
> }else {
> print "$arg file not found\n";
> }
> }
Subroutine arguments are passed in the @_ array, so:
foo('textfile', 'craig');
foo(@ARGV);
sub foo {
for (@_) {
if (-e) {
print "$_ is a file\n";
} else {
print "$_ not found\n";
}
}
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]