Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Just an additional note --- 'used only once' won't come into play in a variety of situations:

#!/usr/bin/perl -w use strict; use vars qw/$abc @def %ghi/; our($jkl, @mno, %pqr); my($stu, @vwx, %y_and_z); sub qux {} open(FOO,$0) or die $!; opendir(DIR, '.') or die $!;

In 5.6.1, the above throws warnings for FOO and DIR, and all of the our variables, but nothing else --- in 5.8.0, only FOO and DIR elicit warnings. Variables declared with 'use vars' (and now our) are exempt, as are subroutines and lexicals.

To top it off, 'used only once' really only applies to things in the symbol table, and in particular, is elicited only when the *typeglob is used but once --- as soon as two or more slots in a typeglob are filled, all identifiers within that typeglob are exempt:

#!/usr/bin/perl -w use strict; use vars '$foo'; our(@foo); # second use of *foo $main::bar = 42; %main::bar = (a => 1); # second use of *bar our($FOO, @DIR); open(FOO,$0) or die $!; # second use of *FOO opendir(DIR, '.') or die $!; # second use of *DIR sub blah {} our($blah); # second use of *blah

No warnings --- even though $main::bar is used only once, the *bar identifier is used more than once.


In reply to Re: Warnings for unused subs by danger
in thread Warnings for unused subs by VSarkiss

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 learning in the Monastery: (8)
As of 2024-04-20 00:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found