Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re^2: split and uninitialized variables

by markjugg (Curate)
on Sep 03, 2004 at 15:38 UTC ( #388313=note: print w/replies, xml ) Need Help??

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

This solution is novel and works, but I don't recommend it.

. It's more important to have code that is clear and easy to read than to be as concise and compact as possible. The clearest solution is to simply use a second line to initialize the variables.

  • Comment on Re^2: split and uninitialized variables

Replies are listed 'Best First'.
Re^3: split and uninitialized variables
by Eimi Metamorphoumai (Deacon) on Sep 03, 2004 at 15:51 UTC
    I'm aware of the importance of clarity. If I were golfing I would have done something like
    my ($x, $y, $z) = split(',', "$_,,");
    but this was the most natural answer to me. The problem, as I saw it, was "sometimes the list returned by split is too short, and I want empty strings to fill missing places at the end," so the most natural answer I saw was to add items to fill it out.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2018-06-21 05:37 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (117 votes). Check out past polls.