The eval is because the regexp might match a package name

I knew there was a reason like that but was puzzled when it worked without eval. Thanks for explaining. I forget to load modules and -ML is less punishment so you can imagine how much I like L! I wonder why Perl doesn't use the failure to load a method or function, because the module isn't loaded, as an opportunity to look for it and load it. For example:

perl -e 'Foo->bar'
Can't locate object method "bar" via package "Foo" (perhaps you forgot to load "Foo"?) at -e line 1. (Perhaps Perl, or perhaps *you* forgot to load "Foo" so object method "bar" can be located? ;-)
perl -e 'print qq~package Foo; sub bar { print "baz\\n" } 1\n~' > Foo. +pm; cat Foo.pm
package Foo; sub bar { print "baz\n" } 1
perl -I. -MFoo -e 'Foo->bar'
baz
perl -I. -ML -e 'Foo->bar'
baz
I can hack away -M Perl, to locate object method "bar" via package "Foo", why wont you?!
perl -I. -e 'eval{Foo->bar};$_=$@;s/.*forgot to load "([^"]+)".*/$1/s; +eval{require"$_.pm"};Foo->bar'
baz
And minimize L, to see what's happening, to X.pm:
perl -e 'print qq~package X; { package UNIVERSAL; our \$AUTOLOAD; sub +AUTOLOAD { warn "\$AUTOLOAD" }} 9\n~' > X.pm; cat X.pm
package X; { package UNIVERSAL; our $AUTOLOAD; sub AUTOLOAD { warn "$AUTOLOAD" }} 9
perl -I. -MX -e ''
I don't know what this means:
IO::File::DESTROY at X.pm line 1.
IO::File::DESTROY at X.pm line 1 during global destruction.
IO::File::DESTROY at X.pm line 1 during global destruction.
IO::File::DESTROY at X.pm line 1 during global destruction.
IO::File::DESTROY at X.pm line 1 during global destruction.
But this!
perl -I. -MX -e 'Foo->bar'
Yes
IO::File::DESTROY at X.pm line 1.
Foo::bar at X.pm line 1.
IO::File::DESTROY at X.pm line 1 during global destruction.
IO::File::DESTROY at X.pm line 1 during global destruction.
IO::File::DESTROY at X.pm line 1 during global destruction.
IO::File::DESTROY at X.pm line 1 during global destruction.
I know what line 2 means! Perl knows what it means. Why doesn't she connect the dots automatically? I guess it would lead to all sorts of chaos and... L! Is L searching @INC in the background with Module::Load to find Foo.pm (and say Bar->foo that doesn't exist), and that's somehow dangerous (according to L docs)?

In reply to Re^4: Perl 28 broke L: How to fix? by Anonymous Monk
in thread Perl 28 broke L: How to fix? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.