Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Other monks have mentioned this, but not in these words: map, grep, and for/foreach arrange for $_ to be an alias to each element of the list in turn. In a map block, $_ is not its own variable and modifying $_ will reach back into the original list. In some cases, $_ can even be aliased to some value slot that is read-only, and attempting to modify $_ will fail; for this reason, subs using $_ should localize *_, which replaces the entire glob and "shadows" any aliases that have been established in outer contexts.

There are several reasons to avoid eval STRING that do not affect eval BLOCK. An obvious problem is that eval STRING parses Perl code from a string. If that string is untrusted remote user input and not very, very, very strictly checked, you have a remote code execution vulnerability. There is also a performance issue, in that eval STRING must invoke perl's parser each time it is reached at runtime, while the BLOCK in eval BLOCK is compiled along with the rest of the program. This also leads to one of the reasons eval STRING can be needed: because the STRING is not compiled until runtime, eval STRING can also trap compilation errors in STRING, while a compilation error in the BLOCK in eval BLOCK is fatal before execution starts.


In reply to Re: Perl::Critic says don't modify $_ in list functions and other things by jcb
in thread Perl::Critic says don't modify $_ in list functions and other things by Lady_Aleena

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (8)
As of 2024-04-19 08:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found