in reply to printf syntac

I think ikegami's reply needs some expanding:

Try

my $format = " %10s\n" x @totalexpenses . "%10s\n" x @totalcosts;

update: s/elaborat/expand/

Replies are listed 'Best First'.
Re^2: printf syntac
by props (Hermit) on Sep 27, 2007 at 06:57 UTC
    pen WRITEFILE , ">>$time.txt" or die "write error\n"; my $format = " %10s\n" x @totalexpenses . "%10s\n" x @totalcosts; printf WRITEFILE $format, @totalexpenses . @totalcosts;
    I think those two @totalexpenses . @totalcosts conflict.

      Change
      printf WRITEFILE  $format, @totalexpenses . @totalcosts;
      back to
      printf WRITEFILE  $format, @totalexpenses, @totalcosts;

        Hi Monks i have 2 arrays @totalexpenses = "ONE" , "TWO" , "THREE"; and @totalcosts = "1" , "2" , "3"; by executing the following code i do not get the result i wish to have in WRITEFILE filehandler. gives me:
        ONE TWO THREE 1 2 3 but what i want to look like is : ONE 1 TWO 2 THREE 3
        do i need another loop or a hash to form the data ?
        open WRITEFILE , ">>$time.txt" or die "write error\n"; my $format = " %10s\n" x @totalexpenses . "%10s\n" x @totalcosts; printf WRITEFILE $format, @totalexpenses , @totalcosts; close WRITEFILE; }