http://www.perlmonks.org?node_id=937799


in reply to how to avoid using index of array

Stacks?
plankton@chumbucket:~$ cat stack.pl #!/usr/bin/perl -w use strict; my @boys = qw/boy boymonkey boydog/; my @girls = qw/girl girlmonkey girldog/; while (@boys){ # will be boys my $boy = pop( @boys ); my $girl = pop( @girls ); print "boy =[$boy] girl=[$girl]\n"; } plankton@chumbucket:~$ ./stack.pl boy =[boydog] girl=[girldog] boy =[boymonkey] girl=[girlmonkey] boy =[boy] girl=[girl]