On Fri, Mar 18, 2011 at 7:02 PM, Shawn H Corey <shawnhco...@gmail.com>wrote:

> On 11-03-18 06:41 PM, shawn wilson wrote:
>
>> an argument to what sub?
>> (it's obvious that i've missed the boat on this concept)
>>
>
> my $writer = shift->(
>            [ 200, [ "Content-type" => "text/plain" ], $s ]
>        );
>
> The array @_ contains a sub ref as its first argument.  It is this sub that
> gets [ 200, [ "Content-type" => "text/plain" ], $s ] as its argument.
>
> It can be rewritten as:
>
> my sub_ref = shift @_;
> my $writer = $sub_ref->(
>            [ 200, [ "Content-type" => "text/plain" ], $s ]
>        );
>



oh, that's right, i forgot the general oo use of:
my( $self, @etc ) = @_;

that almost makes sense. the only part i'm still confused about is why he
defined $writer when you're not going to do anything with it? that just gets
returned, right?

so,
my( $self, @more ) = @_;
my @arr =  [ 200, [ "Content-type" => "text/plain" ], $s ];
$self->( @arr );

right? though, i've never actually used $self, i've always just defined it
because i knew that was the first thing that was passed to a sub in @_ (or,
at some point i knew this anyway :) )

maybe i should reread perlboot or perlsub, eh?

Reply via email to