[tpm] how to conditional compile

Indy Singh indy at indigostar.com
Fri Nov 27 11:44:29 PST 2009

To expand a little on what Abram suggested:

I think you have to put the subroutine definitions inside an eval.

Another way to do it would be to say:
if (something) {
    require 'x.pm';
else {
    require y.pm';

Where files x.pm and y.pm contain your two versions of the code.

Indy Singh
IndigoSTAR Software -- www.indigostar.com

  ----- Original Message ----- 
  From: Fulko Hew 
  To: TPM 
  Sent: Friday, November 27, 2009 2:00 PM
  Subject: [tpm] how to conditional compile

  I thought I was doing the right thing, but I can't get there from here.
  What I'd like to do is 'conditional compile'.  ie. define this set of
  subroutines if something, and a different set if something else.

  For example:

    if (eval 'use AMODULE; 1") {
      sub mysub1 { print "do something"; }
      sub mysub2 { print "something else"; }
    } else {
      sub mysub1 { print "mysub1() is unsupported"; }
      sub mysub2 { print "mysub2() is unsupported"; }

  Or in otherwords... if the module isn't found, I'd like to stub out some routines.

  Ideas anyone?


  toronto-pm mailing list
  toronto-pm at pm.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/toronto-pm/attachments/20091127/8bda2cab/attachment-0001.html>

More information about the toronto-pm mailing list