• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

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"

0
Silentbob19
Asked:
Silentbob19
  • 3
  • 3
1 Solution
 
ozoCommented:
my $number = <STDIN>;
chomp $number;
if( $number == 4 ){
    print "Cool.\n\n";
}elsif( $number >= 5 ){
    print "That's to much!\n\n";
}else{
   print "That's Nothing"
}
0
 
Silentbob19Author Commented:
why do you use "my"?
And why chomp and not chop?

There's a diference if a use it like
$number = <STDIN>;
chop ($number);
0
 
Silentbob19Author Commented:
Also if I put 125 for ex. It't thinks it is 1 and not 125

Sorry about my english... I speak spanish.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
ozoCommented:
I used my so the code would pass "use strict;"

chomp is safer in that it only removes $/
0
 
ozoCommented:
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
0
 
Silentbob19Author Commented:
Thank's so mucho... This is my first day on perl... I have to learn  a lot.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now