I've got the parsing of text down to a routine, but now I've got an html form which includes the option to upload an image.
I'm stymied on how to set up the parse routine in Perl to accommodate the uploaded image file along with my text info.
Any insight into this would be greatly appreciated.
This is the typical routine I use for parsing text:
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pairs (@pairs) {
local($name, $value) = split(/=/, $pairs);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.¦\n)*-->//g;
if ($Form{$name} && $value) {
$Form{$name} = "$Form{$name}, $value";
}
elsif ($value) {
push(@Field_Order,$name);
$Form{$name} = $value;
}
}
local($key,$sort_order,$sorted_field);
foreach $field (@Field_Order) {
push(@FormData, $Form{$field});
}
The deal is part of the data you are sending can be plain text and part of it is binary data. In that data there is a "separator" that defines the . . . multi-parts. :-) I dug around in cgi.pm for a while but got lost and had projects to complete, it's pretty heavy stuff.
Use the modules and save your brain for bigger tasks.