Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

relative paths...

by zee12 (Initiate)
on Aug 13, 2014 at 09:14 UTC ( [id://1097235]=perlquestion: print w/replies, xml ) Need Help??

zee12 has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: relative paths...
by AppleFritter (Vicar) on Aug 13, 2014 at 09:28 UTC

    Without having looked at this in detail, I'd say you simply got your paths wrong. What does the directory hierarchy look like?

    You also don't need to shell out to copy files, BTW; there's modules like File::Copy and Win32 (which contains a CopyFile() function) for that purpose.

Re: relative paths...
by frozenwithjoy (Priest) on Aug 13, 2014 at 09:28 UTC

    Hi there. It's hard for me to tell exactly what you want with no code formatting, but let me recommend a few things.

    For converting absolute path to relative path, you should use something like abs2rel from File::Spec.

    For copying files, you should use copy/cp from File::Copy.

    Edit: Use of File::Spec or Path::Class will also make your paths much less prone to errors related to dealing with weird Windows backslashes.

Re: relative paths...
by aitap (Curate) on Aug 13, 2014 at 10:07 UTC
    Maybe your relative copy command fails because your current directory (use Cwd 'getcwd'; print getcwd(), "\n";) is different from what you expect?
Re: relative paths...
by Anonymous Monk on Aug 13, 2014 at 11:08 UTC
Re: relative paths...
by poj (Abbot) on Aug 13, 2014 at 12:21 UTC
    mkdir "$dir1\\BC_TESTCASES" will fail if $dir1 does not exist.
    Consider using File::Path, for example
    #!perl use strict; use File::Path 'make_path'; my $dir = 'xyz1'; make_path("$dir/BC_TESTCASES",{verbose=>1}) or warn "$!";
    poj

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2024-04-25 10:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found