Nested formats
authorFather Chrysostomos <sprout@cpan.org>
Mon, 6 Aug 2012 16:48:07 +0000 (09:48 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 6 Aug 2012 21:04:03 +0000 (14:04 -0700)
commit64a408986cf3da7615062d0778e28cfa24288618
tree1043275c237f051d795efb8b151b5bb0bcaddc89
parenteaf6a13dc1ee199aebc2ca608507bab3b8244655
Nested formats

Are nested formats a good idea?  Probably not.  But the only rea-
son they don’t work is that the parser becomes confused and loses
track of where it is.

And it would be nice to have some consistency.  I can put sub defini-
tions inside a format:

format =
@
;sub foo {
    bar
}
.

and:

format =
@
{
    sub foo {
        bar
    }
}
.

so why not these?

format foo =
@
;format bar =
@
.
.

format foo =
@
{
    format bar =
@
.
}
.

In perl 5.17.2 and earlier, you can nest formats, but, due to the
parser being confused, the outer format must be terminated with }
instead of a dot.  That stopped working with commit 7c70caa5333.

format =
@<<<<<<<<<<<<<<<
"Just another"; format STDERR =
@<<<<<<<<<<<<<<<
"Perl hacker"
.
}
write; select STDERR;
write;
t/op/write.t
toke.c