| [reply] |
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:
- Enter the above on your command line and hit return. This starts the REP loop.
- Enter a perl statement (variable assignment, regex match statement, etc) and hit return. The result will be printed out.
- Repeat until you are bored
- 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
| [reply] [d/l] |
| [reply] |
| [reply] |
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®.) | [reply] [d/l] |