On Nov 13, Nandita Mullapudi said:

>This has to be really easy- but I cant get it to work:
>I want my script to carry out a loop only if the number stored in
>$diff is positive,
>so i say
>if ($diff =~m/^[-\d+]/) {blah blah}
>but it won't work. why?

Well, your regex is matching either a digit, a -, or a + as the first
character in $diff.  If you wanted to match a POSITIVE number, you'd be
better with /^+?\d/, but WHY are you using a regex for a MATH problem?

  if ($diff > 0) { ... }

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
<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.  ]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to