[27852] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 9216 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 3 18:05:57 2006

Date: Wed, 3 May 2006 15:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 3 May 2006     Volume: 10 Number: 9216

Today's topics:
        CGI Upload in forked child-thread <cbroschek@web.de>
    Re: CGI Upload in forked child-thread xhoster@gmail.com
    Re: FAQ 6.16 How do I efficiently match many regular ex <nilram@hotpop.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 03 May 2006 18:55:46 +0200
From: Carsten Broschek <cbroschek@web.de>
Subject: CGI Upload in forked child-thread
Message-Id: <4bs5kjF132munU1@individual.net>

Hi!

Is it possible to handle a file upload via CGI through a
background-thread in order to show process-info? If the server reads
complete request and stores data into temp-file, there would be no sense
to fork the process?

My idea
1) send multipart
2) create session, fork process
3) parent writes html reponse "upload in process", with some meta-refresh
4) child process reads file-handle and writes into file
5) upload state is stored into session


Thanks for comments.

Carsten


------------------------------

Date: 03 May 2006 17:56:06 GMT
From: xhoster@gmail.com
Subject: Re: CGI Upload in forked child-thread
Message-Id: <20060503141206.750$Az@newsreader.com>

Carsten Broschek <cbroschek@web.de> wrote:
> Hi!
>
> Is it possible to handle a file upload via CGI through a
> background-thread in order to show process-info? If the server reads
> complete request and stores data into temp-file, there would be no sense
> to fork the process?

You are right, I don't think there is much sense to fork a process, from
what you describe, anyway.

>
> My idea
> 1) send multipart
> 2) create session, fork process
> 3) parent writes html reponse "upload in process", with some meta-refresh

I don't think the client will honor a meta-refresh until the client is done
uploading the data.  You would probably have to have the *client* do the
"fork", which is a web-question (javascript?  using "_blank" as the
target?) not a perl one.  But if it does do a refresh into a cgi script, it
will cause the cgi-script to be run from scratch, not connect into the
previous spawned process of the earlier cgi invocation (well, you could
make that happen with a bit of work, but I don't see why you would need
to.)

> 4) child process reads file-handle and writes into file

Why not have one process read the file-handle, write into a file,
and send soothing messages to the client every 10K bytes of upload?
Use CGI's upload hook.  Of course, you would be at the mercy of your
web-servers buffering, and the clients incremental rendering.  But
it seems to work for me as long as I keep it simple.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


------------------------------

Date: 03 May 2006 15:26:05 -0500
From: Dale Henderson <nilram@hotpop.com>
Subject: Re: FAQ 6.16 How do I efficiently match many regular expressions at once?
Message-Id: <87ac9yrh2a.fsf@hotpop.com>

>>>>> "PF" == PerlFAQ Server <brian@stonehenge.com> writes:

PF> 6.16: How do I efficiently match many regular expressions at
PF> once?



PF>     ( contributed by brian d foy )

PF>     Avoid asking Perl to compile a regular expression every time
PF> you want to match it. In this example, perl must recompile the
PF> regular expression for every iteration of the foreach() loop since
PF> it has no way to know what $pattern will be.

PF>        @patterns = qw( foo bar baz );

PF>        LINE: while( <> )
PF>            {
PF>                    foreach $pattern ( @patterns )
PF>                            {
PF>                    print if /\b$pattern\b/i;
PF>                    next LINE;
PF>                            }
PF>                    }

Maybe I'm missing something, but this doesn't work. This code will
only print if the first pattern ("foo") matches. It completely ignores
the other patterns ("bar" and "baz"). 

The problem is the next line. I believe the inside of the loop should
be

        if (/\b$pattern\b/i){
            print;
            next LINE;
        }

or something similar.



------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 9216
***************************************


home help back first fref pref prev next nref lref last post