Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

File Paths of Shared Packages

by mikasue (Friar)
on Oct 14, 2011 at 16:00 UTC ( #931546=perlquestion: print w/replies, xml ) Need Help??
mikasue has asked for the wisdom of the Perl Monks concerning the following question:

Good morning! I have a question about filenames and paths in Perl. I use the the FindBin command to find my current working directory but I need to go one level up out of my current directory. Is there a command that will allow me to do that and then set the lib "." to that level so that I can share a .pm file that's in that directory?

when I use FindBin i get /foo/poo/current/
but the file I want to use is in /foo/poo


Replies are listed 'Best First'.
Re: File Paths of Shared Packages
by AnomalousMonk (Canon) on Oct 14, 2011 at 16:23 UTC

    The synopsis of FindBin seems to give an example of what I understand you want to do.

    c:\@Work\Perl\junque>perl -wMstrict -le "use FindBin; use lib qq{$FindBin::Bin/../monks}; ;; print qq{$FindBin::Bin}; printf qq{'$_' } for @INC; " c:/@Work/Perl/junque 'c:/@Work/Perl/junque/../monks' 'C:/strawberry/5.12/perl/site/lib' 'C +:/strawberry/5.12/perl/vendor/lib' 'C:/strawberry/5.12/perl/lib' '.'


    I use the the FindBin command to find my current working directory ...

    Note that the current working directory and the directory in which the script resides (returned by FindBin) may only be the same by chance. For the reliable current working directory, use something like Cwd.

Re: File Paths of Shared Packages
by Eliya (Vicar) on Oct 14, 2011 at 16:40 UTC
    but I need to go one level up

    ".." goes one level up, so if $FindBin::Bin is "/foo/poo/current", the path "$FindBin::Bin/.." is interpreted by the OS as "/foo/poo".  So:

    use FindBin; use lib "$FindBin::Bin/..";

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://931546]
Approved by Eliya
[ambrus]: Corion: I think there's already some form of AnyEvent integration for Prima, according to https://metacpan. org/source/ KARASIK/Prima-1. 49/examples/
[ambrus]: Corion: even better, https://metacpan. org/pod/distributi on/Prima/pod/ Prima/faq.pod#How- do-I-use-Prima- with-AnyEvent
[ambrus]: a FAQ question
[ambrus]: ah, apparently that's the POE thing you were talking about
[ambrus]: Ok, but if there's a POE integration, then I again suggest that you consider using IO::Async::Loop:: Poe . I don't know if that will work.
[ambrus]: So that, or if you really want something agnostic to the loop, then use curl multi. Its interface is quite reasonable (unless you use an old version),

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2016-12-07 16:19 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (130 votes). Check out past polls.