Comparison: finding if a value is gt some value AND lt another

Hello, All:

Is there a simple way to find if a variable's value is within a range? 
e.g.,

  if (1 < $x < 5) { print 'foo'; }

.....or do I have to join two separate comparisons using the logical AND 
operator? e.g.,

  if (1 < $x and $x < 5) { print 'foo'; }

-- 
Eric P.
Sunnyvale, CA

0
eric
9/26/2002 8:12:42 PM
perl.beginners 29388 articles. 4 followers. Follow

2 Replies
500 Views

Similar Articles

[PageSpeed] 36

On Sep 27, eric-perl@pretorious.net said:

>Is there a simple way to find if a variable's value is within a range?
>e.g.,
>
>  if (1 < $x < 5) { print 'foo'; }

You can't do that until Perl 6.

>....or do I have to join two separate comparisons using the logical AND
>operator? e.g.,
>
>  if (1 < $x and $x < 5) { print 'foo'; }

You have to do that for now.

-- 
Jeff "japhy" Pinyan      japhy@pobox.com      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]

0
japhy
9/27/2002 2:04:20 PM
On Fri, 27 Sep 2002, Jeff 'japhy' Pinyan wrote:
> On Sep 27, eric-perl@pretorious.net said:
> >Is there a simple way to find if a variable's value is within a range?
> >  if (1 < $x < 5) { print 'foo'; }
> >...or do I have to join two separate comparisons using the logical AND
> >operator? e.g.,
> >  if (1 < $x and $x < 5) { print 'foo'; }
> 
> You have to do that for now.

Many thanks!

-- 
Eric P.
Sunnyvale, CA

0
eric
9/30/2002 8:47:27 AM
Reply:

Similar Artilces:

update <value > </value> in .resx file ??
Hi to all I have a localized page like aboutus.aspx in three language EN - FR - AR, in this page I have a localize control that contains a HTML Code to display the content of About us like this localized1.Text="<div >Amer Azzaz <br />Amer Azzaz, Amer Azzaz, <b> Amer Azzaz </b></div>"; The problem is: I create a back office for this page and I need the administrator to update the content of this control anytime, So, I can to read from aboutus.aspx.resx the value of this control <data name="localized1Resource1.Text" xml:space="preserve"><value>...

get value from <select> value & display value
hi all, i want these two bold values which are below,  underline value i can get but second bold value i m not avail to get please help.... <select><option value="ma">manoj</option> </select> regard khushak  P.S. if possible then Please with  java script other wise code behind New In .NET World See my post in this thread.  That should take care of you. Peter BrunoneMS MVP, ASP.NETFounder, EasyListBox.comDo the impossible, and go home early....

Dot notation for dw.SetItem (<row>, <col>, <value>) ?
Hi, Is there a dot notation for dw.SetItem (<row>, <col>, <value>) ? (dw. ... ??) If yes, would you give me an example? (My problem is that one SetItem command needs half a second because of thousands of rows in the data window !? OK, PB5 is quite old...) Thanks, Burkart Venzke ---== Posted via the PFCGuide Web Newsreader ==--- http://www.pfcguide.com/_newsgroups/group_list.asp Yes - look in help under "About DataWindow data expressions" Burkart Venzke wrote in message ... >Hi, > >Is there a dot notation for dw.SetItem (<row>,...

<asp:ListItem Value="name"><% this.strName %></asp:ListItem>
Hi, I declared a string strName and strAge which get data from DB. I want to show them in a CheckBoxList's ListItem. How can I do it? <asp:CheckBoxList ID="username" CssClass="form" Runat="server" RepeatColumns="2" RepeatDirection="Horizontal"> <asp:ListItem Value="name"><% this.strName %></asp:ListItem> <asp:ListItem Value="age"><% this.strAge %></asp:ListItem> <asp:CheckBoxList> It has runtime error. How can I fix it? Thanks I think you need <%...

<html:html><html:body><html:input xul:persist="value">
I have an HTML administration and I'd like make it use of XUL's @persist great feature without andy browser-dependant conditions. Is there a way how to take advantage of @persist in normal HTML page viewed by Mozilla? Requirements: 1. HTML elements must not include namespace prefix - it must stay 'html', 'body' etc. 2. No extra XUL elements such as root xul:window etc. - still have fully IE compatible code. 3. Try to avoid Javascript magic that appends XUL xul:window element etc. Is possible something like this? --- <html xmlns="h...

