<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package Modules::Lurker;

use strict;
use subs qw( );
use vars qw( $VERSION );
use File::Find qw( find );
use File::Spec qw( canonpath slitdir );

$VERSION = '0.01';

=head1 NAME

Sample - a sample script tracking all installed perl modules

=cut

sub parse {
    my @modules = ();
    my $current_path;

    sub { #set_path
	$current_path = shift;
    },
    # Let's say $curret_path = /home/kangu/
    # $_ -&gt; Boom.pm
    # $File::Find::name -&gt; /home/kangu/FireCracks/Boom.pm
    
    sub { #wanted
	return if !m/^\w+\.pm$/;
	my $mod = substr( File::Spec-&gt;canonpath($File::Find::name),
			  length($current_path) + 1 );
	$mod =~ s/\.pm$//;	
	my @modSlices = File::Spec-&gt;splitdir($mod);
	push @modules, !$#modSlices ? $modSlices[0] : join '::', @modSlices 
    },
    sub { #result
	@modules
   };
}

sub foreach_module {
    my ($exec, $set_path, $wanted, $result) = (shift, parse());

    for(@INC) {
	$set_path-&gt;($_);
	find($wanted, $_);
    }
    for($result-&gt;()) {
	$exec-&gt;($_);
    }
}

#eval {
    foreach_module( sub { print $_[0], "\n" } ) unless caller;
#} unless caller;


1;

__END__


=head1 SYNOPSIS 

foreach_module( sub { print $_[0], "\n" } ) unless caller;

=head1 DESCRIPTION

This script will traverse all directories defined in @INC fetching (guessing)
all possibly valid perl modules

=head1 README

=head1 PREREQUISITES

This script requires both the C&lt;File::Find&gt; and the C&lt;File::Spec&gt; modules

=head1 COREQUISITES


=pod OSNAMES

any

=pod SCRIPT CATEGORIES

CPAN/Administrative
Fun/Educational

=head1 AUTHOR

Issam Mourad &lt;&lt; &lt;mouradissam@gmail.org&gt; &gt;&gt;

The idea came from brian d foy

=head1 COPYRIGHT AND LICENSE

Copyright (c) 2007-2008, Issam Mourad, All Rights Reserved.

You may redistribute this under the same terms as Perl itself.

=cut



</pre></body></html>