From: Fergal Daly (fergal at domain esatclear.ie)
Date: Wed 09 Feb 2000 - 18:53:56 GMT
There is a nicer way to do it, you could try below seeing as how you're
going all object oriented. The code is theived from the perlform man page
and then OOified. This should compile OK, but that's as much as I've tested
it. If you're going to use you should really break the package out into a
module,
Fergal
my $form_string = <<EOF;
Check me out
at domain <<< at domain ||| at domain >>>
EOF
my $format = OOFormat->new($form_string);
my $a_string = $format->swrite(1, 2, 3);
my $another_string = $format->swrite(4, 5, 6);
print $a_string."\n";
print $another_string."\n";
package OOFormat;
sub new
{
my ($pkg, $format) = at domain _;
my $self = bless {}, $pkg;
$self->{'format'} = $format;
return $self;
}
sub swrite
{
my $self = shift;
$^A = "";
formline($self->{'format'}, at domain _);
return $^A;
}
At 12:09 09/02/00 +0000, Donncha O Caoimh wrote:
>For those who might be interested, I had to create the formats "on the
>fly" like so:
>$format="format CUSTOMER_REPORT=
>";
>and then
>eval $format
>later in my subroutine. Of course, all $ signs had to be protected too
>but it seems to work and I'm in a hurry..
>Simply "require"ing the file with the formats in the derived class
>didn't work.
>
>Donncha.
>
>
>Donncha O Caoimh wrote:
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:05:23 GMT