in reply to Array confusion.
A non-destructive way map'ing pop inside an anonymous subroutine.
johngg@shiraz:~/perl > perl -Mstrict -Mwarnings -E ' my @arr = ( q{a} .. q{z} ); my @rev = sub { map { pop } 1 .. @_ }->( @arr ); say qq{@arr}; say qq{@rev};' a b c d e f g h i j k l m n o p q r s t u v w x y z z y x w v u t s r q p o n m l k j i h g f e d c b a
I hope this is of interest.
Cheers,
JohnGG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Array confusion.
by BrowserUk (Patriarch) on Feb 14, 2017 at 23:51 UTC | |
by johngg (Canon) on Feb 15, 2017 at 11:44 UTC | |
by BrowserUk (Patriarch) on Feb 15, 2017 at 11:52 UTC |