bradcathey has asked for the wisdom of the Perl Monks concerning the following question:
Update: I posted too soon. I thought I had tried it all but it had nothing to do with my uploader, but in my MySQL. I added LINES TERMINATED BY '\r' to my statement. So, this worked:sub upload_file { $| = 1; #flush the output buffer my $sourcefile = shift; my ($buffer, $bytes); $sourcefile =~ /([\w .-]+)$/i; #strip off path stuff my $newfile = $1; $newfile =~ s/ //; open (OUTFILE, ">../$newfile") or die "Cannot open $newfile: $!"; # binmode(OUTFILE); while ($bytes = read($sourcefile, $buffer, 1024)) { print OUTFILE $buffer; } close($sourcefile) or die "Close:$!";; close(OUTFILE) or die "Close:$!";; chmod (0666, ">../$newfile"); return $newfile; }
Yikes, next time I'll RTFM more throughly before posting.;^&$stmt ="LOAD DATA LOCAL INFILE '../catalog.txt' INTO TABLE catalog LINES TERMINATED BY '\r'IGNORE 1 LINES";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: File upload losing newlines
by duff (Parson) on Apr 24, 2004 at 22:01 UTC | |
by bradcathey (Prior) on Apr 24, 2004 at 22:08 UTC |