From: Shashank Date Date: 2002-07-23T14:05:57+09:00 Subject: Re: piping into ruby at command line Thanks a lot, David ! You nailed it ... Thanks to you too Dossy and Mike for the suggestions. "David Alan Black" wrote in message news:Pine.LNX.4.30.0207221426320.1660-100000@candle.superlink.net... > Hi -- > > On Tue, 23 Jul 2002, Dossy wrote: > > > $ cat >junk.txt < > asdf > > 1234 > > EOT > > > > $ cat junk.txt | ruby -ne "print $_" > > > > Strangely, this didn't do what I expected: > > > > $ cat junk.txt | ruby -ne "puts $_" > > > > Using #puts, I got two blank lines. This happens in both 1.6.7 and > > 1.7.2: > > > > ruby 1.6.7 (2002-03-19) [i386-linux] > > ruby 1.7.2 (2002-05-30) [i686-linux] > > OK, after some mystification, I figured out what's happening. > > The shell is interpolating its own $_ -- which is nothing. > > So what you're really getting is just "print" and "puts". > > print uses $_ (the Ruby one) by default. puts doesn't. > > Try putting the inline script in single quotes instead of double, or > escape the $ with a \ . > > > David > > -- > David Alan Black > home: dblack@candle.superlink.net > work: blackdav@shu.edu > Web: http://pirate.shu.edu/~blackdav >