Slash Boxes
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.
More | Login | Reply
Loading... please wait.
  • I haven't gotten done guessing the last problem, yet!

    Is the problem apparent from the code snippet you posted, alone?

    J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers
    • The problem is caused by something else and that something else is not in But once you realize what's going on, you'll slap your forehead and say "of course!"

  • If there's a subroutine called Foo that returns an undefined value, you get that error message.
    sub Foo {}
    use Foo;
    my $foo = Foo -> new;

    Can't call method "new" on an undefined value at...
    • Yup. I was called over to look at the problem and it simply didn't occur to me that someone would name a sub after a package name.

      • Despite the fact that you are the author of aliased []?

        • With aliased, the sub is not the package name -- it's a shorter version -- and in any event, because it has a null prototype, it gets inlined away and no subroutine is left in the symbol table.

          However, that's still a pretty lame defense on my part :)

          • the sub is not the package name – it’s a shorter version

            Yeah, but it’s used like a package name, on the left side of an arrow operator.

            it gets inlined away and no subroutine is left in the symbol table.

            Not at all. It gets inlined into calls, but the subroutine is always there.

      • This is the way you do constructors in PHP4

        Ref: []

        If anybody wonders as to why somebody would do it in the first place...
  • I'd say that as well as providing an Object-Oriented interface, for some strange reason, is also exporting a function called Foo() you can use directly.

    Which is stupid of course, since now when doing OO you have to say


    The subroutine is found before the word is treating as a string (and thus class) and so Foo() returns undef, which gives your error.

    I seem to recall encountering this during my AppSpace days a few times, with the end result I wrote a standard symbol table sc
    • No. If exports a sub Foo, there's no problem.
      • Sorry?

        The specific problem is function vs class name. Why does it matter where the subroutine comes from?

        Specifically, if Foo contains sub Foo::Foo { undef } and exports it, what differs it from my defining sub Foo { undef } by hand?

        What am I missing here? Something different about the *Foo glob?

        Adam K