Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
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 contemplating the Monastery: (17)
As of 2014-07-24 19:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (165 votes), past polls