in reply to Re^3: Best practice or cargo cult?
in thread Best practice or cargo cult?
In fact, here's the implementation. This works in perl5 going back to uh... early? Have your cake today. Not that I tested it. It's simple enough I just penned this and didn't bother running it.
use Regexp::SlashN; "A B C" =~ /(\N+)/; $1 eq "A B C" or die;
Regexp/SlashN.pm
package Regexp::SlashN; use overload; sub import { overload::constant qr => \ &convert } # A simple table of definitions my %syntax = ( '\\' => '\\', N => '[^\n]', ); sub convert { my ( $re ) = @_; $re =~ s/\\([\\N])/$syntax{$1}/g; return $re; }
⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Best practice or cargo cult?
by demerphq (Chancellor) on Jun 22, 2006 at 07:44 UTC | |
by diotalevi (Canon) on Jun 22, 2006 at 13:40 UTC |