Forum Moderators: coopster & phranque

Message Too Old, No Replies

Bad name, but I don't see the problem

         

csdude55

8:41 pm on Dec 5, 2023 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm getting this error in my log:

Bad name after HTTP_CF_IPCOUNTRY'


Here's the section of the script it's flagging:

if (
$ENV{'HTTP_CF_IPCOUNTRY'} && # this is the line it's referencing
$ENV{'HTTP_CF_IPCOUNTRY'} ne 'US'
) { ... }

That's an exact copy-and-paste from my script, minus the comment of course.

I modified it to use exists() in case that was the problem, but I still get the same error:

if (
exists($ENV{'HTTP_CF_IPCOUNTRY'}) &&
$ENV{'HTTP_CF_IPCOUNTRY'} ne 'US'
) { ... }


Any idea what's causing the problem?

Brett_Tabke

10:11 pm on Dec 5, 2023 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



turn on strict and warnings and run it. Might produce a different error.

Exists was a nice try. Might also try "if length($ENV{'HTTP_CF_IPCOUNTRY'})"

Or set HTTP_CF_IPCOUNTRY to another variable and make a check on that variable. (weird I know)

For some reason, Perl can rarely get confused about numeric vs string. I used to think it was windows doing it, but given I am almost 100% *nix dev these days....

That looks like CloudFlare environ header?

lucy24

10:40 pm on Dec 5, 2023 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Bad name after HTTP_CF_IPCOUNTRY'
Is that literally what the error message says, with mismatched ' (single quote), or is that an artifact of posting?

csdude55

1:19 am on Dec 6, 2023 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I figured it out, and I feel so dumb :-/

This particular script was wrapped in eval ' '; just in case I coded an error, and I needed the main script to run anyway. For testing I was removing the eval, and unable to duplicate the error.

But OF COURSE, now I see that the issue was the danged single quote for eval! The script was seeing the first ' in the $ENV as closing the eval, so of course the rest of it was an error.

Sigh. I'm too old for this ****.

LOL

tangor

5:06 am on Dec 6, 2023 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Coding is a full contact sport.

Experience is what we get after we needed it.