On Apr 15, 2004, at 2:10 PM, Jakob Kofoed wrote:

Hello All,

I'm trying to create a script with where you can put a flag to the script or
not
fx run it like:


script -h
or just
script

something like:

if ( $ARGV[0] =~ /-h/ ) {
print "You have chosen the very special ability!\n";
} else {
print "you have not chosen the very special ability!\n";
}

but when I run this one without any flag i get an error message:
"use of initialized value in pattern match (m//)"

Use:


if (@ARGV and $ARGV[0] =~ /-h/) {

Do I have to do it differently to get rid of the error?

Better would be to use the standard module to handle this for you. It's called Getopt::Std.


James


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to