Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: Build your array with push

by demerphq (Chancellor)
on Jan 31, 2006 at 15:48 UTC ( [id://526775]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Build your array with push
in thread Build your array with push

Neither work. Second one has the dreaded can't modify read only string error. Which is a good example of the issues the OP was making I guess. Sigh, i should know better for both of these too. :-(

I will quibble with the "grasping at straws" comment tho. I think this approach often is just fine for dealing with spaces in a qw() string.

---
$world=~s/war/peace/g

Replies are listed 'Best First'.
Re^4: Build your array with push
by japhy (Canon) on Jan 31, 2006 at 15:54 UTC
    My problem with the second approach (apart from the "read only" snag) is that it turns constant data into something that requires computation. Certainly, there are times when computation is necessary with constant data, such as when you are constructing a data structure like an array of arrays: you take tab-separated data, split on the tabs, and produce array references. That's certainly easier and faster to write than producing the data structure in the code itself. But in this case, I think it was overkill.

    Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
    How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

      Right, I can see your point. I think for me it would come down to a matter of whether run time issues are more important than development time issues. Generally I'd say that development time is more important so I'd probably go with whatever saved me the most work.

      ---
      $world=~s/war/peace/g

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://526775]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (8)
As of 2024-04-23 08:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found