http://www.perlmonks.org?node_id=1224540

bigup401 has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: $ENV{REMOTE_ADDR} problem
by 1nickt (Canon) on Oct 23, 2018 at 11:06 UTC

    "i dont know wats the problem here"

    The problem is you are lazy and intellectually undisciplined. How can you submit a post with a question written like the above? If you can't take a few seconds to capitalize or spell your words or use grammar or punctuation, why should anyone believe that you are doing differently in your code? (Obviously you are not.)

    Until you learn and practice mental discipline and clear thinking, you will never succeed in your web programming: you are wasting your time. And that of those monks who are kind enough to try to decipher your garbage posts and help you.

    You are a freeloader and I hate freeloading. You have shown yourself not worthy, by not using minimal effort, to dwell here and consume the Monastery's resources, and the only reason you have not been expelled as you would have been from any other place of learning, is that the Monks practice charity as part of our own discipline. But you are just wasting our time; shame on you.

    Now you may think this is unfair because you spend hours working on your code trying to make it do what you want. But you are wasting your own time as well, because you do not do the most basic things to increase your understanding and skill level, even when the Monks have shown you those things many times.

    For example, if $REMOTE_IP does not match $query, you should print out those variables and see what they contain, before you post here another question beginning with "i dont know wats the problem here."


    The way forward always starts with a minimal test.

      good response @lnickt

      i thought this would work also in cgi $ENV{REMOTE_ADDR}

      i changed to $cgi->remote_addr() and works

        You should take what 1nickt wrote and give it due consideration. You didn't post a working script, what you posted makes no sense at all. You said that $query contains a string (you didn't enclose it in quotes, nor end the line with a ;) and are now claiming that "select my remote_ip from tbl where me = me" is not equal to a value returned by $cgi->remote_addr(). This makes no sense

Re: $ENV{REMOTE_ADDR} problem
by harangzsolt33 (Chaplain) on Oct 24, 2018 at 06:31 UTC
    I usually do this:
    my $IP = ENV('REMOTE_ADDR', '0.0.0.0'); print $IP; exit; ################### # This function returns an environment variable named in the # first argument. If the environment variable doesn't exist, # then DEFAULT is returned. However, if a third argument is # given, then that will be returned in every case. # The third argument is used for tweaking and testing purposes. # # Usage: VALUE = ENV( NAME, [DEFAULT, [OVERRIDE]] ) # sub ENV { return '' unless @_; # No arguments at all? my $NAME = shift; # Get NAME my $DEFAULT = @_ ? shift : ''; # Get DEFAULT value return shift if @_; # OVERRIDE? return $DEFAULT unless defined $NAME; # NAME undefined? return $DEFAULT unless $NAME; # NAME is blank? if (exists($ENV{$NAME})) { return Trim($ENV{$NAME}); } return $DEFAULT; } ################### # # This function removes whitespace before and after STRING # and returns a new string. # # Usage: STRING = Trim(STRING) # sub Trim { return '' unless @_; my $T = shift; return '' unless defined $T; return '' unless length($T); my $s = -1; # start ptr my $e = 0; # end ptr for (my $i = 0; $i < length($T); $i++) { if (vec($T, $i, 8) > 32) { if ($s < 0) { $s = $i; } $e = $i; } } return substr($T, $s, $e - $s + 1); }
    This means, even if REMOTE_ADDR is undefined for whatever reason, I get a string in $IP which is going to be 0.0.0.0. And then I know that it's because it was undefined!
Re: $ENV{REMOTE_ADDR} problem
by Anonymous Monk on Oct 23, 2018 at 10:03 UTC
    this guy is a known troll. don't feed