in reply to Re^4: Search 2 columns
in thread Search 2 columns
which prints "%blah%". Putting a "%" in front of a scalar variable in a double-quoted string will not turn that variable into a hash ref.perl -Mstrict -le 'my $s="blah"; print "%$s%"'
If the variable happens to already be a hash ref, then of course it will be interpolated as such, though not in a way that most folks would consider useful:
prints something like "%HASH(0x1801380)%". It's only arrays (and array refs) that get interpolated into the list of values when placed inside double-quotes -- and only if the sigils are right:perl -Mstrict -le 'my $s={foo=>"bar"}; print "%$s%"'
perl -Mstrict -le 'my %s=(foo => "bar"); print "%s"' %s perl -Mstrict -le 'my $s=[qw/foo bar/]; print "%$s%"' %ARRAY(0x1801380)% perl -Mstrict -le 'my $s=[qw/foo bar/]; print "@$s@"' foo bar@
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Search 2 columns
by roboticus (Chancellor) on Sep 23, 2007 at 15:50 UTC |