CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Is there any way to get file name which is including a perl module?

 



naven8
Novice

Apr 12, 2012, 9:35 AM

Post #1 of 6 (1886 views)
Is there any way to get file name which is including a perl module? Can't Post

Is there any way to get file name which is including a perl module?
Eg: I have two module Module1.pm,Module2.pm and one .pl file

Code
Module2.pm 
---------------
package Module2;
use Module1;
---------------

Script.pl
-----------------
#!/usr/bin/perl
use Module2;
-----------------


using %INC i can get the path to included file but i need the line number which is including the perl module.

In this case it is supposed to output following:

Module line file
-------------------------
Module2 2 script.pl
Module1 2 Module2.pm


Thanks in advance.


wickedxter
User

Apr 12, 2012, 5:01 PM

Post #2 of 6 (1867 views)
Re: [naven8] Is there any way to get file name which is including a perl module? [In reply to] Can't Post

I remember this question being asked on PerlMonks a while back and only remember as far as an answer was you would have to open the file and search it.


rovf
Veteran

Apr 13, 2012, 7:54 AM

Post #3 of 6 (1828 views)
Re: [naven8] Is there any way to get file name which is including a perl module? [In reply to] Can't Post

If it is OK for you to catch only the "reasonable" cases, and not every conceivable border case (such as, strings which look like "use" statements and appear in HERE documents), why don't you simply grep?

Ronald


naven8
Novice

Apr 13, 2012, 8:12 AM

Post #4 of 6 (1826 views)
Re: [rovf] Is there any way to get file name which is including a perl module? [In reply to] Can't Post

In my case multiple file are involved and they are spread across the directories.


rovf
Veteran

Apr 13, 2012, 9:35 AM

Post #5 of 6 (1819 views)
Re: [naven8] Is there any way to get file name which is including a perl module? [In reply to] Can't Post

Well, then just grep recursively in all those directories.....


FishMonger
Veteran / Moderator

Apr 13, 2012, 4:29 PM

Post #6 of 6 (1792 views)
Re: [naven8] Is there any way to get file name which is including a perl module? [In reply to] Can't Post

Why are you needing to do this? To me it seems pretty odd.

Maybe we could suggest a better way to accomplish your real goal, which prompted you to want to learn the line numbers of the module includes.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives