[Perl] Pregunta #3: Forzando una cadena...

Alejandro G. Bedoya nezumi@prodigy.net.mx
Jue Mar 4 17:48:28 CST 2004


Saludos!!!

	Debido a que Mason es una bronca subir archivos con POST, tuve que 
hacer este programita que sirve de puente entre un mhtml y otro mhtml. 
Simple toma todos los campos de la forma, sube el archivo a un 
directorio temporal y llama a la siguiente mhtml metiendole todos los 
campos. Todo funciona bien, excepto en 
$INPUT{'SubirFile'}="$INPUT{'SubirFile'}" donde hay que forzar la 
cadena, cosa que descubrí despues de dos horas. La pregunta es porque 
solo funciona asi???


Atte.
Alejandro Encadenado...


#!/usr/bin/perl
use strict;
use CGI qw/:standard/;
use LWP::UserAgent;
use HTTP::Request::Common qw(POST);

my $DataForm = new CGI;
my %INPUT;
foreach my $Data ($DataForm->param) {
	$INPUT{$Data}=$DataForm->param($Data);
	$INPUT{$Data}=~ s/\r//g;
	}

open (MYFILE, ">/tmp/$INPUT{'SubirFile'}") or die $!;
	while (my $bytesread = read($INPUT{'SubirFile'},my $buffer, 1024)) {
		print MYFILE $buffer;
		}
	close (MYFILE);

$INPUT{'SubirFile'}="$INPUT{'SubirFile'}";  #AQUI ESTA LA BRONCA!!

my $userAgent = new LWP::UserAgent;
my $res = $userAgent->request(POST 
'http://localhost/administrador/cargaraceptar.html', \%INPUT);
my $returned_content = $res->content;
print "Content-type: text/html\n\n";
print $returned_content;







Más información sobre la lista de distribución Perl