Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Perl without its internal 'magic' implementation is essentially no longer
Perl.
Here's some of the features of perl that would no longer work in sections of code where magic was disabled: $1, $2, et al, and in fact most other special variables, such as $., $!, %ENV, %SIG, @ISA etc; while (/.../g) (/g match in scalar context); weak references; ties; so for example this stops working: use Config; if ($Config{foo}) ... the taint mechanism; $#array, keys %hash, substr, vec in lvalue context; foo($hash{nonexist}), where the element is only vivified if foo() assigns a value to $_[0]; It would also interfere with offset caching on utf8 strings, meaning that for example //g on long strings will go quadratic on length. And of course if you write a function which is allowed to be called by others, then you have to allow that @_ may contain magic values which won't work properly if you've disabled magic in your function. Similarly, the return value you receive from other functions or perl builtins and ops may contain magic. In short, all but the most trivial of perl code requires magic to be enabled. Note also that you can't have just 'low' amounts of magic; in a particular section of code you either perform a check on each SV before you access it to see if it has any magic attached (and after you update it), or you don't. So its all or nothing. Dave. In reply to Re: Perl 5 Optimizing Compiler, Part 9: RPerl.org & The Low-Magic Perl Commandments
by dave_the_m
|
|