in reply to Hash slice in regex

The equivalent print would have been print "@k{qw(A B C)}";. Remember that m/.../ is a quote-like operator. The element seperator for interpolated slices and arrays is the value of $".

#!perl -l my %k; $k{'A'} = 'Foo'; $k{'B'} = 'Bar'; $k{'C'} = 'Baz'; { # What goes for double-quotes... print "@k{qw(A B C)}"; # Foo Bar Baz local $" = ''; print "@k{qw(A B C)}"; # FooBarBaz } { # ...also goes for the regexp operators. print qr/@k{qw(A B C)}/; # Foo Bar Baz local $" = ''; print qr/@k{qw(A B C)}/; # FooBarBaz }

Update: Added qr/.../ to the example.

Replies are listed 'Best First'.
Re^2: Hash slice in regex
by anjiro (Beadle) on Sep 26, 2006 at 17:26 UTC
    Ah-ha! I knew there would be something like that! Too many darn man pages to wade through... =)