ActiveState Perl 5.10 under Windows XP
ActiveState Perl 5.10 under Windows XP
am 01.12.2007 18:16:28 von dilbert1999
Hi all,
I have used Perl 5.8.8 for some time now, but I hope you don't mind if
I post my first ever perl 5.10 program and ask for comments: (I just
discovered that ActiveState have now released a Beta for Perl 5.10
under Windows XP)
C:\>perl -v
This is perl, v5.10.0 built for MSWin32-x86-multi-thread
(with 2 registered patches, see perl -V for more detail)
Copyright 1987-2007, Larry Wall
Binary build 1000 [283192] Beta provided by ActiveState http://www.ActiveState.com
Built Nov 22 2007 14:37:48
Here is my program :
use strict;
use warnings;
use feature ':5.10';
property($_) for (0, 1, 2, 3, 4, 'aad', 'abd', 'acd', 'add', 99, 100,
101, 3.1415);
sub property {
my $foo = shift;
printf 'my $foo = %-10s -- ', $foo;
given ($foo) {
when (1) { say "\$foo == 1" }
when ([2,3]) { say "\$foo == 2 || \$foo == 3" }
when (/^a[bc]d$/) { say "\$foo eq 'abd' || \$foo eq 'acd'" }
when ($_ > 100) { say "\$foo > 100" }
default { say "None of the above" }
}
}
Any comments ?
Re: ActiveState Perl 5.10 under Windows XP
am 01.12.2007 19:00:12 von Michele Dondi
On Sat, 1 Dec 2007 09:16:28 -0800 (PST), dilbert1999@gmail.com wrote:
>Here is my program :
>
>use strict;
>use warnings;
>use feature ':5.10';
>
>property($_) for (0, 1, 2, 3, 4, 'aad', 'abd', 'acd', 'add', 99, 100,
>101, 3.1415);
>
>sub property {
> my $foo = shift;
> printf 'my $foo = %-10s -- ', $foo;
> given ($foo) {
> when (1) { say "\$foo == 1" }
> when ([2,3]) { say "\$foo == 2 || \$foo == 3" }
> when (/^a[bc]d$/) { say "\$foo eq 'abd' || \$foo eq 'acd'" }
> when ($_ > 100) { say "\$foo > 100" }
> default { say "None of the above" }
> }
>}
>
>Any comments ?
It doesn't seem to have anything Windows or FWIW ActivePerl specific.
Other than that, cool.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
Re: ActiveState Perl 5.10 under Windows XP
am 01.12.2007 23:42:16 von Ben Morrow
Quoth dilbert1999@gmail.com:
> Hi all,
>
> I have used Perl 5.8.8 for some time now, but I hope you don't mind if
> I post my first ever perl 5.10 program and ask for comments: (I just
> discovered that ActiveState have now released a Beta for Perl 5.10
> under Windows XP)
>
> Here is my program :
>
> use strict;
> use warnings;
> use feature ':5.10';
>
> property($_) for (0, 1, 2, 3, 4, 'aad', 'abd', 'acd', 'add', 99, 100,
> 101, 3.1415);
>
> sub property {
> my $foo = shift;
For extra added 5.10-ness I might make that (totally untested)
property for (...);
sub property (_) {
my $foo = shift;
The new _ prototype character causes an argument to default to $_. :)
> printf 'my $foo = %-10s -- ', $foo;
> given ($foo) {
> when (1) { say "\$foo == 1" }
> when ([2,3]) { say "\$foo == 2 || \$foo == 3" }
> when (/^a[bc]d$/) { say "\$foo eq 'abd' || \$foo eq 'acd'" }
> when ($_ > 100) { say "\$foo > 100" }
> default { say "None of the above" }
Mmmm, /me likes. I can see given/when coming in very useful...
Ben
Re: ActiveState Perl 5.10 under Windows XP
am 02.12.2007 19:35:27 von dilbert1999
On Dec 1, 11:42 pm, Ben Morrow wrote:
> For extra added 5.10-ness I might make that (totally untested)
>
> property for (...);
>
> sub property (_) {
> my $foo = shift;
>
> The new _ prototype character causes an argument to default to $_. :)
I *love* the new _ prototype character and I've tested it with perl
5.10, works like a charm :))
(the only alteration I had to make was to move the line "property for
(...)" below the sub property(_) definition)
Re: ActiveState Perl 5.10 under Windows XP
am 02.12.2007 21:40:59 von Michele Dondi
On Sun, 2 Dec 2007 10:35:27 -0800 (PST), dilbert1999@gmail.com wrote:
>(the only alteration I had to make was to move the line "property for
>(...)" below the sub property(_) definition)
Of course...
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,