toasty has asked for the wisdom of the Perl Monks concerning the following question:

From Regexp::Common::zip

$RE{zip}{US}{-extended => [yes|no|allow]}

What is going on with {-extended => [yes|no|allow]}?

It kinda looks like a hash slice, but it's not, right? How is that syntax able to set an option?

Might be a simple answer, just puzzles me this afternoon.

Replies are listed 'Best First'.
Re: What is this magic?
by ikegami (Patriarch) on May 21, 2009 at 20:00 UTC

    When multiple indexes are provided as a hash index (as opposed to a hash slice), they are joined using $;. This is indeed a rarely used feature. (HoH are preferred.)

    $ perl -wle'$h{ -extended => "no" } = 1; print for keys %h' | od -c 0000000 - e x t e n d e d 034 n o \n 0000015

    How is that syntax able to set an option?

    %{ $RE{zip}{US} } is either magical (and the fetcher looks for /^-extended\034/) or it's populated with all the possible options.
      Thanks indeed for satisfying my curiosity. Long time hacker, never saw it before today.