Sunday, September 20, 2009

perl 101: use FindBin

FindBin does one simple thing. It allows you to determine the full path of the Perl script you're running. This allows you to build relative paths to other parts of the filesystem that you might need.

More Perl articles:

2 comments:

Naveed said...

FindBin is pretty awesome. Thanks for sharing. Do you know if there is a python module that emulates FindBin?

raoul said...

Hi Naveed.

I would say you want to use os.path: http://docs.python.org/library/os.path.html

And the function you want to look at is os.path.abspath() in something like this:


os.path.abspath(os.path.dirname(sys.argv[0]))


Not sure if that is the best way to do it, but pretty straightforward.