I just don't know what to do to end the damn loops!?!
#!/usr/bin/perl -w
use strict;
print "Welcome to Techno-Bank 3000.\n";
print "Enter command => ";
my $input = <STDIN>;
chomp $input;
my ($command, $user, $amount) = split / /, $input;
my %accounts = ( $user => $amount );
while( $command ne "Exit" ){
if( $command eq "add" ){
$accounts{$user} += $amount;
print "done."
}elsif( $command eq "withdraw" ){
$accounts{$user} -= $amount;
print "done."
}elsif( $command eq "print" ){
foreach (sort keys %accounts) {
print "$_ has $accounts{$_}";
}}elsif( $command eq "exit" ){
print "Goodbye.\n";
}else{
print "Invalid command.";
}
}
print "Enter command => ";
$input = <STDIN>;
chomp $input;
Sample input
Welcome to Techno-Bank 3000.
Enter command => add jacob 1000
done.
Enter command => add jacob 10000
done.
Enter command => this is fun
invalid command.
Enter command => add fil 1000
done.
Enter command => wd fil 20
done.
Enter command => print
Here are the accounts in Techno-Bank 3000.
jacob has 11000.
fil has 980.
Enter command => exit
Goodbye.
So stuck!!! HELP :) Please.