Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Answer: How can i print N repeated characters?

by lithron (Chaplain)
on Mar 10, 2006 at 15:37 UTC ( #535726=categorized answer: print w/replies, xml ) Need Help??

Q&A > strings > How can i print N repeated characters? - Answer 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

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2016-12-06 06:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (101 votes). Check out past polls.