in reply to recursive join

Is there a way to initialize the variable with a value before I join it
Yes, just declare it with something like my $LINE = "" before you start doing your joins.

You are also using join to do concatenation of two strings. Much better to use the "." operator which expresses exactly what you are doing:

$LINE = $LINE . $_;

or even more succinctly

$LINE .= $_;

Replies are listed 'Best First'.
Re: Re: recursive join
by Anonymous Monk on Dec 22, 2002 at 18:37 UTC
    The big win with the second is not that it is shorter to write, it is that it executes more efficiently because you do not have to recopy the existing string. Try this:
    my $t = ''; $t .= "test" for 1..50_000;
    versus
    my $t = ''; $t = $t . "test" for 1..50_000;
    See what I mean?