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