Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > ActiveState Perl 5.10 under Windows XP

Reply
Thread Tools

ActiveState Perl 5.10 under Windows XP

 
 
dilbert1999@gmail.com
Guest
Posts: n/a
 
      12-01-2007
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 ?
 
Reply With Quote
 
 
 
 
Michele Dondi
Guest
Posts: n/a
 
      12-01-2007
On Sat, 1 Dec 2007 09:16:28 -0800 (PST), http://www.velocityreviews.com/forums/(E-Mail Removed) 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^<R<Y]*YB='
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
 
Reply With Quote
 
 
 
 
Ben Morrow
Guest
Posts: n/a
 
      12-01-2007

Quoth (E-Mail 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

 
Reply With Quote
 
dilbert1999@gmail.com
Guest
Posts: n/a
 
      12-02-2007
On Dec 1, 11:42 pm, Ben Morrow <(E-Mail Removed)> 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)

 
Reply With Quote
 
Michele Dondi
Guest
Posts: n/a
 
      12-02-2007
On Sun, 2 Dec 2007 10:35:27 -0800 (PST), (E-Mail Removed) 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^<R<Y]*YB='
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ActiveState Perl and MinGW [was: Perl 5.14 Windows Strawberry Perl 64 bits] Dilbert Perl Misc 0 11-10-2011 02:20 PM
Trouble with activestate perl for windows Caduceus Perl 1 09-02-2007 12:14 AM
Progress bar under Windows XP/Activestate Perl George Perl Misc 6 03-05-2006 05:13 PM
Activestate Perl and original Perl both on Mac OS Tiger Jake Wiley Perl Misc 14 06-16-2005 10:47 PM
Boxed Perl or ActiveState Perl? Vittorio Perl Misc 3 04-02-2004 05:48 PM



Advertisments