×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

very very basic question

very very basic question

very very basic question

(OP)
I have never used perl before. I would like to state that from the offset.

ok I have been given an old system written in perl to update, the update is not all that difficult and I have gotton along pretty well on my programming fundementals, that is until now.

I am useing a case statement to find out if a number is within a certain range how can this be done?

will it be something like
     case csconitm < 5
          cprice = 12
     case csconitm > 4 .AND. < 10
          cprice = 13
     case csconitm > 9
  cprice = 19

any help is most appreciated

Best Regards
James

please bear in mind I have no books or help files.


RE: very very basic question

Perl does not 'really' do case statements in the same sense that 'C' does....however, you can do something link this...

DO_CASE: {
if ($csconitm < 5)
    {
    $cprice = 12;
    last DO_CASE;
    }
if (($csconitm > 4) && ($csconitm < 10))
    {
    $cprice = 13;
    last DO_CASE;
    }
if ($csconitm > 9)
    {
    $cprice = 19;
    last DO_CASE;
    }
} # end of DO_CASE
[\tt]

...pretty much what the Camel book says.....
You can name your block what ever you like.  DO_CASE was the first name in my head.  If you have the Camel book, see 'case structure'.  If you don't have it, I suggest you get it.

Programming Perl
Wall, Christiansen, and Schwartz
O'Reilly & Associates, Inc.


'hope this helps




keep the rudder amid ship and beware the odd typo

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close