For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > May 2004 > Determine symlink name in required module









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Determine symlink name in required module
vurt

2004-05-23, 2:41 pm

Hi,

I'm possibly not googling effectively, but I couldn't find an answer to
this.

Say I had a scriptanalogous something like:

require "/foo/bar/S01wibble.pm"

But the file is actually a symlink, ie:

/foo/bar/S01wibble.pm -> ../wibble.pm

How can I, in the required module, find the name of the symlink. I want to
be able to have behaviour analogous to rc scripts, and be able to have
different behaviour determined by the name I was called as. I hasten to
add I'm not actually trying to produce real rc scripts here...

Any tips would be welcome...
Ben Morrow

2004-05-24, 4:31 am


Quoth vurt <vurt@nospam.example.com>:
> Hi,
>
> I'm possibly not googling effectively, but I couldn't find an answer to
> this.
>
> Say I had a scriptanalogous something like:
>
> require "/foo/bar/S01wibble.pm"
>
> But the file is actually a symlink, ie:
>
> /foo/bar/S01wibble.pm -> ../wibble.pm
>
> How can I, in the required module, find the name of the symlink. I want to
> be able to have behaviour analogous to rc scripts, and be able to have
> different behaviour determined by the name I was called as. I hasten to
> add I'm not actually trying to produce real rc scripts here...


AFAIK the only thing you can do is grovel through values %INC looking
for a symlink to the right place. I suppose that if you remove or
replace it every time wibble.pm is loaded this would even be reliable.

Ben

--
Outside of a dog, a book is a man's best friend.
Inside of a dog, it's too dark to read.
ben@morrow.me.uk Groucho Marx
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com