sub depo { open (IFILE, "<", "Inventory.txt") or die "Can not open file\n"; my @inv = (); close (IFILE); while (<@inv>) { chomp $_; print ucfirst . "\n"; } my $ans = lc(); chomp $ans; print "Say 'menu' to go back to menu.\n"; while (<@inv>) { chomp $_; if ($_ =~ m/$ans/) { open (SFILE, ">>", "Storage2.txt") or die "Can not open file\n"; print SFILE "$ans\n"; close (SFILE); open (WFILE, ">", "Inventory.txt") or die "Can not open file\n"; while (<@inv>) { print WFILE "$_\n" unless /$ans/; } print "You have stored $ans\n"; close (WFILE); &depo; } elsif ($ans eq "menu") { &menu; } else { print "Item does not exist in Inventory!\n"; &depo; } } }