in reply to Save first n values from a file
Note that if you have strict or warnings enabled, you will get errors like: "Use of uninitialized value $k in printf". You can add error/null checking here to handle all of these. This would also mutate the @names array - keep a defensive copy around. :-)while(@names) { my ($i, $j, $k) = splice (@names, 0, 3); printf('$i is %s, $j is %s, $k is %s', $i, $j, $k); print "\n"; }
|
|---|