SPUG: Annoying "name only used once" msg from -w

ced at carios2.ca.boeing.com ced at carios2.ca.boeing.com
Thu Apr 27 18:29:43 CDT 2000


>I often set a variable in the main program that is only 
>referenced in a subroutine that is in another file.  I 
>don't want to explicitly pass it to the subroutine because 
>I am dealing with large numbers of parameters, so I
>refer to it in the subroutine as $main::foo.
>
>When I use the perl -w command line option, I get annoying
>messages like Name "main::date" used only once: possible 
>typo ...
>
>Is there any other way to shut this message off other than:
>(1) Adding a gratuitous reference to the variable
>(2) Explicitly passing the variable to the subroutine
>(3) Turning off the -w option
>(4) Copying the subroutine code into the file containing the 
>    main program
>

Also gratuitous but you could "pragmatize" the problem 
away with "use vars":
   
    use vars qw( $foo $bar );
    ...
    $foo = 1;
    $bar = 2;
    
This'd eliminate "used only once" warnings. As a
bonus of course, you wouldn't have to package 
qualify if 'use strict' is in effect. But, if  
you have dozens that need pragma laundering, 
this could get ugly. 

The 5.6 lexical warning that Doug mentioned 
may be the best way of all. 

Rgds,
--
Charles DeRykus

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
 Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
 SUBSCRIBE/UNSUBSCRIBE: Replace "action" below by subscribe or unsubscribe
           Email to majordomo at pm.org: "action" spug-list your_address





More information about the spug-list mailing list