Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 3rd, 2012  |  syntax: None  |  size: 1.26 KB  |  hits: 26  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Why is Perl saying I only use this once? Why is that even an issue?
  2. use strict;
  3. use warnings;
  4. sub cfgRead () { $main::cfg{"abc"} = "/usr"; }
  5. 1;
  6.        
  7. #!/usr/bin/env perl
  8.  
  9. use strict;
  10. use warnings;
  11. use 5.005;
  12.  
  13. require File::Basename;
  14. import File::Basename "dirname";
  15. push (@INC, dirname ($0));
  16. require plugh;
  17.  
  18. my (%cfg);
  19.  
  20. sub subOne () {
  21.         my $list = `ls -1 $main::cfg{"abc"}`;
  22.         my @list = split (/s+/, $list);
  23.         my $fspec;
  24.         foreach $fspec (@list) {
  25.                 print $fspec . "n";
  26.         }
  27. }
  28.  
  29. sub mainLine () {
  30.         cfgRead();
  31.         subOne();
  32. }
  33.  
  34. mainLine();
  35.        
  36. Name "main::cfg" used only once: possible typo at /home/xyzzy/bin/xyzzy line 15.
  37. bin
  38. games
  39. include
  40. lib
  41. lib64
  42. local
  43. sbin
  44. share
  45. src
  46.        
  47. require plugh;
  48.  
  49. our (%cfg);
  50.  
  51. sub subOne () {
  52.    my $list = `ls -1 $cfg{"abc"}`;
  53.    ...
  54. }
  55.        
  56. our(%cfg);
  57. sub cfgRead () { $cfg{"abc"} = "/usr"; }
  58.        
  59. sub cfgRead {
  60.     my %cfg;
  61.     $cfg{"abc"} = "/usr";
  62.     ...
  63.     return %cfg;
  64. }
  65.        
  66. sub subOne {
  67.     my $cfg = shift;
  68.     my $list = `ls -1 $cfg->{"abc"}`;
  69.     ....
  70. }
  71.  
  72. my $cfg = cfgRead();
  73. subOne($cfg);
  74.        
  75. use warnings;
  76. $something = 1;
  77. $something = $something + 1;
  78.        
  79. use warnings;
  80. $something = 1;
  81. $something = $somehting + 1;
  82.        
  83. Name "main::somehting" used only once: possible typo at tmp.pl line 3.