Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I interpolate a Perl hash element in a string?

Tags:

string

hash

perl

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

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

versus

print "\n[*] Query : " . $select { query };
like image 930
PoorLuzer Avatar asked Oct 24 '09 09:10

PoorLuzer


1 Answers

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.

like image 180
Greg Hewgill Avatar answered Sep 19 '22 20:09

Greg Hewgill