Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: "Use of uninitialized value" due to empty elements in an array

by JavaFan (Canon)
on Mar 31, 2010 at 15:06 UTC ( #832070=note: print w/ replies, xml ) Need Help??


in reply to "Use of uninitialized value" due to empty elements in an array

$line_split[0] will only be undefined if $line doesn't contain any other character than \t (including being empty). And the fact it's undefined stems from @line_split not having any entries. So, you may do something like:

if (@line_split && $line_split[0] eq "") { # Has empty leading fields }
or
if (!@line_split || $line_split[0] eq "") { # Has empty leading fields, or no fields at all }
depending on what you want to do if there are no fields at all.


Comment on Re: "Use of uninitialized value" due to empty elements in an array
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://832070]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (12)
As of 2014-12-18 12:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (51 votes), past polls