in reply to Re: format question
in thread format question

the second "format" line, that starts with ~ is supposed to be optional if there is no more data from $1 or $2. It would work if I used "format =", but I am using formline(), and it doesn't seem to...

thanks

ps
I posted this pretty late last night...is there a way to resubmit it now that there are more people logged on? I don't want to abuse this GREAT system.

Replies are listed 'Best First'.
Re: Re: Re: format question
by jmcnamara (Monsignor) on Nov 08, 2001 at 22:41 UTC

    Okay, I think I see the cause of the confusion. The tilde ~ does eliminate blank lines. However, setting $^A = "" does not reset the accumulator. You have to print it to do that.

    Consider the following example based on your code snippet:

    #Something tells me we're not programming in Perl anymore Toto. ;-) for (1..2) { print "Run: ", $_, "\n"; $^A = ""; formline(<<'OUTPUT_TABLE', 1, 2); @<<<<<<< @<<<<<<<<<<<< @<<<<<<< @<<<<<<<<<<<<~ OUTPUT_TABLE $out .= $^A; print $out; } for (3..4) { print "Run: ", $_, "\n"; $^A = ""; formline(<<'OUTPUT_TABLE', 1, 2); @<<<<<<< @<<<<<<<<<<<< @<<<<<<< @<<<<<<<<<<<<~ OUTPUT_TABLE print $^A; }
    This gives the following output. Note the additional line in Run 2.

    Run: 1 1 2 Run: 2 1 2 1 2 Run: 3 1 2 Run: 4 1 2
    Therefore, you will have to re-organise your code to make sure that you print $^A.

    --
    John.

      I get it ;)
      THANKS a TON !!! I can tell you spent time on this !