in reply to Re (tilly) 2: ADD PATH TO @INC
in thread ADD PATH TO @INC

The apprentice takes a shot at expanding on D'oh!, just to make sure he's been paying attention...

Presumeably because push appends the element to the array and use lib prepends it.

The first would, I think, work when you've installed a module into your local area that is already available in the standard area. Why would you do this? Perhaps you need (want) to use (or experiment with) a later version. Perhaps you're not the admin and the real admin is busy, lazy, or charges you to install stuff. Perhaps the existing one is severely broken for some reason (e.g. a bad install). Perhaps you're trying to make sure your stuff is searched before anything else.

The latter is, I believe the preferred approach and should be used unless you know why it won't work for you.

--f

Replies are listed 'Best First'.
Re (tilly) 4: ADD PATH TO @INC
by tilly (Archbishop) on Jun 18, 2001 at 23:39 UTC
    That and (before damian1301 fixed the main issue) a question of timing. He didn't have a BEGIN block so his push happened at run-time while a use happens at compile time.

    A more subtle point. lib doesn't bother to put its unshift in a BEGIN block and it works just fine. If you were writing a module and you wanted to affect someone's @INC you could ignore the BEGIN and it works. Which works because runtime for a module compile time for anything that uses it.