Syntactic Confectionery Delight | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
You have the canonical answer from jwkrahn. However your code indicates a few opportunities for learning. First off always use strictures (use strict; use warnings;). Perl programers seldom use a C style for. The more usual way to iterate a fixed number of times is:
Although in the case in hand you don't need the counter at all. You could just:
and if there is only one simple statement in the loop you can use the for as a modifier:
I suspect there is a transcription error in your sample code. Most likely what you intended was:
in which case Perl allows you to use the concatenation assignment operator:
so a more Perlish technique (without using the x operator) is
DWIM is Perl's answer to Gödel In reply to Re: Making a variable tab string
by GrandFather
|
|