How do I use macros in Perl, like I do in C?
Example:
#define value 100
print value;
I want to get the output as 100.
If you just want to define constants (like your example) rather than full macros, there are a couple of perl ways to do this.
Some people like:
use constant value => 100;
print value;
Note that 'value' is a subroutine, not a 'variable'. This means you cannot interpolate it in strings so you have to do. print "The value is ".value."\n";.
The "Best Practices" crowd like:
use Readonly;
Readonly my $value => 100;
print $value;
However, unlike constant, Readonly is not part of the core perl distribution and so needs to be installed from CPAN.