Print the same line multiple times in perl

I want to output in one line, which is now fine, for example:

print "$a\t" x 99;
print "$b\n";

So what does one line look like. But I also want to print these lines $conce. Is there a shortcut to do this, and not use for loops like:

for ($i = 1; $i <= $c; $i++) {
  print "$a\t" x 99;
  print "$b\n";
}

Are there any simpler ways to do this, like "$a\t" x 99?

+3
source share
2 answers
for (1 .. $how_many) { print "$foo\t" x 99, "$bar\n"; }

is IMO easier than C-style for (;;) loops.

+8
source

Yes, and you already have everything you need.

print ((("$a\t" x 99)."$b\n") x $c);
+4
source

All Articles