[Israel.pm] sub subroutines??

Yuval Kogman nothingmuch at woobling.org
Mon Oct 30 08:00:03 PST 2006


Use a class:

	package F1;

	sub the_sub {
		my ( $self, @args ) = @_;

		$self->show;

		$self->update;
	}

	sub show {

	}

	sub update {

	}

The polymorphism has to be resolved somehow-- if you want the
subroutines named identically, then an object must mediate between
the different meanings of 'update' and 'show'.

The reason for this is that there are no lexically scoped
subroutines. It has been proposed that 'my sub foo { }' be added to
Perl, but this has not yet been done (see Perl 6 and some hacks on
the CPAN if you *really* want this)

On Sun, Oct 29, 2006 at 07:14:36 -0800, rami doqa wrote:
> hello perl programmers, is there any way to do the
> following in perl:
> -------------------------------------
> sub f1
> {
> 	show();  # calls the show on the f2 subroutine but i
> need to call show of f1?
> 	update();
> 	....
> 	sub show {..f1.}
> 	sub update{.f1..}
> }
> 
> sub f2
> {
> 	show();   # calls the show on the f2 (right)
> 	update();
> 	....
> 	sub show {..f2.}
> 	sub update{..f2.}
> }
> -----------------------------------------------------------
> and i want to know if this is a good or bad
> programming style 
> thanx alot
> 
> regards 
> dakka, rami 
> 
> 
>  
> ____________________________________________________________________________________
> Want to start your own business? Learn how on Yahoo! Small Business 
> (http://smallbusiness.yahoo.com) 
> 
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://perl.org.il/mailman/listinfo/perl

-- 
  Yuval Kogman <nothingmuch at woobling.org>
http://nothingmuch.woobling.org  0xEBD27418

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://perl.org.il/pipermail/perl/attachments/20061030/e0f64474/attachment.pgp 


More information about the Perl mailing list