When calling a perl script with:
myPerlScript --myarg 10 --my2Darg 42x87.
How do I make the assignments:
$myarg = 10;
$my2Darg_x = 42;
$my2Darg_y = 87;
if and only if myarg and my2Darg is valid arguments?
I think I need something like this:
#!/usr/bin/perl
foreach (@ARGV) {
if ($_ eq '--myarg') {
$myarg =
}
elsif ($_ eq '--my2Darg') {
$my2Darg_x =
$my2Darg_y =
}
else {
print "Not valid argument!!";
}
}
As you can see this code is not complete. Plz. help.
Is there a short way to write if($_ eq 'text') (is if('text') valid Perl?)?
Check
Getopt::Longmodule, it’s on core.Script
Output