in reply to Re: qr// and user provided regex patterns...
in thread qr// and user provided regex patterns...
if($options{r}){ #variable grab, add flags to pattern if they exist. my $pattern = $options{r}; $pattern .= 'g' if $options{g}; $pattern .= 'i' if $options{i}; $pattern .= 's' if $options{s}; #compile that stuff with eval my $compd_pattern = eval "qr($pattern)" or die $@; print "Please enter the text you wish to run the pattern on: "; my $text = <STDIN>; chomp $text; #do work and display if($text =~ $compd_pattern){ print $text; } else{ print "$pattern on \n\t{$text} Failed. "; } } #end R FLAG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: qr// and user provided regex patterns...
by JadeNB (Chaplain) on Aug 03, 2009 at 15:46 UTC | |
|
Re^3: qr// and user provided regex patterns...
by ikegami (Patriarch) on Aug 04, 2009 at 03:24 UTC | |
by JadeNB (Chaplain) on Aug 04, 2009 at 13:49 UTC | |
|
Re^3: qr// and user provided regex patterns...
by toolic (Bishop) on Aug 02, 2009 at 13:51 UTC | |
by misterMatt (Novice) on Aug 02, 2009 at 21:00 UTC |