ActiveState Perl 5.10 under Windows XP

D

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 ?
 
M

Michele Dondi

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
 
B

Ben Morrow

Quoth (e-mail address removed):
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
 
D

dilbert1999

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top