Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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?

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

Thanks!
MikaSue

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' '.'

    Update:

    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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://931546]
Approved by Eliya
help
Chatterbox?
[james28909]: ok maybe i need to ask this question in sopw and not CB but here goes
[james28909]: i am manually parsing html, and am trying to wrap my head around keeping up with tag counts
[james28909]: i can extract a certain tree manually by regexing the html file for a starting anchor, then i send the position of the match to a sub and then seek to that position in the file and keep up with div tags (for now)
[james28909]: how can i manage multiple tags? other than div?

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2017-04-25 03:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (448 votes). Check out past polls.