[Wellington-pm] Strange (for me) notation

Chris Eade chris.eade at gmail.com
Tue Jul 21 16:10:37 PDT 2009


Hi,
My name is Chris Eade - Long time listener, first time caller. Well,
not so much the long time listener :)

I am working as a developer on a suite of web applications written in
Perl. Its basically maintaining legacy code, and there are always bits
of code that make me stop and think: what the..?!

However, this particular piece of code has me really stumped. It looks
like this:

  use constant LATEST_D_ACROSS_PRODUCTS => 'P';
  <snip>
  $ib->{reg}->{@{[LATEST_D_ACROSS_PRODUCTS]}} = $ed;
  $ib->{prodNo}->{@{[LATEST_D_ACROSS_PRODUCTS]}} .= "$product_no,";

The part I really don't get is the meaning of this:

  @{[LATEST_D_ACROSS_PRODUCTS]}

I realise that LATEST_D_ACROSS_PRODUCTS becomes "P", but then I really
don't understand:

  @{[P]}

as a valid hash key. From the rest of the code, $ib->{reg} and
$ib->{prodNo} are references to hashes that appear to just behave
normally with strings as the has keys.

Does anyone know what might be happening here? The line occurs within
a loop that makes use of $_ rather than assigning a variable
explicitly to each element of the loop, so I thought that might have
something to do with it (like a form of @{$_} or something).

Kind regards,
Chris.


More information about the Wellington-pm mailing list