Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Re: Re: File::Copy - not working!

by helgi (Hermit)
on Jun 19, 2003 at 14:29 UTC ( [id://267202]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: File::Copy - not working!
in thread File::Copy - not working!

Since your incoming path seems to have Windows type backslashes as delimiters, I am using that below.

However, you should always use forward slashe, even under Windows, and get rid of them as soon as possible with something like: $path =~ s.\\.\/.g;

use warnings; use strict; use File::Basename; my $path_to_file = 'bla\bla\full\path\to\file.ext'; $path_to_file =~ s.\\.\/.g; my ($file,$path) = fileparse($path_to_file); print "$file is in $path\n";

For copying files using File::Copy, you do:

use File::Copy; copy $file,$newpath or die "Cannot copy $file to $newpath:$!\n";

--
Regards,
Helgi Briem
helgi DOT briem AT decode DOT is

Replies are listed 'Best First'.
Re: Re: Re: Re: File::Copy - not working!
by Anonymous Monk on Jun 20, 2003 at 10:37 UTC

    I tried the above and it did not work as expected, or shall I say at all.

    my $path_to_file is a file form field on a web page being displayed on a windows client, hence c:\...... do you think that is why it does not work? Is your $path_to_file on the same machine (in my case the linux web server)?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-03-19 03:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found