Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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.

Replies are listed 'Best First'.
Re^2: Printf : How to repeat characters?
by westrock2000 (Beadle) on Oct 03, 2010 at 04:34 UTC
    yep works perfect....the %s made all the difference :)

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2019-03-27 00:13 GMT
Find Nodes?
    Voting Booth?
    How do you Carpe diem?

    Results (125 votes). Check out past polls.