#!/usr/bin/perl -w use strict; use File::Find; my %known; find( sub{$known{$File::Find::name}=1 if /\.pm$/}, grep {$_ ne '.'} @INC ); my $pgm = shift or die; my @xref = `perl -MO=Xref,-r $pgm 2>/dev/null` or die; # Xref data looks like this: # test.pl (definitions) 5 main & GoodSub subdef # test.pl (main) 4 (lexical) $ y intro # test.pl (main) 4 main & BadSub subused my %h; foreach (@xref) { my ($file, $where, $line, $package, $sym, $name, $how) = split; next if $how eq 'subused' and $known{$file}; $h{$how}{$name}++; } foreach (sort keys %{$h{subused}}) { print "$_\n" unless $h{subdef}{$_}; }