On Feb 13, 2008 12:52 AM, Brent Clark <[EMAIL PROTECTED]> wrote: > Chas. Owens wrote: > > > The XMLin method takes a string, file, or file handle as its argument. > > Just pass $upload_filehandle to it: > > > > my $ref = $xs->XMLin($cgi->upload("filename")); > > print $xs->XMLout($ref); > > Hi > > Thanks for replying. To be honest, I did try that, but then i was getting > this message. > > read on filehandle failed: Undefined subroutine Fh::read > at /usr/lib/perl5/XML/LibXML.pm line 531 at > /usr/lib/perl5/XML/LibXML/SAX.pm line 64 > at /usr/share/perl5/XML/Simple.pm line 366 >
I can't say for sure, but my guess is that this has to do with $cgi->upload returning an array in list context. Try something like my $ref = $xs->XMLin(scalar($cgi->upload("filename"))); # or my $ref = $xs->XMLin(($cgi->upload("filename"))[0]); > I dont mind creating the tmp file, I just think its a very crappy way of > doing things. > Perhaps we could be more help if you told us why you think it's "crappy." Is this a security issue? A system resource issue? Also, we need to know in what way the standard idiom of passing an upload_hook to CGI->new and toggling the $use_tempfile flag, as described in the file upload section of the CGI.pm documentation fails to meet your needs in this specific case. It seems to me that something like the following would do: my $xml; $cgi = CGI->new(\&upload_hook, \$xml , 0); sub upload_hook { my ($filename, $buffer, $bytes_read, $xml) = @_; $$xml .= $buffer; } my $ref = $xs->XMLin($xml); HTH, -- jay -------------------------------------------------- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.downloadsquad.com http://www.engatiki.org values of β will give rise to dom!