Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Something along the lines of ...
#!c:\Perl\bin\perl.exe # # This recursively searches .pl and .pm files for parenthesized functi +on calls. # $ARG[0] specifies the initial directory, # $ARG[1] specifies the function name, # for example: # c:\alpha\adx gettext # use File::Find; use Perl6::Slurp; use strict; use warnings; # Prowl the drive looking for files named .pl and .pm find({ wanted => \&FindFunctionCalls__, follow => 0 } ,$ARGV[0]); exit; sub FindFunctionCalls__ { # Don't trace me # $File::Find::dir is the current directory name, # $_ is the current filename within that directory # $File::Find::name is the complete pathname to the file. return unless (m/\.p(l|m)$/i); return if (/^(p|s)\./); my($s_Function)=($ARGV[1]); # Slurp my $s_Code=slurp $File::Find::name, {}; my $Count; # ... and search for "$s_Function" if (my $Count=($s_Code=~s/(?:^|\W)$s_Function\W/$&/g)) { # $s_ +Function occurred at least once # Remove the "use statement;" if any print "\nFound $Count in $File::Find::name\n"; # Balanced parentheses: my $np; # The initial balance parentheses expression with an embed +ded set is: # $np=qr/\( ([^()] | (??{$np})) *\)/x; # and quoted strings are "(?:[^"]|\")*" and '(?:[^']|\')* +' or ('|")(?:[^\1]|\\1)*\1 so $np=qr/ \( + # The opening "(" (( + # We'll want this hence the capturing () '(?:[^']|\')*?' + # a single quote string | "(?:[^"]|\")*?" + # a double quote string | [^()] + # not a parentheses | (??{$np}) )*) \) + # and the closing ")" /x; # Find the body of the function calls my($s_CompleteCall,$s_Before); while ($s_Code =~ m/(?:^|\W)($s_Function\s*$np)/gos) { # H +ave the entire call! # The complete call is $s_CompleteCall=$1; # and line number is print 1+(($s_Before=$`)=~ tr/\n/\n/).": $s_CompleteCal +l\n"; }; }; }; # __END__
perhaps?

In reply to Re: regexp for finding all function calls by Anonymous Monk
in thread regexp for finding all function calls by marksman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (7)
    As of 2014-12-18 01:07 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (41 votes), past polls