I installed Perl 5.11 in my home directory, so I could kick the tires a little bit.
wget http://search.cpan.org/CPAN/authors/id/J/JE/JESSE/perl-5.11.0.tar.bz2
sha1sum perl-5.11.0.tar.bz2
# 0d436577386c668161e3dad385d233c383bf4c9d perl-5.11.0.tar.bz2
tar xjf perl-5.11.0.tar.bz2
cd perl-5.11.0
perl Configure -de -Dusedevel -Dprefix=${HOME}/Perl5.11 -Dusethreads
make
make test
make install
I noticed it now has implicit strictures.
$ perl5.11 -le '$foo = "bar"; print $foo'
bar
$ perl5.11 -M5.11.0 -le '$foo = "bar"; print $foo'
Global symbol "$foo" requires explicit package name at -e line 1.
Global symbol "$foo" requires explicit package name at -e line 1.
Execution of -e aborted due to compilation errors.
So if we "use 5.11.0" we get strictures too (I don't know why we get the message twice).
One of the few times we don't want strictures is when we're doing one-liners. We can't use -M5.11.0 to turn on the new features if it also turns on strictures, but that's what we have big -E for.
$ perl5.11 -e '$foo = "bar"; say $foo'
Can't locate object method "say" via package "bar" (perhaps you forgot to load "bar"?) at -e line 1.
$ perl5.11 -Mfeature=say -e '$foo = "bar"; say $foo'
bar
$ perl5.11 -E '$foo = "bar"; say $foo'
bar
Some years ago, I wrote Compress::DAWG, a Perl module for compressing and decompressing lists of words. But I never uploaded it to CPAN, because I didn't think anyone else would find it useful. Slightly more recently, I redid it in Python and rewrote the explanation from the POD on a web page. I've just discovered that neither of these links appears to be indexed by any search engines or, at least, if they are, they aren't ranked high enough to actually show up in any searches. I wonder if I should upload it to CPAN just for posterity? On the one hand, I really doubt anyone else will be interested, but on the other, I hate to see it just disappear.
So the British government has officially apologized for their treatment of Alan Turing and some people seem to think this is too late to do any good. I couldn't disagree more. I think apologies of this sort matter a great deal. Sure, Turing is dead. We can't undo what happened. But there's no benefit in ignoring it. When our governments can be open and honest about things--- including when they screwed up--- I think we're all better off. I'm not British, but if I were, I'd be proud of my government right now. This is not some casual remark. It's an official statement from the Prime Minister. And that statement says everything beautifully while not pulling any punches. We're sorry.
Sorry, this entry doesn't have anything to do with Perl, but Turing is one of the most important figures in the history of computing, so I'm using my "computer blog" to talk about it.

I'm still on the fence about whether I like constructors that throw exceptions. In object-oriented Perl, we seem to have a number of paradigms. Some constructors don't do any error checking, so we always get an object back.
$ perl -MData::Dumper -MImage::Magick -E '$i=Image::Magick->new; say Dumper($i)'
$VAR1 = bless( [], 'Image::Magick' );
$ perl -MData::Dumper -MImage::Magick -E '$i=Image::Magick->new(no_such_attribute
=> "what garbage"); say Dumper($i)'
$VAR1 = bless( [], 'Image::Magick' );
Others return undef on failure and set errno.
$ perl -MIO::File -E '$iof = IO::File->new("rofile", "w") or die $!; say "DONE"'
Permission denied at -e line 1.
I'm most comfortable with these right now, but if you fail to check that return value, they lie to you.
$ perl -MIO::File -E '$iof = IO::File->new("rofile", "w"); say "DONE"'
DONE
Still others return undef on failure, but set some other value instead of errno.
$ perl -MText::CSV -e '$i = Text::CSV->new({binar => 1}) or die scalar
Text::CSV::error_diag'
Unknown attribute 'binar' at -e line 1.
In addition to lying to you if you forget to check the return value, these lie to you if you forget and use errno
$ perl -MText::CSV -e '$i = Text::CSV->new({binar => 1}) or die $!'
No such file or directory at -e line 1.
Gah! That wasn't the problem at all. This particular one also gives you a bit of a mess if you use it as documented
$ perl -MText::CSV -e '$i = Text::CSV->new({binar => 1}) or die
Text::CSV::error_diag'
1000Unknown attribute 'binar'0 at -e line 1.
Since die called it in list context, it gives back more than just the error string.
Finally, the Modern Perl modules throw an exception instead of returning undef. Thus we don't have to check the return value at all.
$ perl -MDateTime -E '$d = DateTime->new; say "DONE"'
Mandatory parameter 'year' missing in call to DateTime::new
at /usr/local/lib/perl/5.10.0/DateTime.pm line 171
DateTime::new(undef) called at -e line 1
However, we now need to eval the call to the constructor, if we want to do anything other than exit.
$ perl -MDateTime -E 'my $d = eval {DateTime->new} or warn $@; say "DONE"'
Mandatory parameter 'year' missing in call to DateTime::new
at /usr/local/lib/perl/5.10.0/DateTime.pm line 171
DateTime::new(undef) called at -e line 1
eval {...} called at -e line 1
DONE
As I said, I'm most comfortable with ones like IO::File now, but DateTime is one of my favorite modules, so I guess exceptions are starting to rub off on me. However, since I use all of the above modules, I'm going to need to be aware of all of the paradigms for some time.
-- oylenshpeegul
So, I guess the little man icons are working now. Here's mine

I didn't think about how to add it to a vox profile or anything. Maybe I'll just have to remember to add it to posts. Hm, but then it will change. I sort of want a static version for individual posts and one that changes for my vox profile. Or something.
It's easy enough to point to the static images, if you know what level you are




I wasn't able to figure out how to use an img tag on my vox profile.
I couldn't figure out how to leave a comment on tokuhirom's blog (maybe I need to learn Japanese...or maybe I just need an account on Hatena), so I'll just make a comment here.
In Perl 5.10, we have a new keyword state for this (we also have our own say), so the following would also work.
use 5.010;
use strict;
use warnings;
sub counter {
state $i;
return $i++;
}
say counter() for 1..5;
No need for an enclosing block or risky behavior.
Okay, to heck with the release candidates...Perl 5.10.1 has been released (today is my birthday...what an ossum birthday present)!
wget http://www.cpan.org/modules/by-authors/id/D/DA/DAPM/perl-5.10.1.tar.bz2
tar xjf perl-5.10.1.tar.bz2
cd perl-5.10.1
perl Configure -de -Dprefix=${HOME}/local -Dusethreads
make
make test
make install
Now let's see if I can get all the Modern Perl modules I want to use installed from source. I've been using the Perl 5.10.0 that's in /usr/bin/perl with a mixture of modules loaded with apt-get and cpanp. I don't want to wait for Ubuntu to upgrade to Perl 5.10.1, so I'll have to do without the apt-get option. It's probably just as well. In the long run, that mixed configuration was probably trouble anyway.
I built Perl 5.10.1 RC2 the other day, but I forgot to enable threads. So I went back to my build directory and re-ran
perl Configure -de -Dprefix=${HOME}/local -Dusethreads
make
make test
make install
That appeared to work fine--- it recompiled a bunch of stuff and there were no complaints--- but the resulting executable was not thread-aware.
$ $HOME/local/bin/perl -Mthreads -e 1
This Perl not built to support threads
Compilation failed in require.
BEGIN failed--compilation aborted.
So I started over in a fresh directory
wget http://search.cpan.org/CPAN/authors/id/D/DA/DAPM/perl-5.10.1-RC2.tar.gz
tar xzf perl-5.10.1-RC2.tar.gz
cd perl-5.10.1-RC2
perl Configure -de -Dprefix=${HOME}/local -Dusethreads
make
make test
make install
and then all was well.
$ $HOME/local/bin/perl -Mthreads -e 1
$
Lesson learned: don't try to reconfigure...just redo it.
I've been using Perl for a while now and I've gotten a lot out of it. Personal things. Professional things. But by far the most tangible thing I've gotten out of Perl is my Tick DVD. Here it is, literally in my hands.
How much more tangible can you get? I loved the Tick, but the show was cancelled before it even finished its first season. There were completed episodes that were never shown. So when they announced they were going to make a Tick DVD with all the episodes on it, I was thrilled!
What's that have to do with Perl you ask? See, there was this online poll to determine what shows would be made into DVD's next. I'm not saying I know how the Tick "quickly became one of the first finalists", but I did stumble upon this old Perl script recently.
#!/usr/bin/perl
use strict;
use warnings;
use HTTP::Cookies;
use HTTP::Request::Common;
use LWP::UserAgent;
use constant INDICES => qw(two three four five);
use constant MAXTIMES => 100;
use constant PREFERENCES => ("A full season release of a series",
"Prefer all of the above equally");
use constant SHOWS => ("Barney Miller",
"Benson",
"Bewitched",
"Dilbert",
"Father Knows Best",
"The Flying Nun",
"I Dream of Jeannie",
"Just Shoot Me",
"Mary Hartman",
"Maude",
"News Radio",
"One Day at a Time",
"Soap");
use constant URL => 'http://www.sonypictures.com/cthe/tv/poll/tvpoll.php';
my $numtimes = shift || int(rand(MAXTIMES));
die "\n\tUsage: $0 [numtimes]\n\n" if $numtimes =~ /\D/;
chomp(my @agents = <DATA> );
my %parameters = (one => 'The Tick',
action => 'submit',
Submit => 'Submit your vote!',
Referer => URL,
);
for my $i (1..$numtimes) {
my @shows = SHOWS;
$parameters{$_} = splice @shows, int(rand(@shows)), 1 foreach INDICES;
my $agent = $agents[int(rand(@agents))];
$parameters{prefer} = (PREFERENCES)[int(rand(PREFERENCES))];
my $ua = LWP::UserAgent->new(agent => $agent);
$ua->cookie_jar(HTTP::Cookies->new);
GET URL;
my $req = POST URL, [ %parameters ];
if ( $ua->request($req)->as_string =~ /Thank you!/ ) {
print scalar localtime,
" $i @parameters{(INDICES)} # $parameters{prefer} # $agent\n";
} else {
print "Oops!\n";
}
}
__END__
amaya/6.2 libwww/5.3.1
DocZilla/1.0 (Windows; U; WinNT4.0; en-US; rv:1.0.0) Gecko/20020804
ICE Browser/5.05 (Java 1.4.0; Windows 2000 5.0 x86)
Links (0.95; Unix)
Lynx/2.8.4dev.11 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.6
Lynx/2.8.4rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.6c
Mozilla/1.10 [en] (Compatible; RISC OS 3.70; Oregano 1.10)
Mozilla/1.22 (compatible; MSIE 5.01; PalmOS 3.0) EudoraWeb 2.1
Mozilla/2.0 (compatible; MSIE 3.02; Windows CE)
Mozilla/2.0 (compatible; MSIE 3.02; Windows CE; 240x320)
Mozilla/2.02 [fr] (WinNT; I)
Mozilla/3.0 (Windows 2000; U) Opera 6.0 [en]
Mozilla/3.0 (compatible; AvantGo 3.2)
Mozilla/3.01-C-SYMPA (Macintosh; I; PPC)
Mozilla/4.0 (compatible; MSIE 4.01; Mac_68000)
Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)
Mozilla/4.0 (compatible; MSIE 4.0; Windows 95)
Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
Mozilla/4.0 (compatible; MSIE 5.01; Windows NT)
Mozilla/4.0 (compatible; MSIE 5.0; Mac_PowerPC)
Mozilla/4.0 (compatible; MSIE 5.0; Mac_PowerPC) Opera 5.0 [en]
Mozilla/4.0 (compatible; MSIE 5.0; Mac_PowerPC; e504460WanadooNL)
Mozilla/4.0 (compatible; MSIE 5.0; Windows 2000) Opera 6.0 [en]
Mozilla/4.0 (compatible; MSIE 5.0; Windows 95) Opera 6.01 [en]
Mozilla/4.0 (compatible; MSIE 5.0; Windows 98) Opera 6.0 _ [en]
Mozilla/4.0 (compatible; MSIE 5.0; Windows ME) Opera 6.0 _ [en]
Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)
Mozilla/4.0 (compatible; MSIE 5.13; Mac_PowerPC)
Mozilla/4.0 (compatible; MSIE 5.5; Windows 95)
Mozilla/4.0 (compatible; MSIE 5.5; Windows 95; BCD2000)
Mozilla/4.0 (compatible; MSIE 5.5; Windows 98; Win 9x 4.90)
Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)
Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0; .NET CLR 1.0.2914)
Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)
Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0; T312461)
Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows NT 4.0) Opera 7.0 [en]
Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)
Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90)
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461)
Mozilla/4.0 (compatible; MSIE 6.0; Windows XP; DigExt)
Mozilla/4.08 [en] (WinNT; I ;Nav)
Mozilla/4.5 (compatible; iCab 2.7.1; Macintosh; I; PPC)
Mozilla/4.7 [en] (X11; U; SunOS 5.6 sun4u)
Mozilla/4.74 [en] (X11; I; ProxiNet)
Mozilla/4.74 [en]C-NECCK (Win98; U)
Mozilla/4.75 [en](X11;U;Linux2.2.16-22 i586)
Mozilla/4.76 (Windows 2000; U) Opera 6.0 [en]
Mozilla/4.76 [en] (WinNT; U)
Mozilla/4.77 [en] (Win95; U)
Mozilla/4.7C-SGI [en] (X11; I; IRIX 6.5 IP32)
Mozilla/5.0 (Linux 2.4.2-2 i586; U) Opera 5.0 [en]
Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US; rv:0.9.4) Gecko/20011022 Netscape6/6.2
Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US; rv:0.9.6) Gecko/20011120
Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US; rv:1.0.1) Gecko/20021104 Chimera/0.6
Mozilla/5.0 (Macintosh; U; PPC; en-US; rv:0.9.5) Gecko/20011011" "en-us
Mozilla/5.0 (Macintosh; U; PPC; ja-JP; rv:0.9.2) Gecko/20010726 Netscape6/6.1
Mozilla/5.0 (Windows 2000; U) Opera 6.0 [en]
Mozilla/5.0 (Windows XP; U) Opera 6.0 [en]
Mozilla/5.0 (Windows; U; Win 9x 4.90; ja-JP; rv:0.9.2) Gecko/20010726 Netscape6/6.1
Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.2.1) Gecko/20021130
Mozilla/5.0 (Windows; U; Win98; ja-JP; rv:0.9.4) Gecko/20011019 Netscape6/6.2
Mozilla/5.0 (Windows; U; WinNT4.0; en-CA; rv:0.9.4) Gecko/20011128 Netscape6/6.2.1
Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.2) Gecko/20021126
Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.2b) Gecko/20021001 Phoenix/0.2
Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.2b) Gecko/20021016 K-Meleon 0.7
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4) Gecko/20011128 Netscape6/6.2.1
Mozilla/5.0 (Windows; U; Windows NT 5.0; ja-JP; rv:0.9.4) Gecko/20011019 Netscape6/6.2
Mozilla/5.0 (Windows; U; Windows NT 5.0; ja-JP; rv:0.9.6) Gecko/20011120
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2a) Gecko/20020910
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2b) Gecko/20020923 Phoenix/0.1
Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:0.9.6) Gecko/20011121
Mozilla/5.0 (X11; U; Linux 2.4.3-20mdk i586; en-US; rv:0.9.1) Gecko/20010611
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.4.1) Gecko/20020314 Netscape6/6.2.2
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3a) Gecko/20021207 Phoenix/0.5
Mozilla/5.0 (X11; U; Linux i686; ja-JP; rv:0.9.2) Gecko/20010726 Netscape6/6.1
Mozilla/5.0 (X11; U; Linux i686; ja-JP; rv:0.9.6) Gecko/20011120
Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)
Mozilla/5.0 Galeon/1.2.0 (X11; Linux i686; U;) Gecko/20020326
Opera/6.0 (Windows 2000; U) [en]
UPG1 UP/4.0 (compatible;Blazer 1.0)
Spoon!
I'm still digesting all of the Modern Perl things I learned about at YAPC. The thing I've had the most trouble with is Moose objects always using Carp 'confess', especially in the constructors. Is that what Modern Perl means? If I use your module and ask you for a new object, you're going to kill my program if there's a problem? I always thought that returning undef was the polite thing to do. Thus if I have an object Point as in the Moose man page, and I want to go through a whole list of points, I would expect to write something like
foreach my $aref (@points) {
my $p = Point->new(x => $aref->[0], y => $aref->[1])
or warn "skipping bad point @$aref\n" and next;
do_something($p);
}
But that doesn't work for Moose objects; they want to exit the program and spew the whole stack trace at the first sign of trouble. If I have a whole list of points and I just want to skip the bad ones, I have to eval the construction of the object. Since eval returns undef on failure, I don't really have to change very much, if I don't want to.
foreach my $aref (@points) {
my $p = eval { Point->new(x => $aref->[0], y => $aref->[1]) }
or warn "skipping bad point @$aref\n" and next;
do_something($p);
}
That's not so bad, I guess. I'm just going to have to get used to it.
Python folks have exceptions and some of the worst Python code I've seen is at least partly due to overuse of try/except blocks. Moreover, the bare except is probably the second most common abuse I see in Python code (second only to "from Package import *"). If Modern Perl ends up with evals all over the place, I don't think I'm going to like it. But we'll see.
Also in Python, string exceptions have been deprecated in favor of exception objects. If the same is true in Modern Perl, I guess I need to have a look at the Exception::Class module. At first glance, it seems a whole lot more involved than just taking a peek at $@, but again, it's probably just something I have to get used to. I made the switch in Python, there's no reason I can't do so in Perl as well.
Using autodie is another thing that's going to take getting used to. It's sort of like constructors that die (or croak or confess). I'm completely comfortable writing
open my $fh, '<', $file or die "$file: $!\n";
It's going to take me a long time before I can look at
open my $fh, '<', $file;
with anything but horror. And, just as above, occasionally I want to write
open my $fh, '<', $file
or warn "bad file '$file': $!\n" and next;
and go on to the next file without dying.
At chromatic's talk at YAPC::NA this year, he put it as "autodie is a replacement for Fatal." Well, I don't use Fatal, so why do I need a replacement for it? Later in the conference, I was fortunate to run into chromatic and I asked him why I would want to use autodie; in particular, what if I don't want to die? He said, "you can turn it off with no autodie".
Of course! This is the main advantage of autodie over Fatal; it's lexically scoped! I can just say
no autodie 'open';
open my $fh, '<', $file
or warn "$file: $!\n" and next;
and turn off the autodie feature just for that block and just for open. The rest of the program still has autodie enabled and even in that block, everything other than open is still "autodied." It's analogous to the warnings pragma being better than the -w flag.
So chromatic probably thinks I'm a moron now, but it was a complete epiphany for me. I went from not liking autodie to loving it instantly. It's still going to take me a while before I can look upon a bare open without feeling queasy, but I think it will save me a lot of trouble. If I had a nickel for every time I've said, "check the return value on that open," I could make Ian Hague look tight. Now, instead of repeating my lecture about how open can fail, I can just say, "you forgot to add use autodie; to the top of your program."
As of Perl 5.10.1, autodie is a core module. You can, of course, install it from CPAN if your are using an older version of Perl.
Ah, of course! What a dolt! Thanks! read more
on Implicit strictures in Perl 5.11