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...
|
---|
In Section
Seekers of Perl Wisdom