print shift @array while @array;... which prints, but also dismantles an array.
Using that idiom inside an anonymous subroutine is non-destructive!
knoppix@Microknoppix:~$ perl -E ' > @arr = qw{ 11 22 33 44 }; > sub { say shift while @_ }->( @arr ); > say qq{@arr};' 11 22 33 44 11 22 33 44 knoppix@Microknoppix:~$
Cheers,
JohnGG
In reply to Re^3: TIMTOWTDI - printing an array
by johngg
in thread TIMTOWTDI - printing an array
by cheekuperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |