in reply to Help with error msg "Useless use..."

The full error message I get when running your code is Useless use of a constant in void context at test.pl line 17. and line 17 is
my $pms = join("\n", @foundfiles), "\n";
which joins together all the values in @foundfiles then throws it away, and assigns the "\n" to $pms.which parses as (my $pms = join("\n", @foundfiles)), "\n"; as pointed out by tye below. Assigning the value of join to $pms and doing nothing with the "\n", hence the error message. What you probably mean is
my $pms = join("\n", @foundfiles) . "\n";
(Note the period which is the string concatination operator, instead of the comma, which in scalar context evaluates its LHS, throws it away, then evaluates and returns its RHS)

Update: Thanks tye. This will teach me to try and answer a PM post while answering support calls at work. Next time I'll ignore the calls.. must have my priorities straight.

Replies are listed 'Best First'.
Re^2: Help with error msg "Useless use..." (nit)
by tye (Sage) on Sep 15, 2003 at 16:11 UTC

    Good catch.

    Rather minor correction: The original gets parsed as:

    ( my $pms = join("\n", @foundfiles) ), "\n";
    not as
    my $pms = ( join("\n", @foundfiles), "\n" );
    so it is the "\n" that gets thrown away.

                    - tye