On Sat, Jul 12, 2008 at 8:12 PM, Bob Clancy <[EMAIL PROTECTED]> wrote:

>
> [EMAIL PROTECTED] bclancy]$ showfunc showfunc
> showfunc ()
> {
>    set | perl -ne 'print if m#^'$*' \(\)# .. m#^}$#'
> }
> [EMAIL PROTECTED] bclancy]$
>
>    Until I saw this Perl pattern shown above, I used to use awk, and set a
> variable upon matching the first regex, and clearing a variable upon seeing
> the second regex, then printing lines when the variable was set.


That's the range operator. In scalar context, it evaluates as false until
the first operand is true, then true until the second operand is true, then
false again until the first operand is true, and so on. It's also called a
"flip flop operator" because of its behavior. You can use it just as well
without regexes, for instance "print if ($.==5 .. $.==20) to print lines
five through twenty of the input.

sherm--

_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to