in reply to Re: Determining if you have balanced delimiters
in thread Determining if you have balanced delimiters

Darned clever. Too bad that:
balanced_delimiters('(\a)', '(', ')', "\\")
returns the wrong thing. Perhaps you meant this?
sub balanced_delimiters { local $_ = shift; my %sub; @sub{@_} = ("(",")"); my $LRS=join'|',map quotemeta,@_; $LRS .= "($LRS)"; {local $^W=0;s/($LRS|.)/$sub{$1}/gs; eval{m/$_/} } return !$@; }
A behaviour note, the escape sequence properly escapes the escape sequence.

Replies are listed 'Best First'.
Re: Re (tilly) 2 (fails): Determining if you have balanced delimiters
by I0 (Priest) on Dec 17, 2000 at 04:34 UTC
    Thank you for catching that, it was meant more like
    @sub{@_} = ("(",")"); my $LRS=join'|',map quotemeta,@_; {local $^W=0;s/($LRS.|.)/$sub{$1}/gs; eval{m/$_/}