CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Path ??

 



Fredrik
Deleted

Feb 27, 2001, 4:10 PM

Post #1 of 2 (149 views)
Path ?? Can't Post

Hi
I am working on an upload script
Uploading with Unix client works great but when it comes to win it just erase
my file


$file =~ s{.*/} {} if $file =~ m{^/};##Removes unix path

$file =~ s{.*\\} {} if $file =~ m{[A-Z]:\\};##Removes Win path


What it wrong with my Win path, it just empties my file to 0kb
Thanks /Fredrik



Rivotti
User

Mar 2, 2001, 4:59 AM

Post #2 of 2 (129 views)
Re: Path ?? [In reply to] Can't Post

Hi Fredrik,

Try this:

# Match the name file without the path.
# Regex: [^/:\\]* - Match anything that is not / or : or \, zero or more times.

$file =~ m!([^/:\\]*)$!;
my $short_name = $1; # put the filename in the string $short_name
my $size;

open (SAVE,">$short_name") || die $!; # now saves the files
while ($size = read($file,$data,1024)) {
print SAVE $data;
}
close SAVE;

Rivotti


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives