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

Testing for unimplemented

Jonathan E. Paton
March 30, 2002 07:49
Testing for unimplemented
Message ID:
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:


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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About