Lori713 has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to figure out why I'm getting a "Useless use of a constant in void context" error message when running a program. I've read princepawn's Useless Use question, but I confess I'm not understanding what's being said. I'm still a fledgling, so some of the explanations are over my head. Note, however, that the program still generates my text file as I expect, so this error isn't stopping the program... I just want to understand it better. Below is my little program (which I think I stole mostly from Ovid):
#!/usr/bin/perl5 -w use strict; use File::Find; my $report = "LDT_results.txt"; open MYOUTPUT, "> $report" or die "Can't open $report: $!"; my @directories = ("/usr/local/lib"); my @foundfiles; # Collect all .pm files below each directory in @directories # and put them into @foundfiles find ( sub { push @foundfiles, $File::Find::name if /\.pm$/ }, @directories); # and output them all to the screen so I can see it's working my $pms = join("\n", @foundfiles), "\n"; print $pms; #and print them to my file "LDT_results.txt" print MYOUTPUT $pms; close MYOUTPUT;
I've tried tilly's and merlyn's suggestions about getting some diagnostics on the command line, but I don't seem to be able to get the right command going. I've tried the following:
command line>perldoc perldiag /Useless use -Mdiagnostics
and I get the following message:
syntax error in file /usr/local/bin/perldoc at line 5, next 2 tokens "use warnings"
syntax error in file /usr/local/bin/perldoc at line 17, next 2 tokens "my $bindir "
syntax error in file /usr/local/bin/perldoc at line 21, next 2 tokens "my $pod2man "
syntax error in file /usr/local/bin/perldoc at line 43, next 2 tokens "my $me "
syntax error in file /usr/local/bin/perldoc at line 55, next 2 tokens "my @global_found"
syntax error in file /usr/local/bin/perldoc at line 110, next 2 tokens "Text:"
syntax error in file /usr/local/bin/perldoc at line 111, next 2 tokens "Text:"
syntax error in file /usr/local/bin/perldoc at line 123, next 2 tokens "am_taint_checking("
syntax error in file /usr/local/bin/perldoc at line 154, next 2 tokens "}"
syntax error in file /usr/local/bin/perldoc at line 166, next 2 tokens "my $opts "
/usr/local/bin/perldoc has too many errors.
I know very little about Unix commands, but I'm starting to learn. I've also read some from the Llama book (I don't have the Camel book yet), but it's a little over my head.
If someone would be so kind as to explain why it doesn't like the way I'm using the variables, I'd appreciate it. Thanks!
Lori
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help with error msg "Useless use..."
by dbwiz (Curate) on Sep 15, 2003 at 16:05 UTC | |
|
Re: Help with error msg "Useless use..."
by Paladin (Vicar) on Sep 15, 2003 at 16:00 UTC | |
by tye (Sage) on Sep 15, 2003 at 16:11 UTC | |
|
Re: Help with error msg "Useless use..."
by Lori713 (Pilgrim) on Sep 15, 2003 at 16:36 UTC | |
|
Re: Help with error msg "Useless use..."
by Not_a_Number (Prior) on Sep 15, 2003 at 17:39 UTC | |
by Lori713 (Pilgrim) on Sep 15, 2003 at 17:58 UTC |