D
Daniel Bretoi
perl -e '$a="hello hi hello";$a =~ s/(\w+)/$1a/g;print $a; '
helloa hia helloa
ruby -e 'a="hello hi hello";a.gsub!(/(\w+)/,"#{$1}a"); puts a'
a a a
Why? I'm expecting the same result as in perl.
ruby -e 'a="hello hi hello";a.gsub!(/(\w+)/) { |k| k = k + "a"}; puts a'
helloa hia helloa
does however work.
Can someone try to explain why the first doesn't work?
db
helloa hia helloa
ruby -e 'a="hello hi hello";a.gsub!(/(\w+)/,"#{$1}a"); puts a'
a a a
Why? I'm expecting the same result as in perl.
ruby -e 'a="hello hi hello";a.gsub!(/(\w+)/) { |k| k = k + "a"}; puts a'
helloa hia helloa
does however work.
Can someone try to explain why the first doesn't work?
db