Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
This is a small modification for UNIVERSAL.pm for Win32 (or any other operating system that supports file systems where the letter case of file names is ignored) that detects when you get the letter case of a module name incorrect.

If you put this code in place of 3 lines of your perl/lib/UNIVERSAL.pm file (the three lines that nearly match the first three lines of this code) and then do "SET PERL5OPT=-mUNIVERSAL" in your AUTOEXEC.BAT file (or use some other method to get that environment variable set) then writing use Strict; becomes a fatal error instead of a silent and useless mistake.

If you are feeling particularly obsessive/compulsive, you can also set PERL5OPT="-MUNIVERSAL=overused,unimportant". The "overused" part will generate a warning if you use a module that you might as well have just required. The "unimportant" part will prevent Exporter::import() from being called when you use a module that didn't actually arrange for that to happen (currently, Exporter::import() is called whenever you use a module that doesn't define any import method at all, even it that module doesn't even mention Exporter -- this will probably be "fixed" at some point but with this you can "fix" it now and see if you are using any modules that depend on this "bug").

Just to be nice (or perverse), case is ignored for all of these options so you can use "PERL5OPT=-MUniversal=overUse,unImport" (the "d" in "overused" and the "ant" in "unimportant" are also optional).

require Exporter; #*import = \&Exporter::import; @EXPORT_OK = qw(isa can); my( $overused, $unimportant ); sub import { my( $pack )= @_; if( $pack =~ /^UNIVERSAL$/i ) { @_= grep { not /^overused?$/i ? ( $overused= 1 ) : /^unimport(ant)?$/i ? ( $unimportant= 1 ) : 0 } + @_; goto &Exporter::import; } elsif( keys %{$pack."::"} <= 1 ) { my @matches= ( "::" ); foreach my $file ( split /::/, $pack ) { @matches= map { my $match= $_; my @files= grep /^\Q$file\E::$/i, keys %{$match}; map { $match.$_ } @files; } @matches; } @matches= grep { s/^:://; s/::$//; $_ ne $pack } @matches; die "$pack->import() called for empty package!\nPerhaps you ne +ed to use ", 1 == @matches ? "C<use @matches> instead.\n" : @matches ? "one of these (@matches).\n" : "different upper/lower case in C<use $pack>.\n"; } else { warn "C<use $pack> but no $pack\::import().\n" if $overused; goto &Exporter::import unless $unimportant; } }

In reply to Universally unimportant and overused by tye

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-20 01:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found