Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby: simple command line with -pe is not working

Tags:

ruby

file:test

test

Command line input:

ruby -pe 'gsub(/t([a-z])s/){"d"+$1.capitalize}' test

I am expecting output to be dEt, but the actual output is:

#<Enumerator:0x00000001c78520>

I have no idea what happen. It works in irb when I do:

"test".gsub(/t([a-z])s/){"d"+$1.capitalize}
like image 865
SwiftMango Avatar asked Nov 13 '22 20:11

SwiftMango


1 Answers

This turns out to be a Ruby bug.

I submitted a bug ticket 2 days ago, and they already resolved it.

Here is the link to the bug ticket (it is now a backport):

Backport #7157

Here is the new change log to the trunk:

Change log: see Oct 14

like image 171
SwiftMango Avatar answered Jan 04 '23 03:01

SwiftMango