Shawn H Corey wrote:
On 11/08/11 07:17 PM, siegfr...@heintze.com wrote:
This works! Is there a way to do it with less typing? How can I do it
without creating a temporary variable "@p"?
Thanks,
siegfried

find /xyz -exec perl -e 'foreach(@ARGV){ my @p=split "/"; rename $_,
"./$p[$#p].txt" } '

find /xyz -exec perl -e 'foreach(@ARGV){ my @_=split "/"; rename $_,
"./$_[$#_].txt" } '

split() uses @_ by default so you could just say:

find /xyz -exec perl -e 'for(@ARGV){ split "/"; rename $_, "./$_[-1].txt" } '



John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.                   -- Albert Einstein

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to