Dynamic sub references

#!/usr/local/bin/perl

use strict; # always

*dynamicsub = \&{'somepackage::somesub'};
&dynamicsub('blah blah') if defined(&dynamicsub);

The line in bold above is pretty cool if you're a Perl hack. Dynamically referencing and invoking a routine (regardless of what package it may be in) like that is pretty handy.

About

This article was published on May 23, 2001 1:11 PM.

The article previously posted was Gamecube pricing!.

The next article is rain rain go away.

Many more can be found on the home page or by looking through the archives.

Powered by Movable Type