in reply to Re^3: How do a make an IP look up non-greedy?
in thread How do a make an IP look up non-greedy?

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

Replies are listed 'Best First'.
Re^5: How do a make an IP look up non-greedy?
by targetsmart (Curate) on Jun 16, 2009 at 11:18 UTC
    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.

    this works for me in command prompt (of course Perl must be there)
    perl -ne "{ print '==>',eval,$/ }"
    Ctrl + C to terminate this one+liner.


    Vivek
    -- In accordance with the prarabdha of each, the One whose function it is to ordain makes each to act. What will not happen will never happen, whatever effort one may put forth. And what will happen will not fail to happen, however much one may seek to prevent it. This is certain. The part of wisdom therefore is to stay quiet.
Re^5: How do a make an IP look up non-greedy?
by kjg (Sexton) on Jun 16, 2009 at 11:54 UTC
    If had access to my command line that would be great, but I don't! :sigh:
    Never knowingly obfuscated
Re^5: How do a make an IP look up non-greedy?
by AnomalousMonk (Archbishop) on Jun 16, 2009 at 12:45 UTC
    I'm puzzled by the presence of the curly brackets in your command-line statement exerciser: the code seems to work just fine without them.
    >perl -nle "print ' ==> ', eval" print 2 2 ==> 1 '12a34' =~ /(\d)/ ==> 1 '12a34' =~ /(\d+)/ ==> 12 '12a34' =~ /(\d+$)/ ==> 34 '12a34' =~ /(\d+ $)/x ==> 34
    (And, yes, MS command lines are "a bit" funky; yet another WinNoyance®.)
      perl -nle 'print q! ==> !, eval' perl -nle "print q! ==> !, eval"