UNIX pipes

dossy@panoptic.com 6/13/02 7:27PM >>>
What’s the accepted way to use a UNIX pipe? I wound up using Ruby
commands instead of sed…

Why use sed when Ruby already has regex? I’d
certainly just take the output of gunzip and
process it in Ruby rather than with another
process (sed).

I’m used to using ksh - in fact, I write in ksh more the Ruby, Perl, and C put together (sorry…)

Ruby’s gsub(pat, str) form never felt “right” - I kept wanting s/pat1/pat2/ - and why not? I really am curious…

Instead of:

“My string”.gsub(/My/, “His”)

…why not?

“My string”.s/My/His/

…?

David Douthitt
CUNA & Affiliates
UNIX Systems Administrator
ddouthitt@cuna.coop
(608) 231-4922

···

On 2002.06.14, David Douthitt DDouthitt@cuna.coop wrote:

Too much syntactic sugar will give you syntactic cavities.

This might be possible (but not implemented, AFAIK):

str = “My string”.s /My/ /His/

But then, that’s close enough to:

str = “My string”.gsub /My/ “His”

I do wish that the more natural s/pat/pat/mod syntax could
be used in Ruby, but it’s not a big deal.

– Dossy

···

On 2002.06.14, David Douthitt DDouthitt@cuna.coop wrote:

Ruby’s gsub(pat, str) form never felt “right” - I kept wanting
s/pat1/pat2/ - and why not? I really am curious…

Instead of:

“My string”.gsub(/My/, “His”)

…why not?

“My string”.s/My/His/


Dossy Shiobara mail: dossy@panoptic.com
Panoptic Computer Network web: http://www.panoptic.com/
“He realized the fastest way to change is to laugh at your own
folly – then you can let go and quickly move on.” (p. 70)