Monday, May 24, 2010

How to get perl file soucre file name in perl program?

e.g. if my source file name is perl1.pl,I want my code to fetch this name with full path in some variable


THIS IS NOT FOR CGI PROGRAMMING SO DONT TELL ME TO USE ENVIRONMENT VARIABLES





THANKS

How to get perl file soucre file name in perl program?
I wont write out the script for you but the only idea that comes to mind is to use $$ (pid of this process) to find the line from a ps -aux command .corresponding to the running process THe last part of that line listing should give the name of the perl file running.
Reply:$0 (that's dollar zero) is supposed to give you that info, but it may vary slightly, depending on how exactly you call the program (and of course it depends on your OS)... Try it!


No comments:

Post a Comment