SPUG: Another program head scratcher

Sweethomes sweetsue at sweethomes.com
Sat Jul 13 14:27:36 CDT 2002

I think I pinpointed one problem anyway.  The coding is:

foreach $line(@ipx) {
  @ipstuff = split(/\\n/, $line);
  foreach $ipl (@ipstuff) {
    ($cnt, $ipadd) = split(/\|/, $ipl);

The errors I get are:

Argument "\n" isn't numeric in numeric ne (!=) at test2.cgi line 15.
Argument "" isn't numeric in numeric ne (!=) at test2.cgi line

Do I need to strip out the returns somehow?  And it just seems like it's not
splitting out the lines as it should.


-----Original Message-----
From: owner-spug-list at pm.org [mailto:owner-spug-list at pm.org]On Behalf Of
Creede Lambard
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
> 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,
> 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 "" 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

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; }


if ($answer =~ /^y/i) { return 1; }

 * .~. `(
` / V \  . Creede Lambard                : Just who is this General
 /(   )\   creede at penguinsinthenight.com :   and why is he reading my

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