Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2018-06-21 23:52 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (120 votes). Check out past polls.