Re: ARGV array regarding
- From: rob.dixon@xxxxxxx (Rob Dixon)
- Date: Thu, 31 Jul 2008 15:36:49 +0100
suresh kumar wrote:
This is my part of the script,
if (($#ARGV == 1) && ($ARGV[0] eq "-f")) {
..........
............
if ($ARGV[0] ne "-f" ) {
......................
....................
if i run my script i am seeing this kind of warnings.
Use of uninitialized value in string eq at ./lineCount line 30.
Use of uninitialized value in string ne at ./lineCount line 69.
How can i initialize ARGV array?
can anyone help me in this issue.
The @ARGV array holds the whitespace-split contents of the command line used to
start perl. If you run a program with
perl myprog.pl a b c
then @ARGV will contain ('a', 'b', 'c'). It doesn't normally need initialising,
but you can assign to it if you want to simulate a command line.
$#ARGV is the highest valid index of @ARGV, so
$#ARGV == 1
is testing whether @ARGV has two elements (at indices 0 and 1). The second test
$ARGV[0] eq "-f"
will be performed only if the first succeeds, and since you've established that
there are two elements the first can only be undefined if you've explicitly made
it so, with
delete $ARGV[0];
or something similar.
I can't really tell what the problem might be without seeing your full code.
Rob
.
- References:
- ARGV array regarding
- From: Suresh Kumar
- ARGV array regarding
- Prev by Date: RE: can perl program do this?
- Next by Date: Re: ARGV array regarding
- Previous by thread: ARGV array regarding
- Next by thread: Re: ARGV array regarding
- Index(es):
Relevant Pages
|