On Fri, Mar 18, 2011 at 4:50 PM, Uri Guttman <u...@stemsystems.com> wrote:
> >>>>> "sw" == shawn wilson <ag4ve...@gmail.com> writes: > > sw> i ran across a peace of interesting code: > sw> my $writer = shift->( > sw> [ 200, [ "Content-type" => "text/plain" ], $s ] > sw> ); > > first off, there is no OO anywhere in that code. all it is is a > dereference of a code reference passed in to a sub. > > [snip] there is NO method there so it isn't a method call. if you have a code > reference (to a regular sub) in $code then you dereference it like this: > > $code->( args ... ) ; > > all the code does is skip assigning the code ref from @_ into $code. i > generally avoid that style of directly using the shift in an > expression. it is better style to store it in a variable so you have > some extra names to describe what that value is. > > > so, what your saying is: my $writer = sub { my $a = shift; return [ 200, [ "Content-type" => "text/plain" ], $s ]; } ???