in reply to String concatenation function
# BY DR JONATHAN REES #
Don't be too proud.
$sym = "*"; # $sym is the string to be concatenated
Why is that not a parameter?
&concat($l); # calls the sub concat passing the
Don't use "&" when calling a sub. It's old fashioned and if you don't know its meaning (I doubt you do), you probably shouldn't be using it.
print $i; # prints the result
Don't comment *what* your code does, comment *why* it does that.
for ($k = 1 ; $k < $val ; $k++){ $i = $i.$sym; }
C-style for is error prone and a lot of work. Perlish foreach is more efficient and easier. The ".=" operator would have saved you two more non-whitespace characters. Besides that, you should of course have used the "x" operator.
}
And fix your indenting logic.
Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: String concatenation function (&fun)
by tye (Sage) on Jun 03, 2003 at 15:48 UTC | |
by Juerd (Abbot) on Jun 03, 2003 at 16:21 UTC |