Miscellaneous Thoughts

Though 1: Test::Class::Most fails on Perl 5.010001 -- but only on Linux. Not on FreeBSD, OS X or Solaris. I've already emailed the testers and hopefully someone can track down what's going on. I don't want to say "bug in Perl", but this is not platform-specific code, so it looks suspicious.

Thought 2: Can anyone please explain to me why anyone would want to buy a whyPad?

Thought 3: What does the following print and why? Results are the same for 5.10.1 and 5.8.9, in case you're wondering. Try and figure out the output before you run the code. I now know why it does this, but I was confused by the behavior.

#!/usr/bin/env perl -l

use strict;
use warnings;

my $foo = 3;
sub Foo::showit { print $foo }
sub Foo::incit { $foo++ }
my $foo = 10;
sub Bar::showit { print $foo }
sub Bar::incit { $foo++ }

Foo::showit;
Bar::showit;
Foo::incit;
Foo::showit;
Bar::incit;
Bar::showit;

6 Comments

A co-worker told me he would might buy it to read his ebooks on the train on the way to work and back, if it helps.

About 2: I'm thinking about buying and iPad because I will be able to leave the laptop at home, one less thing to cary on my short trips. I will only need the laptop with me (its a 17", so 2.5kg) on work trips.

For most common day-to-day tasks not work related, the iPad *seems* enough.

About 3: I got what I expected, no confusion. What was the part that confused you?

(3) didn't confuse me either. Now I'm worried I should have been confused.

OK that's what I thought was happening, although I'd have expected the refcount for the first $foo to be 2 after the second declaration.

This is just the same as

    {
        my $x;
        sub foo { $x }
    }
where &foo has a ref to $x even after its name has gone out of scope.

(How do I post code snippets without double-spacing like that? When will we get a Perl blog site that understands pod in comments?)

Leave a comment

About Ovid

user-pic Freelance Perl/Testing/Agile consultant and trainer. See http://www.allaroundtheworld.fr/ for our services. If you have a problem with Perl, we will solve it for you. And don't forget to buy my book! http://www.amazon.com/Beginning-Perl-Curtis-Poe/dp/1118013840/