develooper Front page | perl.beginners | Postings from March 2002

Testing for unimplemented

From:
Jonathan E. Paton
Date:
March 30, 2002 07:49
Subject:
Testing for unimplemented
Message ID:
20020330154906.32524.qmail@web14601.mail.yahoo.com
i list,

I'll swap from answering questions to asking question today.  Hopefully, I wouldn't be the only
person to learn something this way :)

Anyway, within some code (a module for CPAN actually), I want to write:

alarm $timeout
    unless not implemented("alarm");

which reads rather nicely.  This makes the module portable, since the alarm is a 'nice to have'
feature.  Making the implemented() function is a little harder.

I thought that the CORE psuedopackage would be enough, so I tried:

CORE->can("alarm");

which didn't do anything interesting.  Do I have to actually use the function, just to see if it
throws an error or not?  If so, how do I call an arbitary built-in... CORE::$func() doesn't appear
to work?

Probably I'll end up creating an xalarm() function, it'd be useful to be able to do this kind of
checking.  (fork/exec/shm/msg/chown... anyone?).

Jonathan Paton

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About