Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Answer: How can i print N repeated characters?

( #535726=categorized answer: print w/ replies, xml ) Need Help??

Q&A > strings > How can i print N repeated characters? contributed by lithron

for (1..5) { print "-"; }
Which prints the ----- you are looking for.

If you want to print the number of the iteration you could use:
for my $x (0..9) { print $x; }
Which outputs 0123456789

Comment on Answer: How can i print N repeated characters?
Select or Download Code
Re: Answer: How can i print N repeated characters?
by ptum (Priest) on Mar 10, 2006 at 17:43 UTC

    Or you could always do it this way:

    my $n = 5; print "-" x $n;
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2014-11-21 16:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (114 votes), past polls