goatse

Why does the goatse operator work?

倖福魔咒の 提交于 2019-11-30 18:40:00
The difference between arrays and lists and between list and scalar context have been discussed in the Perl community quite a bit this last year (and every year, really). I have read over articles from chromatic and friedo , as well as this recommended monks node. I'm trying now to understand the goatse operator, documented in perlsecret . Here is some code I used to study it: # right side gets scalar context, so commas return rightmost item $string = qw(stuff junk things); say $string; # things # right side gets list context, so middle is list assigned in scalar context $string = () = qw

Why does the goatse operator work?

只谈情不闲聊 提交于 2019-11-30 02:56:58
问题 The difference between arrays and lists and between list and scalar context have been discussed in the Perl community quite a bit this last year (and every year, really). I have read over articles from chromatic and friedo, as well as this recommended monks node. I'm trying now to understand the goatse operator, documented in perlsecret. Here is some code I used to study it: # right side gets scalar context, so commas return rightmost item $string = qw(stuff junk things); say $string; #

Is the Perl Goatse 'Secret Operator' efficient?

两盒软妹~` 提交于 2019-11-28 22:50:36
The "goatse operator" or the =()= idiom in Perl causes an expression to be evaluated in list context. An example is: my $str = "5 and 4 and a 3 and 2 1 BLAST OFF!!!"; my $count =()= $str =~ /\d/g; # 5 matches... print "There are $count numbers in your countdown...\n\n"; As I interprete the use, this is what happens: $str =~ /\d/g matches all the digits. The g switch and list context produces a list of those matches. Let this be the "List Producer" example, and in Perl this could be many things. the =()= causes an assignment to an empty list, so all the actual matches are copied to an empty

Is the Perl Goatse 'Secret Operator' efficient?

孤街浪徒 提交于 2019-11-27 14:26:26
问题 The "goatse operator" or the =()= idiom in Perl causes an expression to be evaluated in list context. An example is: my $str = "5 and 4 and a 3 and 2 1 BLAST OFF!!!"; my $count =()= $str =~ /\d/g; # 5 matches... print "There are $count numbers in your countdown...\n\n"; As I interprete the use, this is what happens: $str =~ /\d/g matches all the digits. The g switch and list context produces a list of those matches. Let this be the "List Producer" example, and in Perl this could be many