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/ ) {

Try if(defined $ARGV[0]) { if($ARGV[0] eq '-h') { print "Welcome to dash h\n"; } else { print "What did you choose?\n"; } } else { print "you have not chosen the very special ability!\n"; }

or:

my $switch = $ARGV[0] || '';
now it is initialized :)
and you can do what you did before just use $switch instead of $ARGV[0]

HTH

Lee.M - JupiterHost.Net
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//)"

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

Thanks,
Jakob




-- 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