Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Printf : How to repeat characters?

by eyepopslikeamosquito (Chancellor)
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
Replies are listed 'Best First'.
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 examining the Monastery: (10)
As of 2015-07-31 08:37 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 (276 votes), past polls