[prev in list] [next in list] [prev in thread] [next in thread]
List: perl-beginners
Subject: Re: postderef with subroutines
From: Shawn H Corey <shawnhcorey () gmail ! com>
Date: 2017-05-11 11:52:14
Message-ID: 20170511075214.77e04ed0 () sage
[Download RAW message or body]
On Thu, 11 May 2017 13:10:03 +0200
Luca Ferrari <fluca1978@infinito.it> wrote:
> Hi all,
> according to the documentation the postderef for code blocks $ref->&*
> and $ref->() have different meanings
> <https://perldoc.perl.org/perlref.html#Postfix-Dereference-Syntax>
>
> While I can use the following:
>
> my $sub_ref = sub { say "Hello world: @_ !" };
> $sub_ref->( 'and the camels go' );
> &{ $sub_ref }( 'and the camels go' );
> $sub_ref->&* ;
>
> is it possible to pass argument to the function via postderef?
> Something like the not working code:
>
> $sub_ref->& ( 'and the camels go' );
>
> Any idea?
>
{
local @_ = ( 'and the camels go' );
$sub_ref->&*;
}
--
Don't stop where the ink does.
Shawn H Corey
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic