On Wed, May 02, 2001 at 11:44:20PM -0700, David Monarres wrote:
: I am alos fairly new with perl and completely new with perl one liners. I
: see how you can use regex's on the cmd line to edit a file (sort of sed
: ish). I tried this
: 
: $ perl -pe 's/hello/reverse($1)/' -i test
: 
: all it print's is reverse. I was wondering if you knew of a way to read in
: a word and reverse it's contents. Not critical but it has intrigued me.
: Thank you in advance
: David Monarres
: <[EMAIL PROTECTED]>

You could use the -n switch which works just like -p except it does
NOT automatically print '$_' for you:

  perl -nle'chomp, print scalar reverse'

or, instead of using a regex, you could do:

  perl -ple'chomp, $_ = scalar reverse'

Enjoy!

  Casey West

-- 
"Special today---no ice cream."
 --In a Swiss mountain inn

Reply via email to