tags:

views:

88

answers:

1

How do I print a hash from within a string, as in

print "\n[*] Query : $select { query }";

versus

print "\n[*] Query : " . $select { query };
+8  A: 

You may need to eliminate the extra spaces:

print "\n[*] Query : $select{query}";

With a space after $select, Perl thinks that you are done with the interpolation of that variable, and treats the following text (including the curly braces) literally.

Greg Hewgill
What if the key was yet again a variable : print "\n[*] Query : $select{$query}"; ?
PoorLuzer
That should work fine too (as long as you don't put any extra spaces in the interpolation).
Greg Hewgill