Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: uninitialized string variable

by JediWizard (Deacon)
on Aug 13, 2010 at 16:30 UTC ( #854945=note: print w/replies, xml ) Need Help??


in reply to uninitialized string variable

You must be running with warnings enabled, which is a good thing, especially if you're reasonably new to Perl. The warning means that a variable that has no value is being used in string context. If you are using Text::CSV to parse the CSV file, it is probably using undef for blank fields. I'd have to look, but I believe there is a parameter to request that Text::CSV uses an empty string $var = ''; instead of $var = undef; for empty columns, which should prevent the warning.

If that doesn't suit you're liking: you can use something like this: $var ||= ''; to replace the undefined value with a blank string, which would also prevent the warning.


They say that time changes things, but you actually have to change them yourself.

—Andy Warhol

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2021-06-18 05:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (87 votes). Check out past polls.

    Notices?