Casey West wrote ..

>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'


except that will reverse the entire line when the originator seemed to only
want to reverse instances of the word 'hello'

-- 
  jason king

  It is illegal to "annoy a bird" in any city park of Honolulu, Hawaii.
  - http://dumblaws.com/

Reply via email to