in reply to Re: possible to assign symbolic references?
in thread possible to assign symbolic references?

Why would using references be preferable? Is use of Data::aliases expensive (or more so) than using a dereference on each access?
  • Comment on Re^2: possible to assign symbolic references?

Replies are listed 'Best First'.
Re^3: possible to assign symbolic references?
by ikegami (Patriarch) on Sep 21, 2010 at 23:33 UTC

    Aliases would be less expensive once created. However, using aliases introduces more magic (especially if Data::Alias is involved) and creates more action at a distance (making the code less clear and harder to debug).

    Actually, even simpler would be to use neither. The problem only exists because the addition of the scalars to the data structure is done at the top of the code.

    my ($var1, $var2, ...); ... push @array, [ $var1, $var2, ... ];

    The downside is that you might have to guard against exceptions and returns.

      I think Data::aliases is exactly what I was looking for. I didn't know it existed (guess I should have thought to look under aliases!)...

      This comment in the Data::Aliases description fits my situation perfectly:

      You can use this to improve efficiency and readability, when compared to using references.
      Thanks!
        It's currently not compatible with 5.12 (but I believe someone's (slowly) working on it).
Re^3: possible to assign symbolic references?
by Anonymous Monk on Sep 21, 2010 at 23:11 UTC

    Real references are solid, dependable things.

    Symbolic references are a leap of faith that will kill you eventually.