[Purdue-pm] testing Perl 5.20
Bradley Andersen
bradley.d.andersen at gmail.com
Tue Jul 8 10:42:57 PDT 2014
Also, you can do cool things like this more tersely, but still readably:
my $blah //= ..
and it'll do the right thing
On Tue, Jul 8, 2014 at 1:41 PM, Bradley Andersen <
bradley.d.andersen at gmail.com> wrote:
> I would not use smartmatch operator if it can be avoided:
>
> http://blogs.perl.org/users/brian_d_foy/2011/07/rethinking-smart-matching.html
>
> I think grep does the same thing just as easily. Haven't checked speed
> though.
>
> /bda
>
>
>
> On Tue, Jul 8, 2014 at 1:38 PM, Mark Senn <mark at purdue.edu> wrote:
>
>> Thought you might be interested in a little
>> test file I put together to test that Perl 5.20
>> works...at least on a tiny bit of the stuff it
>> can do. Source code is the rest of this message. ---Mark Senn
>>
>> #!/usr/new/bin/perl
>>
>> use Modern::Perl;
>>
>> use experimental qw 'signatures smartmatch';
>>
>> use feature 'say';
>>
>> my $option = undef;
>> $option // say 'it was undef';
>>
>> $option = 0;
>> $option // say 'it was zero';
>>
>> sub a ($a) {
>> return $a;
>> }
>>
>> sub b($x,$y){
>> return $x+$y;
>> }
>>
>> sub c ($one, $two, $three)
>> {
>> return $one + $two + $three;
>> }
>>
>> my $x = a(2);
>> say $x;
>>
>> my $y = b(3,4);
>> say $y;
>>
>> say c(5,6,7);
>>
>> # I usually go without parentheses is sub calls.
>> say c 5, 6, 7;
>>
>> my @msee130 = ('Mark', 'Curtis', 'Rich', 'Mike', 'George', 'Joe');
>>
>> my $name = 'Fred';
>>
>> $name ~~ @msee130 or say "$name is not here";
>>
>> # I like to set off conditions at the beginning of a line with ( ... ).
>> ($name ~~ @msee130) or say "$name is not here";
>> _______________________________________________
>> Purdue-pm mailing list
>> Purdue-pm at pm.org
>> http://mail.pm.org/mailman/listinfo/purdue-pm
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/purdue-pm/attachments/20140708/918fbbbb/attachment.html>
More information about the Purdue-pm
mailing list