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
In reply to Re: Array confusion.
by johngg
in thread Array confusion.
by anonypl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |