in reply to •Re: find real length of an array
in thread find real length of an array
Thanks for the quick reply.
In my real source code in the offending application, the offending array is constructed from a split of a tab-delimited line. I am using split("\t",$line,99999) to generate the line.
Hmmm... When I run the test below on the command line, it seems to behave correctly I have a feeling that I need to take a close look at the offending code. All the splits which I am using to generate the array are providing the field number option, which inserts undefs into the placeholders. Well, at least the answers I got here helped me cross out some of the possible sources of error. Thanks for the help.
bash-2.03$ cat test.pl #!/usr/bin/perl my $line = "hello\tworld\tI\tam\ta\tline\twithout\ttabs"; my $line_2 = "hello\tworld\tI\tam\ta\tline\twith\ttabs\t\t\t\t"; my @array = split("\t",$line,9999); my @array_2 = split("\t",$line_2,9999); my @array_3 = split("\t",$line_2); print "Scalar of array 1 =",scalar @array,"\n"; print "Scalar of array 2 =",scalar @array_2,"\n"; print "Scalar of array 3 =",scalar @array_3,"\n"; bash-2.03$ perl test.pl Scalar of array 1 =8 Scalar of array 2 =12 Scalar of array 3 =8 bash-2.03$
Ronan
www.roasp.com
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: find real length of an array
by Aristotle (Chancellor) on Mar 16, 2003 at 19:04 UTC | |
by hackmare (Pilgrim) on Mar 16, 2003 at 22:37 UTC |
In Section
Seekers of Perl Wisdom