Hi There.

I have this piece of code which I call with the following; array.csh "one"
"two" "three four" "five" "sic cod"

#!/opt/perl-5.6.1/bin/perl -w
$count=0;
print " ARGV $#ARGV\n\n";

while (<$ARGV>) {
        print "count $count $ARGV[$count]\n";
        $count++;
}

I get the following output:
 ARGV 4

count 0 one
count 1 two
count 2 three four
count 3 five
count 4 sic cod
Use of uninitialized value in concatenation (.) or string at array.csh line
9.
count 5 
Use of uninitialized value in concatenation (.) or string at array.csh line
9.
count 6 

Why does the the while loop keep going and not stop? It does stop if I take
the -w out.

I can get it to work like this;

$count=0;
$total = $#ARGV;

while ( $count <= $total ) {
        print "count $count $ARGV[$count]\n";
        $count++;
}

Could someone tell me the best way. I assumed the first option would be the
best but it does not work.

Thanks

Angus 




------------------------------------------------------------------------------
This message is intended only for the personal and confidential use of the designated 
recipient(s) named above.  If you are not the intended recipient of this message you 
are hereby notified that any review, dissemination, distribution or copying of this 
message is strictly prohibited.  This communication is for information purposes only 
and should not be regarded as an offer to sell or as a solicitation of an offer to buy 
any financial product, an official confirmation of any transaction, or as an official 
statement of Lehman Brothers.  Email transmission cannot be guaranteed to be secure or 
error-free.  Therefore, we do not represent that this information is complete or 
accurate and it should not be relied upon as such.  All information is subject to 
change without notice.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to