Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
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 drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2025-11-09 10:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (65 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.