2 ms·
So, it's basically a more hidden version of Regexp::Common? https://www.metacpan.org/module/Regexp::Common https://www.metacpan.org/module/Regexp::Common
by mhd 14y ago
So, it's basically a more hidden version of Regexp::Common?
https://www.metacpan.org/module/Regexp::Common https://www.metacpan.org/module/Regexp::Common
- prakashk 14y agoTemplate::Extract appears closer. https://metacpan.org/module/Template::Extract https://metacpan.org/module/Template::Extract Here's something equivalent to the example in the OP: #!/usr/bin/env perl use Template::Extract; use Data::Printer; sub extractValues { my ($document, $template, $opts) = @_; my $delims = $opts->{delimiters} || [ qw/ { } / ]; $document = lc $document if $opts->{lowercase}; if (exists $opts->{whitespace}) { my $ws = ' ' x $opts->{whitespace}; $document =~ s/\s+/$ws/g; } Template::Extract->new( { START_TAG => $delims->[0], END_TAG => $delims->[1] } ) ->extract( $template, $document ); } p extractValues('/2012/08/12/test.html', '/{year}/{month}/{day}/{title}.html'); p extractValues('John Doe <john@example.com> (http://example.com)', '{name} <{email}> ({url})'); p extractValues('from 4th October to 10th October', 'from `from` to `to`', { whitespace => 1, delimiters => ['`', '`'] }); Output: \ { day 12, month 08, title "test", year 2012 } \ { email "john@example.com", name "John Doe", url "http://example.com" } \ { from "4th October", to "10th October" }