Home > Archive > PERL Beginners > March 2008 > how do check th argument is passing to running file
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
how do check th argument is passing to running file
|
|
| Sivasakthi 2008-03-24, 8:01 am |
| Hi all,
How we can check the argument is passing to the running file or not?
#sample.pl 2008 03
i want to check the two arguments of 2008 & 03 is passed to sample.pl or
not..
Thanks,
| |
| Yitzle 2008-03-24, 7:05 pm |
| Arguments are passed in the @ARGV array.
You can access $ARGV[0] and $ARGV[1]
unless (defined $ARV[0] and defined $ARGV[1]) {
die "You need to supply two arguments\n";
}
| |
| ken Foskey 2008-03-24, 7:05 pm |
| On Mon, 2008-03-24 at 17:46 +0530, sivasakthi wrote:
> Hi all,
>
> How we can check the argument is passing to the running file or not?
>
> #sample.pl 2008 03
>
> i want to check the two arguments of 2008 & 03 is passed to sample.pl or
> not..
if( defined $ARGV[1] ) {
die "Two arguments required\n sample.pl yyyy mm";
}
--
Ken Foskey
FOSS developer
| |
| John W. Krahn 2008-03-24, 7:05 pm |
| sivasakthi wrote:
> Hi all,
Hello,
> How we can check the argument is passing to the running file or not?
>
> #sample.pl 2008 03
>
> i want to check the two arguments of 2008 & 03 is passed to sample.pl or
> not..
@ARGV == 2 or die "You must supply two arguments!\n";
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
|
|
|
|
|