Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Printf : How to repeat characters?

by eyepopslikeamosquito (Canon)
on Oct 03, 2010 at 04:28 UTC ( #863138=note: print w/ replies, xml ) Need Help??


in reply to Printf : How to repeat characters?

Does this do what you want?

my $a = chr(65); my $b = chr(66); my $c = chr(67); printf "%s" x 3, $a x 2, $b x 3, $c x 4;
Update: or perhaps this?
printf "%c" x 9, (65) x 2, (66) x 3, (67) x 4;
or even, using james2vegas' "$" idea, but with %c instead of %s
printf '%1$c'x2 . '%2$c'x3 . '%3$c'x4, 65, 66, 67;
BTW, the above strange-looking POSIX extension positional parameter $ printf syntax was introduced in Perl 5.8 in 2002.


Comment on Re: Printf : How to repeat characters?
Select or Download Code
Re^2: Printf : How to repeat characters?
by westrock2000 (Sexton) on Oct 03, 2010 at 04:34 UTC
    yep works perfect....the %s made all the difference :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://863138]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (12)
As of 2014-08-22 14:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (158 votes), past polls