Adding ' ' around all values in hash
perl, string
Solution
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";
}
Problem
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!