For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > February 2006 > Type globs of subroutines?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Type globs of subroutines?
Angerstein

2006-02-22, 7:56 am

Short Question:

Is type globbing of subroutines possible or not?

for something like

&supersub(\&smallsub);

Hans Meier

2006-02-22, 7:56 am

Angerstein am Mittwoch, 22. Februar 2006 11.05:
> Short Question:
>
> Is type globbing of subroutines possible or not?


yes,

perl -le 'use warnings; use strict; \
sub sub1{1}; \
*sub2=\&sub1; \
warn sub2(); \
'
> for something like &supersub(\&smallsub);


This (passing a subroutine reference as argument to a subroutine):
is unrelated to the above.

perl -le 'use warnings; use strict; \
sub sub1{shift->()}; \
sub sub2 {2}; \
warn sub1(\&sub2);
'

hth
Hans
John W. Krahn

2006-02-22, 6:56 pm

Angerstein wrote:
> Short Question:
>
> Is type globbing of subroutines possible or not?


It is possible but using references is the preferred method.


John
--
use Perl;
program
fulfillment
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com