my is definitly faster than
local,
according to
Advanced Perl programming and the
Camel Book, the
real gurus will explain why in details...
(
tilly,
merlyn, anyone else ???)
But in short (I don't master the topic yet ;-) 'my variables' uses 'scratchpad' (a special table assigned to a scope),
rather than the usual typeglobs table (and they don't use the assign/reassign value mechanism used by local).
The gain is double :
You access you variable directly through the scratchpad ($a)->(the address of $a)
rather than via the typeglob table (a)->(the typeglob table)->(the address of $a in this typeglob table)
You avoid the the saving/restoring of the previous value of the local variable when you enter/leave the scope.
"Trying to be a SMART lamer" (thanx to
Merlyn ;-)
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:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.