Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

very very basic question

Status
Not open for further replies.

JamesMcG

IS-IT--Management
Jun 16, 2000
31
0
0
IE
I have never used perl before. I would like to state that from the offset.<br><br>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.<br><br>I am useing a case statement to find out if a number is within a certain range how can this be done?<br><br>will it be something like<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case csconitm &lt; 5<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cprice = 12<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case csconitm &gt; 4 .AND. &lt; 10<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cprice = 13<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case csconitm &gt; 9<br> &nbsp;&nbsp;cprice = 19<br><br>any help is most appreciated<br><br>Best Regards<br>James<br><br>please bear in mind I have no books or help files.<br><br><br>
 
Perl does not 'really' do case statements in the same sense that 'C' does....however, you can do something link this...<br><FONT FACE=monospace><br>DO_CASE: {<br>if ($csconitm &lt; 5)<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;$cprice = 12;<br>&nbsp;&nbsp;&nbsp;&nbsp;last DO_CASE;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>if (($csconitm &gt; 4) && ($csconitm &lt; 10))<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;$cprice = 13;<br>&nbsp;&nbsp;&nbsp;&nbsp;last DO_CASE;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>if ($csconitm &gt; 9)<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;$cprice = 19;<br>&nbsp;&nbsp;&nbsp;&nbsp;last DO_CASE;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>} # end of DO_CASE<br>[\tt]<br><br>...pretty much what the Camel book says.....<br>You can name your block what ever you like.&nbsp;&nbsp;DO_CASE was the first name in my head.&nbsp;&nbsp;If you have the Camel book, see 'case structure'.&nbsp;&nbsp;If you don't have it, I suggest you get it.<br><i><br>Programming Perl<br>Wall, Christiansen, and Schwartz<br>O'Reilly & Associates, Inc.<br></i><br><br>'hope this helps <p> <br><a href=mailto: > </a><br><a href= > </a><br> keep the rudder amid ship and beware the odd typo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top