In addition to juster
's Re: Overwriting a Constant
, probably the closest you can get is via simulative (re)setting of constants from the command line by using Getopt::constant
, you provide default
values - for constants you use (these values can be scalars, lists or even coderefs) - upon 'use
'ing Getopt::constant, then from the command line these constants can be made to look like having been assigned new values or used in their original definitions.
Interesting to note is that Getopt::constant does prefix such constants too and this serves to distinguish them by providing a label before the constant name, you can pass empty-string to the ':prefix' label too.
#SYNOPSIS from Getopt::constant document...
# Assuming @ARGV is: ('-foo=9,8,7', '-bar', 'wakawaka.txt')
use Getopt::constant (
':prefix' => 'C_', #Can be null too
'foo' => [3,5],
'bar' => 0,
-foo=one,two,three : fooey on these items
-bar : enable barriness
# @ARGV is now 'wakawaka.txt', and you've now got
# a constant C_foo with value (9,8,7)
# and a constant C_bar with value 1
N.B: Nefarious purposes can backfire in a hairy way so 'plot' with caution...
Excellence is an Endeavor of Persistence.
Chance Favors a Prepared Mind.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||