Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
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?
[holli]: see moritz, the , how do i put it, robust charme of this site is what separates the wheat from the chaff ^^
[LanX]: I'm willing to improve the code, but we have a götterdämmerung at the moment, Corion is the only active god for some time now
[moritz]: and everybody is like "if you just copy 250 lines of ugly JS into your free nodelet, and happent to know about it, there is a 40% that this workaround kinda works, sometimes"
[moritz]: ... "so there is no need to do anything"
[LanX]: and the code is a bit of a mess
[LanX]: moritz, no ... jsut copy one line of my code
[moritz]: I'm still using the CB, because ambrus's #cbstream makes it bearable
[LanX]: ... the rest is loaded from a node
[holli]: the best course of action would be to transfer the data to something well tested. even if it isnt perl based
[moritz]: but even if I had all the time in the world, I wouldn't spend much on perlmonks

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (12)
As of 2017-11-20 19:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (291 votes). Check out past polls.

    Notices?