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
@<<< @||| @>>>
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) = @_;
my $self = bless {}, $pkg;
$self->{'format'} = $format;
return $self;
}
sub swrite
{
my $self = shift;
$^A = "";
formline($self->{'format'}, @_);
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:
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!