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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.