use strict; my $list = { head=>undef, tail=>undef }; while (1) { print 'nput, utput : '; chomp (my $input = ); if ($input eq 'i') { add($list); next; } if ($input eq 'o') { show($list); next; } } sub add { my ($list) = @_; chomp (my $input = ); my $newnode = [undef, $input]; $list{tail}[0]= $newnode; $list{tail}= $newnode; }