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.
  • First off: I think you mean s/@foo/@exception_types/ in your error messages and a fat arrow rather than an = in your use statement.

    I ran into this problem when developing Sub::Exporter. It lets you say:

    my $sub;
    use Thing::ThatExports exported_routing => \$sub;

    ...and the coderef goes into the scalar instead of your symbol table. This never worked:

    exporting_routine => \my $sub;

    My assumption is that it's because of this equivalency:

    use Foo bar => $baz;
     
    BEGIN {
      require Foo;
      F

    --
    rjbs
    • Yeah, I was getting a bit sloppy in the post. Thanks for pointing those out.

      I've tried using PadWalker to get around some of these issues, but no love. Damn.

  • use Devel::BeginLift qw( init_var );

    sub init_var(\[$%@];@) {
        my $var = shift;
        if    ( 'ARRAY' eq ref $var ) { @$var = @_ }
        elsif ( 'HASH'  eq ref $var ) { %$var = @_ }
        else                          { $$var = $_[0] }
        return;
    }

    init_var my @foo => qw/ bar baz /;

    BEGIN { print "@foo\n" }

    =begin output

    bar baz

    • Beautiful! Mind if I clean this up and post it to the CPAN? (Or you can since you posted the code. Seems unfair to steal it from you :)

      • I was going to, but it’s obviously not going to happen, so if you want to go ahead, then do.

        • Heh. I'm heading on holiday for over a week. I doubt I'm going to get around to it, either :)