Mega Code Archive

 
Categories / Perl / Array
 

Using Arrays as Stacks

#!/usr/local/bin/perl -w push (@myList, "Hello"); push (@myList, "World!"); push (@myList, "How"); push (@myList, "Are"); push (@myList, "You?"); while ( $index = pop(@myList) ) {    print "Popping off stack: $index\n"; }