>>>>> "MR" == Matteo Riva <mura...@gmail.com> writes:
MR> Hm no maybe I didn't explain myself: my doubt was not about the MR> use of constants, but about the "strange" way of defining MR> them. What I thought when reading it was: "Why not just 'use MR> constant ...' ?". And later "But how exactly does it work?" I'm MR> now reading perlsub, but it's often easier to find out the "how MR> does it work" than the "why did he do that". the strange way is because that is how perl does it. perl doesn't have a proper macro mechanism which is how many langs do constants. so it needs something that is parsed in perl and subs with empty prototypes work well. the compiler sees there are no allowed arguments (the empty prototype) and that the body is just a constant with no other code. this is then converted to a real compile time constant when used. it is wacky but it works. normally it is best invoked with the constant pragma but as slurp needs to be very backwards compatible i did it by hand. also there are other ways such as the readonly module which works with scalar vars so they can be interpolated (which constant subs can't). uri -- Uri Guttman ------ u...@stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/