in reply to regex for regex?

Perhaps B::Concise helps?

# in code.pl, for example if ( /test1/ ) { print; } my $re = qr/test2/; my @array = split( /test3/, $ARGV[0] );

perl -MO=Concise,-exec code.pl | grep "</>"

produces the output,

code.pl syntax OK 3 </> match(/"test1"/) s/RTIME 9 </> qr(/"test2"/) s/64 e </> pushre(/"test3"/) s/64

"</>" is the symbol for an OP with a regular expression. Someone smarter than I might tell you whether this will catch all the regex cases. If the regex is read in at runtime (with YAML or Storable, for example) I think B::Concise would tell you there was a regex involved, but not what it was.

--Solo

--
You said you wanted to be around when I made a mistake; well, this could be it, sweetheart.

Replies are listed 'Best First'.
Re^2: regex for regex?
by ikegami (Patriarch) on Jun 27, 2006 at 17:05 UTC

    I think B::Concise would tell you there was a regex involved, but not what it was.

    Yes. You're actually searching for the match operator (not regexp construction), so it doesn't matter how the regexp was constructed, as long as the match operator is in static code.

    >perl -MO=Concise -e "$re = eval 'qr/test3/'; '' =~ $re" | find "</>" -e syntax OK c </> match() vKS

    Keep in mind that '' =~ $re is short for '' =~ /$re/.