in reply to How do a make an IP look up non-greedy?

use index
if ( -1 > index $logs[$lcounter], $ENV{'REMOTE_ADDR'} ){ ...
FYI, $logs[$lcounter]=~^/$ENV{'REMOTE_ADDR'}/ is a syntax error.

Replies are listed 'Best First'.
Re^2: How do a make an IP look up non-greedy?
by kjg (Sexton) on Jun 16, 2009 at 10:23 UTC
    Thanks.
    Yep '^' etc was a typo on my behalf as I tried to re-instate the code to what it was before I started fiddling!
    Never knowingly obfuscated
Re^2: How do a make an IP look up non-greedy?
by Anonymous Monk on Jun 16, 2009 at 10:11 UTC
    /\Q$ENV{'REMOTE_ADDR'}\E/
      BTW - has anyone got a link to a good online Perl Reg Expr tester. I'm using this one but I don't think it's very good for Perl Reg Exprs: http://www.regextester.com/

      Never knowingly obfuscated

        Your command line is closer at hand and will do just fine as a regex tester. This perl one-liner creates a little loop that you can use to test as many regex combinations as you please or to test small bits of other perl code. It creates a simple read-eval-print (REP) loop:

        perl -ne'{ print "==>",eval,"\n" }'

        To use:

        1. Enter the above on your command line and hit return. This starts the REP loop.
        2. Enter a perl statement (variable assignment, regex match statement, etc) and hit return. The result will be printed out.
        3. Repeat until you are bored
        4. Hit control-D to end the loop

        Note: tested only on Linux. Presumably also works in cywgin-bash. MsWin command lines are a bit funky and I'm not sure how well perl one-liners behave there. Perhaps another monk can fill in.

        Best, beth