Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: split and uninitialized variables

by podian (Scribe)
on Sep 03, 2004 at 16:28 UTC ( #388331=note: print w/replies, xml ) Need Help??


in reply to Re: split and uninitialized variables
in thread split and uninitialized variables

That is what I usually do. But if you know what the data you are working on, then scalars will be better.
One example could be "name, address-line1, address-line2"
and line 2 might be or might not be present.
So to summarise the replies, it would be better to initialize them in the next line.
All the other solutions seem to have some problems!
  • Comment on Re^2: split and uninitialized variables

Replies are listed 'Best First'.
Re^3: split and uninitialized variables
by Aristotle (Chancellor) on Sep 03, 2004 at 17:36 UTC

    The ( '' ) x 3 solution doesn't.

    Another option:

    my ( $foo, $bar, $baz ); $_ .= '' for ( $foo, $bar, $baz ) = split /,/;

    Makeshifts last the longest.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://388331]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2017-09-25 06:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (276 votes). Check out past polls.

    Notices?