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

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.