Re: Question in perl syntax

2002-05-15 Thread drieux
On Wednesday, May 15, 2002, at 01:50 , John W. Krahn wrote: > > $ perl -le' > $val = q/3.1415BOB/; > if ( $val =~ /^\d+/ and $val > 0 and $val <11) { > print "True" } > else { > print "False" } > > print 1 + $val; > ' > True > 4.1415 hum... how to say this a) try with if ( $va

Re: Question in perl syntax

2002-05-15 Thread John W. Krahn
Drieux wrote: > > On Wednesday, May 15, 2002, at 01:02 , John W. Krahn wrote: > > Felix Geerinckx wrote: > >> on Wed, 15 May 2002 03:12:15 GMT, [EMAIL PROTECTED] (Drieux) wrote: > [..] > >>> if ( $val =~ /^\d+/ and $val > 0 and $val <11) { > >> > >> Not good enough. > >> > >> $val = 3.14

Re: Question in perl syntax

2002-05-15 Thread drieux
On Wednesday, May 15, 2002, at 01:02 , John W. Krahn wrote: > Felix Geerinckx wrote: >> on Wed, 15 May 2002 03:12:15 GMT, [EMAIL PROTECTED] (Drieux) wrote: [..] >>> if ( $val =~ /^\d+/ and $val > 0 and $val <11) { >> >> Not good enough. >> >> $val = 3.141592654; >> >> is perfectly numeri

Re: Question in perl syntax

2002-05-15 Thread Felix Geerinckx
on Wed, 15 May 2002 20:02:01 GMT, John W. Krahn wrote: > Felix Geerinckx wrote: >> >> $val = 3.141592654; >> >> is perfectly numeric but fails your /^\d+/. > > No it doesn't Of course it doesn't! Thanks John for spotting this (missing $ at the end of the regex :-) -- felix -- To unsu

Re: Question in perl syntax

2002-05-15 Thread John W. Krahn
Felix Geerinckx wrote: > > on Wed, 15 May 2002 03:12:15 GMT, [EMAIL PROTECTED] (Drieux) wrote: > > > so you need to check that it is numeric... > > so you could do it with say > > > > if ( $val =~ /^\d+/ and $val > 0 and $val <11) { > > Not good enough. > > $val = 3.141592654; > > is

Re: Question in perl syntax

2002-05-15 Thread drieux
On Wednesday, May 15, 2002, at 09:12 , Jaishree Rangaraj wrote: > Hi > Now, I want to check if string or charcater is in the range. Can u > please suggest me something http://www.wetware.com/drieux/pbl/perlTrick/RangeChecker.txt but in that case you want to modify the my %is_vali

RE: Question in perl syntax

2002-05-15 Thread Timothy Johnson
Check out the perlop manpage for lt,gt,le,ge, and eq. These are the string equivalents of <,>,<=,>=, and == respectively. -Original Message- From: Jaishree Rangaraj To: [EMAIL PROTECTED] Sent: 5/15/02 9:12 AM Subject: Re:Question in perl syntax Hi Now, I want to check if string or

Re: Question in perl syntax

2002-05-15 Thread drieux
On Wednesday, May 15, 2002, at 02:55 , Felix Geerinckx wrote: > on Wed, 15 May 2002 03:12:15 GMT, [EMAIL PROTECTED] (Drieux) wrote: >> >> so you could do it with say >> >> >> if ( $val =~ /^\d+/ and $val > 0 and $val <11) { > > Not good enough. > > $val = 3.141592654; > > is perfectly n

Re: Question in perl syntax

2002-05-15 Thread Felix Geerinckx
on Wed, 15 May 2002 03:12:15 GMT, [EMAIL PROTECTED] (Drieux) wrote: > so you need to check that it is numeric... > > so you could do it with say > > > if ( $val =~ /^\d+/ and $val > 0 and $val <11) { Not good enough. $val = 3.141592654; is perfectly numeric but fails your /^\

Re: Question in perl syntax

2002-05-14 Thread Jim C.
My last post is assuming that the script is cgi. Not that it would hurt anything if the script wasn't CGI and in fact, could still legit'ly be helpful and prudent. - Jim On Wed, 2002-05-15 at 00:12, drieux wrote: > > On Tuesday, May 14, 2002, at 06:57 , Bill Akins wrote: > > > How about somet

Re: Question in perl syntax

2002-05-14 Thread Jim C.
And lets not forget to remove all nulls from the user input. Nulls can be used to trick the script into thinking its getting valid input and its usually good practice to just strip em. It certainly can't hurt anything and most certainly can help everything. - Jim $s_field =~ s/\0//g; On Wed,

Re: Question in perl syntax

2002-05-14 Thread drieux
On Tuesday, May 14, 2002, at 06:57 , Bill Akins wrote: > How about something like this: > > if (($s_field >= 1) && ($s_field <= 10)) { >do something; > } > else { > do something else; > } the problem is that as long as $s_field is always numeric, then there wil

Re: Question in perl syntax

2002-05-14 Thread Arul, Rex (NEA-IMAP)
Jaishree: 'eq' operator is used only if the values you are comparing are anything other than numeric data type. '==' operator is used to compare for numeric data-type. Your condition should be as follows: if(($_field >=1) && ($_field <=10)){ do something } Similarly, if($_field eq 'some