Re: [Ssh-sftp-perl-users] Need help to Pass argument in Perl
Brought to you by:
dbrobins
|
From: Ken B. <ken...@co...> - 2009-01-17 18:27:23
|
Hi Folks,
I think that Rodney's looking for something a little more basic.
There are at least 10 variations on doing what you want, some better than
others. This is one way I commonly use.
#! /usr/bin/perl -w
for $arg(@ARGV) {
if ($arg eq "-a") {
$length = shift(@ARGV);
} elsif ($arg eq "-b") {
$width = shift(@ARGV);
} elsif ($arg eq "-ab") {
$height = shift(@ARGV);
} else {
# include any error handling here!
}
}
# Next, check to see if your parameters are all present and in the correct
range!
# Error handling is always a good practice.
Hope this helps.
Sincerely,
Ken
|