http://qs321.pair.com?node_id=469476


in reply to Re: One line assigment statement with regex match
in thread One line assigment statement with regex match

Just because I really like grinder's Regexp::Assemble, and think such a cool module needs more exposure:

#!/usr/bin/perl -w use Regexp::Assemble; my $lineFromSomeTextFile = "your line right here\n"; my $ra = Regexp::Assemble->new->add( "something", "matching", "a", "line" ); print $ra->re . "\n"; # because the output is cool # and sometimes educational my($word) = $lineFromSomeTextFile =~ /($ra)/; print "found '$word' in: $lineFromSomeTextFile";

(For more on Regexp::Assemble see: Why machine-generated solutions will never cease to amaze me.)

HTH,

planetscape