Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: CGI.pm and filehandle woes

by Sidhekin (Priest)
on Mar 27, 2007 at 19:12 UTC ( #606841=note: print w/replies, xml ) Need Help??


in reply to CGI.pm and filehandle woes

Anyone have any ideas on how to get this working?

As I said in the CB, I've worked around CGI's lightweight, crippled, overloaded file handle by making it inherit from the necessary classes. Assuming the classes are already loaded:

push @Fh::ISA, 'IO::Seekable' unless Fh->isa('IO::Seekable'); push @Fh::ISA, 'IO::Handle' unless Fh->isa('IO::Handle'); my $mimetype = File::MMagic->new->checktype_filehandle($filehandle);

As long as the $filehandle provided by CGI is a globref, blessed to the Fh class, and sysopened on the tempfile (as it is today), this works. Plenty hacky, but it works, at least for File::MMagic.

print "Just another Perl ${\(trickster and hacker)},"
The Sidhekin proves Sidhe did it!

Replies are listed 'Best First'.
Re^2: CGI.pm and filehandle woes
by Elijah (Hermit) on Mar 27, 2007 at 19:35 UTC
    Actually, it appears I owe you an apology, I was trying to use your method with File::MimeInfo::Magic which does a seek on the filehandle and it did not work, I installed File::MMagic and used your suggestion and it seems to work fine. The weird thing is that File::MMagic does a seek on the filehandle also.
Re^2: CGI.pm and filehandle woes
by Elijah (Hermit) on Mar 27, 2007 at 19:20 UTC
    Yeah from our conversation in CB, I have tried your suggestion and still get the error.

      Yeah from our conversation in CB, I have tried your suggestion and still get the error.

      Okay, I have installed your choice of module, and it works here. I'm beginning to suspect that you have not loaded the necessary modules. Try adding these lines before the mess above:

      require IO::Seekable; require IO::Handle;

      (If you still get the same error, something else is messing with inheritence.)

      print "Just another Perl ${\(trickster and hacker)},"
      The Sidhekin proves Sidhe did it!

Re^2: CGI.pm and filehandle woes
by markjugg (Curate) on Jun 22, 2008 at 12:46 UTC
    If this works well, have you considered getting patch into CGI.pm that does the same thing? Your solution seems like it would work to me.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://606841]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2018-09-20 07:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Eventually, "covfefe" will come to mean:













    Results (173 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!