HaB has asked for the wisdom of the Perl Monks concerning the following question:


So I am currently on a project to document someone else's code (ugh!), and from what I can tell, the programmer in question doesn't seem to be all that familiar with perl. I am seeing some things that definately run counter to things I was taught or have learned. So I figure I'd consult the Monks for clarification.

Here's the first oddment:
# at the top of the script: $sb="\013"; $eb="\034"; # those two values are never altered anywhere else in the main portion + of the script. # then, later... sub whatever { local ($sb); local ($eb); $sb="\013"; $eb="\034"; # rest of sub }
Is this redundant? Wouldn't my() be better suited to do this? I'm not sure why he even wants local copies of those vars, since they never change. I guess what I'm looking for is a practical explanation of the difference between my and local, and the situations in which you would prefer one over the other. I have strict in use all the time, but I have only ever used my(), so I'm not clear on the difference.