in reply to Perl 28 broke L: How to fix?

It seems your usage of L depends on a "feature" that was deprecated over 20 years ago: It's setting up an AUTOLOAD function in the UNIVERSAL package, so that function calls such as Data::Dump::pp are sent to AUTOLOAD.

The module's tests only test a method call, and its synopsis only shows a method call. In fact, the breakage of the module was reported in #131571, and in the module's repository as #2. If I interpret the fix correctly, I think the module was never intended to work for regular function calls.

At the moment, I don't have any good ideas for a replacement. It's still possible to call Data::Dump->pp(), but that will pass the package as the first argument:

$ perl -wMstrict -ML -e 'Data::Dump->pp("x")' ("Data::Dump", "x")

Note that using -M actually doesn't necessarily make the one-liners longer:

$ perl -wMstrict -ML -e 'Data::Dump::pp("x")' $ perl -wMstrict -MData::Dump=pp -e 'pp("x")'

Replies are listed 'Best First'.
Re^2: Perl 28 broke L: How to fix?
by Anonymous Monk on Oct 28, 2019 at 16:25 UTC
    Note that using -M actually doesn't necessarily make the one-liners longer

    Not for this example but the real win is not having to worry about -M at all once you have -ML.

    breakage of the module was reported in #131571

    Thanks for the history lesson. So Perl's appearance of backward compatability was an illusion due to not fatalizing deprecated bugs for 20 years? Bugs were mistaken for features: "So, this is something we're likely to see many times in this annual development cycle​: code that breaks because we're fatalizing a behavior we've tolerated for twenty years (+ 1 month)."

    I see a lot of messages from recent versions of Perl about code that is "no longer allowed" and "forbidden" and even "illegal"! The code police have made easy things impossible. If you guys can't figure this out my chances are slim:

    haukex: At the moment, I don't have any good ideas for a replacement.
    Corion: I'm not sure how to best implement the functionality of L.
    
      I see a lot of messages from recent versions of Perl about code that is "no longer allowed" and "forbidden" and even "illegal"! The code police have made easy things impossible.

      I dunno about that, deprecations are usually made with a good amount of consideration, watching all of CPAN for breakage (as in this case) as a canary for how Perl is used by devs in production, and there is usually a workaround or fix possible for code that is affected by this. Personally, I don't remember really being affected by any surprising deprecations. So I'd be curious what problems specifically you've run into.

      As I said, in this case, I doubt that this module was ever supposed to work with plain function calls, and only methods. If you look at the really early and unreleased version of the module, that's all it supported. And the tests specifically test for the failure of a function call.

      If you guys can't figure this out my chances are slim

      There are probably some hacks that would make it possible, but I think chances are that they'd be pretty ugly hacks. Note that using UNIVERSAL::AUTOLOAD is not so great to begin with - anything that installs things into UNIVERSAL risks having other modules break in mysterious ways.