Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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


In reply to Re: •Re: find real length of an array by hackmare
in thread find real length of an array by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-03-28 17:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found