Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: sprintf and arrays of unknown (in advance) length

by dbuckhal (Hermit)
on Oct 12, 2018 at 16:53 UTC ( #1223936=note: print w/replies, xml ) Need Help??


in reply to sprintf and arrays of unknown (in advance) length

Another 'x' option...
perl -Mstrict -we ' my @arr = (0..10); printf("%d "x@arr, @arr); ' __output__ 0 1 2 3 4 5 6 7 8 9 10

or 'join' option...

perl -Mstrict -we ' my @arr = (0..10); printf("%s", join(" ", @arr)); ' __output__ 0 1 2 3 4 5 6 7 8 9 10

EDIT:

Yes, I know I could build an output string by looping over the array, but I am trying to learn about sprintf. :)

Sorry if 'join'-ish type option above was something OP already tried...

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2019-10-20 03:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?