Given a command like,
perl -MO=Deparse -E'use constant FOO => 42; print FOO()'
How can I disable constant folding such that
print 42;
Shows me
print FOO();
Or the like. Ideally, I would like this to be a compiler option that works for all of Perl. You can see this talked about in this thread on the perl mailing list, [perl #97942] [PATCH] Add -DO
option to disable optimizations and disable constant folding and the peephole optimizer when used.. I tried -DO
and it didn't work. If that option doesn't work, I'm open to workarounds however they may come.
One method you can do is to prefix the constant with
&
,From the docs on
perldoc perlsub