in reply to formline, undefined format STDOUT

formline is low level function. As shown in perlformat, you have to use it with $^A (which you could also localize):
formline( "@<< @<< @<<", '1', '2', '2' ); print "$^A\n";

or specify an empty format before:

format = . formline( "@<< @<< @<<", '1', '2', '2' ); write;

Use a higher level format:

format = @<< @<< @<< 1, 2, 2 . write;

Or, switch to plain sprintf:

say join ' ', map sprintf('%-3d', $_), 1, 2, 2;
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: formline, undefined format STDOUT
by Anonymous Monk on Apr 20, 2015 at 14:47 UTC

    lets say there are two fields, one of them is long and other one is small. Whats the ways to print all the contents

    $l = "This is long string" ; $s = "s"; format STDOUT = ~~ @<<< @< $l, $s .

    above is not working.

      As documented in perlform, ~~ should be used for changing values that finally become undefined.
      #!/usr/bin/perl use warnings; use strict; my @l = ('This is long string', 'Another long one'); my @s = ('s', 'S'); format = ~~ @<<<<<<<<<<<<<<<<<<< @< shift @l, shift @s . write;

      It's time you read the documentation again. I've never used formats in Perl, and I hope I never will; but I was able to put this together in one minute.

      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

        Thnx for your help, this is what I was looking for :

        #!/usr/bin/perl use warnings; use strict; my @row; my @f_map = ('f1', 'f2'); my $f = "format = \n" . ('^' . '<' x 15 . '|') x scalar(@f_map) . "\n" . '@row' . "\n" . ('^' . '<' x 15 . '|') x scalar(@f_map) . "~~\n" . '@row' . "\n" . ".\n"; eval($f); # @row = ('blah1' x 10, 'blah2' x 10); write;

        output :

        blah1blah1blah1b|blah2blah2blah2b| lah1blah1blah1bl|lah2blah2blah2bl| ah1blah1blah1bla|ah2blah2blah2bla| h1 |h2 |