in reply to Re: What makes good Perl code?
in thread What makes good Perl code?
I want a way for the else block to run if both the inputs don't have numbers in them. Perhaps with an elsif block? However, I'm not aware of anything that would do what I require. Maybe with an algorithm? I don't know of ANY algorithms at all except for the Fischer-Yates shuffle, and that's pretty useless nowadays, considering Perl has a shuffle command anyways. Anyone know of a way to test for a number in a variable?IF: if($current && $resistance) { if($current =~ s/mA//i) { $current /= 1000; } else { } } else { print "Those aren't valid answers.\n"; print "Please type that again, will ya?\n"; print "Type the current of the circuit.\n"; print "Add mA at the end of your answer\n"; print "if your answer is in milliAmps.\n"; $current = <STDIN>; chomp $current; print "Now type the resistance of the circuit.\n"; $resistance = <STDIN>; chomp $resistance; goto IF; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: What makes good Perl code?
by Friendly Daemon (Initiate) on Aug 16, 2011 at 20:12 UTC | |
|
Re^3: What makes good Perl code?
by ForgotPasswordAgain (Vicar) on Aug 16, 2011 at 23:21 UTC |