Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^4: Hash vs constant vs package vs other for data structure

by oldtechaa (Beadle)
on Mar 27, 2017 at 19:46 UTC ( [id://1186134]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Hash vs constant vs package vs other for data structure
in thread Hash vs constant vs package vs other for data structure

I don't really need either of those, but I also would like to assign to slices, which would be difficult with a hash. I think I'll go with the constant method or uppercase variables probably.
  • Comment on Re^4: Hash vs constant vs package vs other for data structure

Replies are listed 'Best First'.
Re^5: Hash vs constant vs package vs other for data structure
by Anonymous Monk on Mar 27, 2017 at 20:24 UTC
    I also would like to assign to slices, which would be difficult with a hash.

    It works:

    $ perl -MData::Dump -e '@{$x[0][0]}{qw/a b/} = qw/c d/; dd \@x' [[{ a => "c", b => "d" }]]
      Seems almost more complicated than my initial problem.
Re^5: Hash vs constant vs package vs other for data structure
by Anonymous Monk on Mar 27, 2017 at 20:10 UTC
    Constants set up with constant are inlined by the compiler (Constant Functions) and should be a little bit faster, and "safer" (no one can accidentally change your variables).
Re^5: Hash vs constant vs package vs other for data structure
by BillKSmith (Monsignor) on Mar 27, 2017 at 21:54 UTC
    When faced with a choice which makes little difference, choose one and use it consistently on all future projects. (This restriction may influence your choice.)
    Bill

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2024-04-19 09:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found