You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Mag Gam <ma...@gmail.com> on 2007/08/11 04:25:04 UTC
Correct way to upload a file
Hi All,
I have just started learning perl and mod_perl, and I must admit I am
enjoying it a lot!
I am tying to upload a file, so I can do some calculations to the file, my
question is what is the "correct" and most "efficient" way to upload the
file, and perform the calculations? Should I consider using the CGI module?
TIA
Re: Correct way to upload a file
Posted by Mag Gam <ma...@gmail.com>.
Thanks Fred.
The problem is, I don't have access to httpd.conf, therefore I can't run
scripts like that.
Is there an alternative?
TIA
On 8/13/07, Fred Moyer <fr...@redhotpenguin.com> wrote:
>
> [please cc the mod_perl list when responding]
>
> Mag Gam wrote:
> > Fred:
> >
> > Thanks. Looks like I may look into Mason for its simplification. I
> don't think I have a the patience or enthusiasm to learn the REquestReq
> feature of Mp2.
>
> It's not that hard, I would say it's no more complex than Mason (but
> there are varying schools of thought on that subject which I will not go
> into here). Here is a hello world handler to give you an example of how
> to get started.
>
> conf/httpd.conf
> --------------------------
> <Location />
> SetHandler perl-script # tells apache mod_perl handles the request
> PerlResponseHandler My::Hello # My::Hello::handler handles / requests
> </Location>
>
> lib/My/Hello.pm
> ------------------------
> package My::Hello;
>
> use strict;
> use warnings;
>
> use Apache2::RequestRec (); # for $r->content_type
> use Apache2::RequestIO (); # for $r->print
> use Apache2::Const -compile => qw( OK ); # for Apache2::Const::OK
>
> sub handler {
> my $r = shift; # <== here is where you get $r
>
> $r->content_type('text/plain'); # set the content type to text/plain
> $r->print("Hello world!"); # print the response to the client
>
> return Apache2::Const::OK; # return 200 OK
> }
>
> HTH
>
> > On 8/11/07, *Fred Moyer* <fred@redhotpenguin.com
> <ma...@redhotpenguin.com>> wrote:
> >
> > > I noticed I have to use Apache::Request and Apache::Cookie.
> > > In, http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html,
> > there is
> > > a
> > > $r which is request object. How do I create that? Is there an
> example
> > > anywhere I can follow?
> >
> > It sounds like you haven't created a mod_perl handler before,
> this page
> > should answer your questions.
> >
> > http://perl.apache.org/docs/2.0/user/intro/start_fast.html
> >
> > > On 8/10/07, Jonathan Vanasco <jvanasco@2xlp.com
> > <ma...@2xlp.com>> wrote:
> > >>
> > >>
> > >> On Aug 10, 2007, at 10:25 PM, Mag Gam wrote:
> > >>
> > >> > I have just started learning perl and mod_perl, and I must
> admit I
> > >> > am enjoying it a lot!
> > >> > I am tying to upload a file, so I can do some calculations
> to the
> > >> > file, my question is what is the "correct" and most
> > "efficient" way
> > >> > to upload the file, and perform the calculations? Should I
> > consider
> > >> > using the CGI module?
> > >>
> > >> libapreq
> > >> http://httpd.apache.org/apreq/
> > >>
> > >> CGI is a close second
> > >>
> > >
> >
> >
> >
>
>
>
>
Re: Correct way to upload a file
Posted by Fred Moyer <fr...@redhotpenguin.com>.
[please cc the mod_perl list when responding]
Mag Gam wrote:
> Fred:
>
> Thanks. Looks like I may look into Mason for its simplification. I
don't think I have a the patience or enthusiasm to learn the REquestReq
feature of Mp2.
It's not that hard, I would say it's no more complex than Mason (but
there are varying schools of thought on that subject which I will not go
into here). Here is a hello world handler to give you an example of how
to get started.
conf/httpd.conf
--------------------------
<Location />
SetHandler perl-script # tells apache mod_perl handles the request
PerlResponseHandler My::Hello # My::Hello::handler handles / requests
</Location>
lib/My/Hello.pm
------------------------
package My::Hello;
use strict;
use warnings;
use Apache2::RequestRec (); # for $r->content_type
use Apache2::RequestIO (); # for $r->print
use Apache2::Const -compile => qw( OK ); # for Apache2::Const::OK
sub handler {
my $r = shift; # <== here is where you get $r
$r->content_type('text/plain'); # set the content type to text/plain
$r->print("Hello world!"); # print the response to the client
return Apache2::Const::OK; # return 200 OK
}
HTH
> On 8/11/07, *Fred Moyer* <fred@redhotpenguin.com
<ma...@redhotpenguin.com>> wrote:
>
> > I noticed I have to use Apache::Request and Apache::Cookie.
> > In, http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html,
> there is
> > a
> > $r which is request object. How do I create that? Is there an
example
> > anywhere I can follow?
>
> It sounds like you haven't created a mod_perl handler before,
this page
> should answer your questions.
>
> http://perl.apache.org/docs/2.0/user/intro/start_fast.html
>
> > On 8/10/07, Jonathan Vanasco <jvanasco@2xlp.com
> <ma...@2xlp.com>> wrote:
> >>
> >>
> >> On Aug 10, 2007, at 10:25 PM, Mag Gam wrote:
> >>
> >> > I have just started learning perl and mod_perl, and I must
admit I
> >> > am enjoying it a lot!
> >> > I am tying to upload a file, so I can do some calculations
to the
> >> > file, my question is what is the "correct" and most
> "efficient" way
> >> > to upload the file, and perform the calculations? Should I
> consider
> >> > using the CGI module?
> >>
> >> libapreq
> >> http://httpd.apache.org/apreq/
> >>
> >> CGI is a close second
> >>
> >
>
>
>
Re: Correct way to upload a file
Posted by Fred Moyer <fr...@redhotpenguin.com>.
> I noticed I have to use Apache::Request and Apache::Cookie.
> In, http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html, there is
> a
> $r which is request object. How do I create that? Is there an example
> anywhere I can follow?
It sounds like you haven't created a mod_perl handler before, this page
should answer your questions.
http://perl.apache.org/docs/2.0/user/intro/start_fast.html
> On 8/10/07, Jonathan Vanasco <jv...@2xlp.com> wrote:
>>
>>
>> On Aug 10, 2007, at 10:25 PM, Mag Gam wrote:
>>
>> > I have just started learning perl and mod_perl, and I must admit I
>> > am enjoying it a lot!
>> > I am tying to upload a file, so I can do some calculations to the
>> > file, my question is what is the "correct" and most "efficient" way
>> > to upload the file, and perform the calculations? Should I consider
>> > using the CGI module?
>>
>> libapreq
>> http://httpd.apache.org/apreq/
>>
>> CGI is a close second
>>
>
Re: Correct way to upload a file
Posted by Mag Gam <ma...@gmail.com>.
I noticed I have to use Apache::Request and Apache::Cookie.
In, http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html, there is a
$r which is request object. How do I create that? Is there an example
anywhere I can follow?
On 8/10/07, Jonathan Vanasco <jv...@2xlp.com> wrote:
>
>
> On Aug 10, 2007, at 10:25 PM, Mag Gam wrote:
>
> > I have just started learning perl and mod_perl, and I must admit I
> > am enjoying it a lot!
> > I am tying to upload a file, so I can do some calculations to the
> > file, my question is what is the "correct" and most "efficient" way
> > to upload the file, and perform the calculations? Should I consider
> > using the CGI module?
>
> libapreq
> http://httpd.apache.org/apreq/
>
> CGI is a close second
>
Re: Correct way to upload a file
Posted by Jonathan Vanasco <jv...@2xlp.com>.
On Aug 10, 2007, at 10:25 PM, Mag Gam wrote:
> I have just started learning perl and mod_perl, and I must admit I
> am enjoying it a lot!
> I am tying to upload a file, so I can do some calculations to the
> file, my question is what is the "correct" and most "efficient" way
> to upload the file, and perform the calculations? Should I consider
> using the CGI module?
libapreq
http://httpd.apache.org/apreq/
CGI is a close second