in reply to Detect line endings with CGI.pm upload
key1{tab}value1{\cM}key2{tab}value2{\cM}key3{tab}value3{\cM}key4{tab}value4
Test Perl script:
#!/usr/bin/perl -T
use CGI;
my $cgi = new CGI;
my $file = $cgi->upload('file');
print "Content-type: text/plain\n\n";
$file =~ s/(\x0d?\x0a|\x0d)/\n/smg;
while (my $line = <$file>)
{
chop $line;
($key, $value) = split(/\t/,$line);
print "key: $key\nvalue: $value\n";
}
Output:
key: key1
value: value1{\cM}key2
where {tab} is a tab character and {\cM} is a Control-M character.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Detect line endings with CGI.pm upload
by Anonymous Monk on Dec 27, 2008 at 01:12 UTC | |
by apu (Sexton) on Dec 27, 2008 at 04:51 UTC | |
by Anonymous Monk on Dec 27, 2008 at 08:08 UTC | |
by apu (Sexton) on Dec 27, 2008 at 08:39 UTC | |
by Anonymous Monk on Dec 28, 2008 at 00:11 UTC |