use strict; my $list = undef; my $lastnode = \$list; while (1) { print 'nput, utput : '; chomp (my $input = ); if ($input eq 'i') { &add; next; } if ($input eq 'o') { &show; next; } } sub add { chomp (my $input = ); my $newnode = [undef, $input]; $$lastnode = $newnode; $lastnode = \$newnode -> [0]; } sub show { for (my $node = $list; $node; $node = $node -> [0]) { print $node -> [1] . "\n"; } }