Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: XP and slashes?

by moritz (Cardinal)
on Apr 04, 2009 at 20:38 UTC ( [id://755478]=note: print w/replies, xml ) Need Help??


in reply to XP and slashes?

If you open a file from within perl, you can use the forward slashes, even on window. See the section "Files and Filesystems" in perlport.

So your problem must be something else.

Replies are listed 'Best First'.
Re^2: XP and slashes?
by hsmyers (Canon) on Apr 05, 2009 at 00:12 UTC
    Yes, the problem is something else... basically it is how to find a file relative to a .pm file when the .pm file loads and not relative to the file using the .pm file. The XP stuff was a red herring. Work ensues on the other.

    --hsm

    "Never try to teach a pig to sing...it wastes your time and it annoys the pig."

      Yes, the problem is something else... basically it is how to find a file relative to a .pm file

      From within the module,

      use Cwd qw( realpath ); use File::Basename qw( dirname ); use File::Spec::Functions qw( catdir ); my $module_dir_qfn = dirname(realpath(__FILE__)); my $db_dir_qfn = catdir($module_dir_qfn, 'db');

      Update: Updated to use OP's dir name.

        Hmmm... I didn't try that... what worked for me is the somewhat more cumbersome:
        my $db_path = ''; for (keys %INC) { if (/parse/i) { $db_path = $INC{$_}; $db_path =~ s/parse\.pm$/db\//i; last; } }
        Since the .pm requires the other file it can be found in the %INC hash and the rest follows from that. I'll take a look at your approach since it is more concise than mine.

        --hsm

        "Never try to teach a pig to sing...it wastes your time and it annoys the pig."

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://755478]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-04-16 11:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found