in reply to Re^2: Export Constants Common to Lots of Packages
in thread Export Constants Common to Lots of Packages
Same here. At work, we've recently removed "use constant" from our code and converted to Readonly due to Damian's advice. It's really cleaned up a lot of our code.
Unfortunately, there are some bugs in how Perl handle tie which Readonly exposes. For example, the following prints "no":
#!/usr/bin/perl -l use strict; use warnings; use Readonly; Readonly my $VAR => 'SEARCH'; foreach my $var ($VAR) { print +($var eq $VAR) ? 'yes' : 'no'; }
Clearly that's wrong, but it's related to Perl's tie mechanism and not Readonly. As a workaround:
print +($var.'' eq $VAR.'') ? 'yes' : 'no';That's ugly as sin, but it works :(
Cheers,
Ovid
New address of my CGI Course.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Export Constants Common to Lots of Packages
by ikegami (Patriarch) on Nov 29, 2005 at 21:25 UTC | |
by Ovid (Cardinal) on Nov 29, 2005 at 21:36 UTC |