On Thu, Mar 24, 2011 at 4:42 PM, Rob Dixon <rob.di...@gmx.com> wrote: > > On 24/03/2011 02:39, Peter Scott wrote: >> >> On Tue, 22 Mar 2011 13:41:59 -0700, Randal L. Schwartz wrote: >> >>> "Peter" == Peter Scott<pe...@psdt.com> writes: >>>> >>>> my $s = Streamer->new; >>>> my $app = sub { >>>> return sub { >>>> $s->open_fh; >>>> my $writer = shift->( >>>> [ 200, [ "Content-type" => "text/plain" ], $s ] ); >>>> }; >>>> }; >>> >>> Peter> As it stands, this doesn't make sense because nothing happens to >>> $writer; Peter> so why create it? >>> >>> I presume you're objecting to the explicit $writer. Certainly, the >>> value of $writer is also the return value of the inner subroutine, so >>> that *is* something that could be noted: >> >> Right, the superfluous naming of $writer leads to a lot of head- >> scratching. Best guess (if this is an accurate post of the code), that >> there was originally some debugging/logging code in there before a >> "return $writer" that got taken out. Although I supposed that the paste >> was incomplete. Either way, a giant red herring. > > For those that overlooked the post, the OP did attribute the source: > > On 18/03/2011 21:08, shawn wilson wrote: >> >> this is where this comes from: >> >> http://www.samuelkaufman.com/blog/2011/03/16/streaming-with-plack-take-2/ > > Which is take 2 of a blog entry by Samuel Kaufman. The original is here: > > <http://www.samuelkaufman.com/blog/2011/03/15/simple-streaming-test-server-with-plack/> > > which is pretty poor code (although the author does say "The previous > code sample sucked for numerous reasons") not least because of the > wrapping and lack of indents. But it does explain the purpose of $writer. >
humm, i missed that. the rewrite looked much better (i couldn't hardly stand to look at the original). i've actually learned a bunch of stuff i should have learned - the difference between $_ and @_ (which just seemed too obvious but maybe not :) ), closures (sorta), and and that cool shift (which i don't think i'll ever use because what it does isn't obvious). for the record, i've pretty much figured out how to do what i want. and *my* code is pretty simple. i create a data stream, keep it in a Gearman worker, print out the uuid which js can use when posting data in catalyst that catalyst can then use to call the worker stream and push the data to the client. this was way more difficult than it needed to be. i went through a bunch of interesting things to figure out what i needed to use (almost thought AnyEvent::Memcached or redis would work - and it might have with some limitations) but gearman seems to be the right man for the job :) anyone who wants the code can just ask, but then again, it's pretty straight forward once you know what to use (Catalyst, Plack::Builder, Data::UUID, JSON, Gearman - that's about it). and the documentation on all of these are pretty solid. And basic javascript. i might eventually write something up on this (since it took me so damn long - a bit over a week). ps - brandon, it was gmail's 'rich formatting' that was messing things up. it's good i've got that solved too, it seemed to be an irritation for uri et al. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/