in reply to Concatenation(Brain Fart)
join can take arbitrary lists, whereas . (dot) concatenates the left hand side with the right hand side.
sub concat { return join '', @_; }
Or if you only want to work with two args, there is the dot operator:
sub concat { return $_[0] . $_[1];
Interpolation also works:
sub concat { local $" = ''; return "@_"; }
Unless you can think of a good reason otherwise, the first solution is probably the most clear and flexible -- a more generalized solution.
I think Perl was given the smallest possible operator (dot) for concatenation of strings to make the C people feel bad.
Dave
|
|---|