in reply to custom args with perl -an type invocation?

The -a switch splits the current line on whitespace and puts the results in the @F array but you are not using the @F array in your code so you probably don't need the -a switch. A simple method of providing switches to your program is Perl's -s switch (described in the perlrun document.)
# With Perl's -s switch $ ./anWithArgs.pl -type=letters input.txt $ cat anWithArgs.pl #!/usr/bin/perl -sn if ( $type eq 'letters' ) { print if /[[:alpha:]]/; } elsif ( $type eq 'numbers' ) { print if /\d/; } else { print "bad type: $type" }

Replies are listed 'Best First'.
Re^2: custom args with perl -an type invocation?
by tphyahoo (Vicar) on Jun 28, 2006 at 12:14 UTC
    Thank you. -s is exactly what I was looking for.