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: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 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 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