Silentbob19
asked on
Perl roockie! please help
Hello, this is my first day using perl and site experts-exchange.com to.
I making a single perl script to read from a text file and then ask for an action.
chop ($number);
if ($number eq 4){
print "Cool.\n\n";
}
if ($number ge 5){
print "That's to much!\n\n";
}
else {
print "That's Nothing";
}
If I put 3 or less it says "That's Nothing" (OK)
If I put 5 or more it says "That's to much!"; (OK)
But why if I set eq 4 says "Cool." when I put 4 it says
"Cool." - and also - "That's Nothing"
I making a single perl script to read from a text file and then ask for an action.
chop ($number);
if ($number eq 4){
print "Cool.\n\n";
}
if ($number ge 5){
print "That's to much!\n\n";
}
else {
print "That's Nothing";
}
If I put 3 or less it says "That's Nothing" (OK)
If I put 5 or more it says "That's to much!"; (OK)
But why if I set eq 4 says "Cool." when I put 4 it says
"Cool." - and also - "That's Nothing"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Also if I put 125 for ex. It't thinks it is 1 and not 125
Sorry about my english... I speak spanish.
Sorry about my english... I speak spanish.
I used my so the code would pass "use strict;"
chomp is safer in that it only removes $/
chomp is safer in that it only removes $/
Also if I put 125 for ex. It't thinks it is 1 and not 12
ge is a string comnpare, use >= to compare numbers
ge is a string comnpare, use >= to compare numbers
ASKER
Thank's so mucho... This is my first day on perl... I have to learn a lot.
ASKER
And why chomp and not chop?
There's a diference if a use it like
$number = <STDIN>;
chop ($number);