Im trying to surround all values in my hash with single quotes. here is my code.
foreach(values(%properties_hash))
{
print "'".$_."'\n";
}
Right now I'm printing. How would I actually augment the value. Also this prints
'logs
'format/systemout-2010-format.txt
'analyze
It is only printing the first '. Why would that be?
Thanks!
Your code is working.
my %h = (
'a' => 1,
'b' => 2,
'c' => 3,
'd' => 4,
);
foreach(values(%h)) {
print "'".$_."'\n";
}
prints
'3'
'1'
'2'
'4'
Your strings are probably ended with "\r", so the ending "'" is printed over 1 st "'" and therefore don't see the last apostrophe. try:
foreach(values(%h)) {
s/[\r\n]//g;
print "'".$_."'\n";
}
How about this?
foreach (keys %properties_hash) {
$properties_hash{$_} = "'$properties_hash{$_}'\n";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With