in reply to Re^2: constants wont optimize
in thread constants wont optimize
Actually, as you've found out, your way is the complicated one.
Simple:
use constant haveMod => eval { require mod; };
And for the non-trivial:
or evenmy $haveMod; BEGIN { ...[ something complicated ]... $haveMod = ...; } use constant haveMod => $haveMod;
BEGIN { ...[ something complicated ]... require constant; import constant haveMod => ...; }
PS - require always returns true, so the "1" is redundant.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: [DUP] Re^3: constants wont optimize
by patcat88 (Deacon) on Jul 10, 2011 at 20:58 UTC | |
by ikegami (Patriarch) on Jul 10, 2011 at 21:35 UTC |