develooper Front page | perl.perl5.porters | Postings from July 2001

Re: [PATCH B::Deparse] support empty formats

Thread Previous | Thread Next
From:
H . Merijn Brand
Date:
July 12, 2001 03:01
Subject:
Re: [PATCH B::Deparse] support empty formats
Message ID:
20010712114546.E0DC.H.M.BRAND@hccnet.nl
On Thu 12 Jul 2001 11:13, Robin Houston <robin@kitsite.com> wrote:
> If you pass B::Deparse an empty format, like
> format FOO =
> .
> 
> then it'll crash. Patch below.

Try parsing this (it won't):

--8<--- format2.pl
#!/pro/bin/perl -w

use strict;

format HEADER =
HEADER
.
sub HEADER ()
{
    local $~ = "HEADER";
    my $HEADER;
				    if ($^V le v5.6.1) {
					open HEADER, "> HEADER";
					}
				    else {
    open HEADER, ">", \$HEADER;
					}
    select HEADER;
    write;
    close HEADER;
				    if ($^V le v5.6.1) {
					local $/ = undef;
					open HEADER, "<HEADER";
					$HEADER = <HEADER>;
					close HEADER;
					unlink "HEADER";
					}
    select STDOUT;
    $HEADER;
    } # HEADER
format STDOUT_TOP =
TOP
@<<<<<
@{[HEADER]}
.
format STDOUT =
STDOUT
@<<<<
$%
.
write;
-->8---

-- 
H.Merijn Brand    Amsterdam Perl Mongers (http://www.amsterdam.pm.org/)
using perl-5.6.1, 5.7.1 & 628 on HP-UX 10.20 & 11.00, AIX 4.2, AIX 4.3,
     WinNT 4, Win2K pro & WinCE 2.11 often with Tk800.022 &/| DBD-Unify
ftp://ftp.funet.fi/pub/languages/perl/CPAN/authors/id/H/HM/HMBRAND/


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About