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

I've a module say ( Sample.pm and some subroutines inside that ). I want to find all the subroutines without actually opening the file. Also, i want to know where and all these subroutines used in other files.
  • Comment on Get List of modules/files where subroutine is used

Replies are listed 'Best First'.
Re: Get List of modules/files where subroutine is used
by tmharish (Friar) on Sep 02, 2009 at 11:07 UTC
    If you are on an Unix system you could use
    find . | xargs grep -n "Any string you want to find in files"
    That will give you output in the following format:
    ./folder/folder/file: line number: line containing "string"

    Of course in your case you would use the name of your subroutine as the string.





Re: Get List of modules/files where subroutine is used
by Anonymous Monk on Sep 02, 2009 at 10:46 UTC
    The way you've phrased the question it is an impossible task, but you should look into B::Xref
Re: Get List of modules/files where subroutine is used
by Anonymous Monk on Sep 02, 2009 at 10:16 UTC

    I could not get your question please clear me

Re: Get List of modules/files where subroutine is used
by Marshall (Canon) on Sep 02, 2009 at 17:23 UTC
    The english formulation of your question is hard to understand. You will have to "open" the file to look inside of it whether by text editor or other means! Usually the question is: what subroutines does this module expect can be called by others? Look at the beginning statements:
    our @EXPORT = qw(sub1 sub2); our @EXPORT_OK = qw(sub3);
    Those are the subroutines that the module author expects will be called by others, the "public interface". It is possible in Perl to call other subroutines with a fully qualified name (package::sub5), but that isn't "playing by the rules". Past this simple advice, I don't understand your question - please explain more...