Field1 value --> variable name ; Field2 value --> variable value (C# code behind)
 I would like to add quantities to variables based on two fields in a table.  The table includes two field names: ingredient, weight.  Assume a simple formulation: add 50 lbs water, add 20 lbs eggs, add 10 lbs water, add 5 lbs salt.The table would have: water, 50 eggs, 20 water, 10 salt, 5The variables water, eggs, water and salt have already been defined. I want something that will cycle through and add the quantities (lbs) to the variable. Ingredients can appear more than once in a formulation--notice that water appears twice and at the e...

Quote values differently inside a <% value %> block
Why i got this error..is there a good way to resolved this ? im using a control inside a datalist to display a image depending with categorie i got.. any suggestion on how i can do it.. ?? thanx ======MY ERROR LINE=======IN MY HTML ======== <IMG alt="" runat=server src="images/icons/<%# CheckCategorie(DataBinder.Eval(Container.DataItem, "cat_no"))%>.gif">I like programming Hi, It seems that you're trying to get the image name from database and trying to concatenate using a helper function, but your helper function fails to do so....

i can't get the value with <%=value%>
onclick="PopUp('SayfaKod-Yardim.aspx?<%=URL01%>')" a hyperlink has that property but i cant get the value by using this. it redirects the webpages to SayfaKod-Yardim.aspx?<%=...... so it give bad request error. Where is the problem ? it is not IN A DATAGRID OR A GRIDVIEW. it is placed normally =)    but i CAN  get  a value by using same method on a datagrid but using with #databinder.eval   well =) i can get with a normal html link but how to get the same value with the hyperlink ? damn there is no edit button on that forum =) <asp:Hy...

If Not value or value then....
Hi all,I want to write a simple IF Not then statement in ASP.net 2.0 and I would like some help please.  If Not ntuser = "DOMAIN\ntuser" Or ntuser = "DOMAIN\ntuser2" Then Panel1.Visible = False End If Doesnt work, can you tell me where i'm going wrong please?many thanks.  The first place you're going wrong is in telling us it "doesn't work" without providing any details. JeffPlease: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue. Use Not as stated below. It ...

Programatically set an <object> <param> value
I am pluggin in a VRML viewer, but I must set the "SRC" param dynamically from the QueryString "?ID=1", perhaps in Page_Load(), perhaps some other way.  <object id="vrml" classid="CLSID:86A88967-7A20-11d2-8EDA-00600818EDB1" codebase=http://www.parallelgraphics.com/bin/cortvrml.cab#Version=5,1,0,167 width="300" height="300">     <param name="SRC" value="1.vrml" /> </object> How could I do this? I have figured it out.In the ASPX : <param name="SRC" valu...

<Value> could not set on property <prop> error
Following is code of a property in my control. When I change the value from default false to true. and try to switch to Designer mode. I am getting error. Control is not being loaded and saying : "Unhandled error occured. 'True' could not set on property CheckFutureDate. /// <summary> /// Gets or sets future date check (True by default). /// </summary> [Category("Validation")] [Description("Gets or sets future date check (false by default).")] [DefaultValue(false)] public bool CheckFutur...

Putting values of a DropDownList to my <update><asp:parameters...>
This probably a very simple question.I have a DropDownList where I want to pass the selected value down to my <update><asp: parameter.....My Template field where I have a dropdownlist in edit mode. <asp:TemplateField HeaderText="Websted" SortExpression="webstedid"> <ItemTemplate> <asp:Label ID="lblWebstedID" runat="server" Text='<%# Bind("webstedid") %>'></asp:Label> </ItemTemplate> <EditItemTemplate> &nbsp; <asp:DropDownList ID="WebstedIDDropDownList" runat="server" DataSourceID="WebstedObjectDataSource" DataTextField="i...

Error msg >> " is not a valid integer value << -- ?
(Win98SE) I am receiving this error message on loading an application (in this case, Rainbow Software's JPEG Cleaner) -- " is not a valid integer value. -- after which the program loads and works anyway. I'm trying to determine the meaning, cause and resolution of this error. Tried to write to app authors, no reply. Tried uninstalling, cleaning the registry and reinstalling, checking INI files, no help. A websearch for this identical message leads to many results, but for many different applications and programming languages, not this in particular. What'...

Find the values between two values
I obtain a value from a listbox similar to: "1-4" or "5-9" or "10-14" etc. What I'd like to be able to do, is to dynamically figure out the values between the start and end - for example: "1-4" = 1, 2, 3, and 4 Is there a simple way to do this? Are you using C# or VB. I can post a small sample if you tell me the language. Anyway, you can use Split() method using "-" as a separator, then read the array[0] and parse it as an int: Int32.Parse(array[0]) and the same with index 1, and just do a for.  Could you find provide a s...

Web resources about - Comparison: finding if a value is gt some value AND lt another - perl.beginners

Resources last updated: 1/16/2016 2:12:19 PM