Thank you!
jlc

-----Original Message-----
From: Paul Lalli [mailto:[EMAIL PROTECTED]
Sent: October-19-07 10:35 AM
To: beginners@perl.org
Subject: Re: Assemble file and directory name for copy

On Oct 19, 12:13 pm, [EMAIL PROTECTED] (Joseph L. Casale)
wrote:
> I am using File::Path and need to assemble a directory without a trailing 
> backslash, $Dir and a file, $File for copy.
> I can't get the syntax right to assemble the path inside the copy?
> I need something like:
> Copy ($FromDir . \  . $File, $ToDir . \ . $File)
>
> Any ideas?

You don't need to use backslashes.  Ever.  For some reason Windows
users always think they need to use backslashes for their pathnames in
their Perl scripts.  They don't.  It's only Windows' cmd.exe or
command.com shells that require the backslash notation.

Just use front slashes and you'll be a hell of a lot happier.

copy ($FromDir . '/' . $File, $ToDir . '/' . $File) or die "Could not
copy: $!";
or
copy ("$FromDir/$File", "$ToDir/$File") or die "Could not copy: $!":

If for some reason you insist on using backslashes, you have to quote
them first, as they're just characters, but you also have to escape
them, which means putting a second backslash in front of them:

copy ($FromDir . '\\' . $File, $ToDir . '\\' . $File) or die "Could
not copy: $!";
or
copy ("$FromDir\\$File", "$ToDir\\$File") or die "Could not copy: $!":

Paul Lalli


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to