Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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

by dbuckhal (Chaplain)
on Oct 12, 2018 at 16:53 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1223936]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-19 18:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found