in reply to Help with error msg "Useless use..."
Your line 17
is assigning the result of join to a variable. That's OK, but then you are also listing another scalar (,"\n") hoping it will go into $pms as well. It won't, and Perl is warning you about that.my $pms = join("\n", @foundfiles), "\n";
If your purpose is to concatenate the two elements, then you should use the "." (dot) operator instead.
Perhaps you saw this working:
print join("\n", @foundfiles), "\n";
And that's fine, because print expects a list of arguments.
As for the diagnostics business, what merlyn meant is to include the -Mdiagnostics in you command line. That is, if your script is called "lory.pl" you can run it this way:
$ perl -Mdiagnostics lory.pl Useless use of a constant in void context at lory.pl line 17 (#1) (W void) You did something without a side effect in a context that + does nothing with the return value, such as a statement that doesn't re +turn a value from a block, or the left side of a scalar comma operator. +Very often this points not to stupidity on your part, but a failure of +Perl to parse your program the way you thought it would. For example, +you'd get this if you mixed up your C precedence with Python precedence +and said $one, $two = 1, 2; when you meant to say ($one, $two) = (1, 2); Another common error is to use ordinary parentheses to construct a + list reference when you should be using square or curly brackets, for example, if you say $array = (1,2); when you should have said $array = [1,2]; The square brackets explicitly turn a list value into a scalar val +ue, while parentheses do not. So when a parenthesized list is evaluat +ed in a scalar context, the comma is treated like C's comma operator, wh +ich throws away the left argument, which is not what you want. See perlref for more on this.
All the lines you see are the result of diagnostic, which is explaining verbosely what you previously got in a dry warning.
HTH
|
|---|