Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Perl roockie! please help

Posted on 2002-07-14
6
Medium Priority
?
186 Views
Last Modified: 2010-03-05
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
Comment
Question by:Silentbob19
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 200 total points
ID: 7152998
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
 

Author Comment

by:Silentbob19
ID: 7153012
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
 

Author Comment

by:Silentbob19
ID: 7153020
Also if I put 125 for ex. It't thinks it is 1 and not 125

Sorry about my english... I speak spanish.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 84

Expert Comment

by:ozo
ID: 7153025
I used my so the code would pass "use strict;"

chomp is safer in that it only removes $/
0
 
LVL 84

Expert Comment

by:ozo
ID: 7153029
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
 

Author Comment

by:Silentbob19
ID: 7153052
Thank's so mucho... This is my first day on perl... I have to learn  a lot.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question