#!/usr/bin/perl -w
use strict;
#------------
# This code is provided as is. There is no implied warrenty
# and it may do anything from nothing to causing the end
# of the world as we know it. I take no responsibilty for
# and such cause.
#
# It is under the Artistic license, but if you use it and
# fix it, I sure would appreciate the patch.
#
# Mik Firestone, Aug 1 2000
#
# mik@speed.stdio.com
#-------------
die "$0 <source> <target> ..." unless @ARGV > 1;
my %keyword = ();
my ( $source, @targets ) = @ARGV;
my $package = '';
#---
# Try to extract the keywords, precompile the regex and store
#---
open SRC, $source or die "Couldn't open $source : $!";
while( <SRC> ) {
$package = $1 if ( ! $package && /^package\s+(.+);/ );
next unless ( /^sub\s+(.+){\s*$/ );
my $name;
$name = $1;
next if ( substr($name,0,1) eq "_" );
$name =~ s/\s+$//;
$keyword{$name} = qr/([\w:{}]+)->$name/;
}
close SRC;
for my $file ( @targets ) {
my ( $line );
open FILE, $file or die "Couldn't open $file : $!";
LINE:
while( $line = <FILE> ) {
next LINE if ( $line =~ /^\s*#/ || $line =~ /^\s*$/ );
last LINE if $line =~ /__END__/;
for ( keys %keyword ) {
my $regex = $keyword{$_};
if ( $line =~ /$regex/ ) {
my $starts_at = $.;
my $lpack = $1 || '';
next LINE if ( $file eq $source ) && ( $line =~ /^
+sub/ );
next LINE if ( $line =~ /Usage/ );
next LINE if ( $lpack =~ /::/ && $lpack ne $packag
+e );
while( $line !~ /;/ && ! eof(FILE) ) {
$line .= <FILE>;
next LINE if $line =~ /^EOF/m;
}
$line =~ s/^\s*//;
printf "%s (%d) %s", uc $file, $starts_at, $line;
next LINE;
}
}
}
#LINE
close FILE;
}
In reply to list_call
by mikfire
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.