Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Friday September 26, 2003
06:25 PM

Long Friday

[ #14934 ]

My goodness, it's been a long day. I spent an hour tracking down a bug caused by the following code.

my @methods = qw/follow_link get title/;

use Class::MethodMaker
    new    => 'new',
    object => [
        'WWW::Mechanize' => {
            slot       => 'browser',
            comp_mthds => [@methods],
        }
    ];

If it doesn't just jump out at you, you'll slap yourself when you find it.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Did sir forget his underscore?

    And, out of interest, do you use @methods anywhere else? Looks like a useless use of variable to me. [qw/.../] is perfectly fine...
    • Re:Oops (Score:3, Interesting)

      Oh goody. You're going to slap yourself :)

      The first thing you do is create a file named "Foo.pm":

      package Foo;

      sub import { print "@_" }

      1;

      Then, in the same directory, run the following script:

      #!/usr/local/bin/perl -w
      use strict;

      BEGIN { unshift @INC => '.' }
      my @methods = qw/bar baz/;
      use Foo @methods;

      That prints "Foo". Foo's import method gets called with no arguments because the assignment to @methods happens after the use statement, even though strict does not complain because @methods has al

      • I think that if you do a
        use constant METHODS => qw( foo bar bat );
        then you can pass 'em in like you want.
        --

        --
        xoa

      • Assign to @methods in a BEGIN block.
        my @methods;
        BEGIN { @methods =  qw/follow_link get title/; }
      • You're right, I'm slapping myself. Iff need to use @methods anywhere else in your code.