pinnacle has asked for the wisdom of the Perl Monks concerning the following question:
SCRIPT
#!/usr/bin/perl -w use Checking; $here = <<ATM; 1 deposit 2 withdraw 3 current Balance 4 exit ATM print $here; print "Enter the type of transaction you want to do:"; $enter = <STDIN>; if($enter == '1') { print "Enter the amount you want to deposit:"; $mon = <stdin>; $d = Checking::deposit($mon); print "Deposited Amount: $d\n"; #&deposit($mon); }
Package
package Checking; my $bal = 0; sub deposit { $d = @_; $bal = $bal+$d; # print $bal; #return; } 1;
RESULT
./myATM.pl 1 deposit 2 withdraw 3 current Balance 4 exit Enter the type of transaction you want to do:1 Enter the amount you want to deposit:23 Deposited Amount: 1
I dont understand why in the result its not showing deposited money as 23, instead it always shows 1, I am doing some silly mistake, please assist !!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: atm deposit problem
by davido (Cardinal) on Jul 20, 2011 at 02:10 UTC | |
by tospo (Hermit) on Jul 20, 2011 at 08:22 UTC | |
by Anonymous Monk on Jul 20, 2011 at 13:21 UTC | |
by tospo (Hermit) on Jul 20, 2011 at 13:57 UTC | |
by pinnacle (Acolyte) on Jul 20, 2011 at 18:09 UTC | |
|
Re: atm deposit problem
by choroba (Cardinal) on Jul 20, 2011 at 09:40 UTC | |
|
Re: atm deposit problem
by Anonymous Monk on Jul 20, 2011 at 22:17 UTC |