SPUG: Another program head scratcher
Sweethomes
sweetsue at sweethomes.com
Sat Jul 13 13:07:15 CDT 2002
Super - that did part of the trick! Now, it gets as far as the first part
then stops. I'll keep plugging away I guess :)
Susanne
-----Original Message-----
From: Creede Lambard [mailto:creede at penguinsinthenight.com]
Sent: Saturday, July 13, 2002 10:52 AM
To: Sweethomes
Cc: Seattle Perl User's Group
Subject: Re: SPUG: Another program head scratcher
On Sat, 2002-07-13 at 10:25, Sweethomes wrote:
> If you guys are sick of me, let me know LOL (I've been learning a lot the
> past week or so, PHP and MySQL are more my forte, thank you for your help
> lately!). I have a program (see near bottom) that is supposed to open a
> file, read it, check to see if an ip is already entered or if the count
has
> reached 2 and if so, print out a quick message saying they can't enter as
> they already have. Then, if it's a new ip and the count is less than 2,
it
> will record the ip address, increment the count then (and this isn't in
> there yet) proceed to the "contest" page. It's only doing the count to 1
> over and over and it's not picking up that an ip has been there before.
> Here are the errors I see when trying to process it:
>
> Use of uninitialized value in numeric eq (==) at test2.cgi line 15.
> Argument "67.40.29.147" isn't numeric in numeric eq (==) at test2.cgi line
> 15.
> Argument "0|\n" isn't numeric in numeric eq (==) at test2.cgi line 15.
> Use of uninitialized value in string ne at test2.cgi line 75, <RDIR> line
1.
>
OK, I'll admit I didn't get any farther than this, because the "isn't
numeric" is a CLUE in capital letters. :)
When you're dealing with numbers, you use "==". When you're dealing with
strings, you use "eq". Unless, of course, you decide to use =~ instead.
If I remember right =~ is more expensive than eq, but also more flexible
because of the regular expressions (as long as you don't let the
"explosion in a punctuation factory" stuff scare you, of course). Just
to use a trivial example, you can replace
if (uc(substr($answer, 0, 1)) eq 'Y') { return 1; }
with
if ($answer =~ /^y/i) { return 1; }
--
* .~. `(
----------------------------------------------------------------
` / V \ . Creede Lambard : Just who is this General
Failure
/( )\ creede at penguinsinthenight.com : and why is he reading my
disk?
^^-^^
----------------------------------------------------------------
Perl Programmer and Linux Sysadmin, reasonable rates. Inquire within.
GPG key at http://www.penguinsinthenight.com/creede_public_key.asc
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
More information about the spug-list
mailing list