Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

packages in code

by manishrathi (Beadle)
on Aug 08, 2009 at 19:56 UTC ( #787094=perlquestion: print w/replies, xml ) Need Help??

manishrathi has asked for the wisdom of the Perl Monks concerning the following question:

#!/migration/interwoven/teamsite/iw-perl/bin/iwperl use strict; use File::Find; use File::Basename; my $PATH = "/iwmnt/iwadmin/main/livesite/component/STAGING/"; my @comp = (); find( \&filterComponent, $PATH ); print "<substitution>\n"; foreach my $component (sort @comp){ (my $value = $component) =~ s#\.component##; my $opt = qq|<option label="$component" value="$value"/>|; print $opt."\n"; } print "</substitution>\n"; sub filterComponent { my @files = $File::Find::name; foreach my $file (@files){ next unless !($file =~ m#\/Interwoven\/#); next unless !($file =~ m#\/Debug\/#); next unless !($file =~ m#\/LiveSite\/#); next unless !($file =~ m#\/Examples\/#); next unless !($file =~ m#\/News\/#); next unless !($file =~ m#\/Web\/#); $file = basename($file); next unless ($file =~ m#\.component$#) ; push (@comp, $file); } }
In this code, from where the packages File::Find and File::Basename are imported ? How do I know what functions are available in these packages ?

Replies are listed 'Best First'.
Re: packages in code
by toolic (Bishop) on Aug 08, 2009 at 20:49 UTC
    from where the packages File::Find and File::Basename are imported ?
    If you are asking where the files are located on your system, perldoc will show you the full paths to those files:
    perldoc -l File/Find File/Basename
    The module files (*.pm) are under the directories named in the @INC special variable, which you can inspect with:
    perl -V

    Inside your code, you can also see where each use'd module comes from by inspecting the %INC special variable:

    use Data::Dumper; print Dumper(\%INC);

    Here is another good resource: Simple Module Tutorial

    next unless !($file =~ m#\/Interwoven\/#);
    This can be more simply written as:
    next if ($file =~ m#/Interwoven/#);

    There is no need to back-whack the slashes since you already used the alternate regex delimiters (#), and there's no need for the double-negative (unless !)

Re: packages in code
by Utilitarian (Vicar) on Aug 08, 2009 at 20:05 UTC
Re: packages in code
by dreadpiratepeter (Priest) on Aug 08, 2009 at 20:05 UTC
    The perldocs for the modules should say, otherwise you can look at the @export and @export_ok lists in the modules.


    -pete
    "Worry is like a rocking chair. It gives you something to do, but it doesn't get you anywhere."

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://787094]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2022-06-27 14:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (88 votes). Check out past polls.

    Notices?