Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
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
Replies are listed 'Best First'.
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 browsing the Monastery: (7)
As of 2015-07-30 11:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (271 votes), past polls