use warnings; use strict; my %storage = map { $_ => 1 } qw(knife wand bow); my %inventory = map { $_ => 1 } qw(axe sword shovel); while (1) { print "Which item would you like to deposit?\n"; print "$_\n" for sort keys %inventory; my $choice = lc <STDIN>; chomp $choice; if (exists $inventory{$choice}) { delete $inventory{$choice}; $storage{$choice}++; print qq(You have stored a "$choice".\n); } elsif ($choice eq 'end') { last; } } use Data::Dumper; $Data::Dumper::Sortkeys=1; print Dumper(\%storage); print Dumper(\%inventory);
In reply to Re: Push,pop, and splice!
by toolic
in thread Push,pop, and splice!
by Jabox
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |