Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
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
Domain Nodelet?
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 wandering the Monastery: (2)
As of 2023-06-01 15:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?