LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Perl OO and formats

[ILUG] Perl OO and formats

Fergal Daly fergal at esatclear.ie
Wed Feb 9 18:53:56 GMT 2000


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:






More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


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!
RSS Version
Powered by Dell