in reply to Re^4: printf syntac
in thread printf syntac

The solution with List::MoreUtils is definitely good. But sometimes (like when writing code that needs to run on lots of different machines), reliance on a non-core module can be less economical than we would like, especially when the task being solved by the module isn't that complicated to begin with.

Here's the solution without the extra module:

open WRITEFILE, ">>", "$time.txt" or die "$time.txt: $!"; my $format = " %10s %10s\n"; printf WRITEFILE $format, $totalexpenses[$_], $totalcosts[$_] for (0.. +$#totalcosts); close WRITEFILE;