Re: Simple way to Reverse an Array



Dr.Ruud <rvtol+news@xxxxxxxxxxxx> wrote in comp.lang.perl.misc:
Dr.Ruud:
A. Sinan Unur:

A. Sinan Unur <1usa@xxxxxxxxxxxxxxxxxxx>
(reverse each component and remove .invalid for email address)

echo 'cba@xxxxxxxxxxxxxxx' \
| perl -ple '@_=/(\w+|.)/g;pop@_,pop@_;$_=reverse@_=reverse@_'

| perl -ple 'split/(\W)/;pop@_;pop@_;$_=reverse@_=reverse@_'

| perl -ple 's/\.[^.]+$//;s/(\w+)/reverse$1/eg'

Much more pedestrian, but shorter is shorter.

Anno, who used to say he doesn't do golf.
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
.



Relevant Pages