Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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 wandering the Monastery: (15)
As of 2014-07-10 20:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (215 votes), past polls