Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
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 avoiding work at the Monastery: (7)
As of 2014-09-16 11:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (12 votes), past polls