Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I am getting slightly different behaviours depending on whether I use
screwed $_;
screwed "$_";
I use AS 5.6.1
In the first, screwed()::@_ gets clobbered, in the second screwed()::@_ is OK, but @instances is still clobbered.

And if I could just add, to the original poster, that
map {function($_)} @array;
is generally frowned upon - map returns a list, and by not having map on the RHS of an assignment
@result_set = map {function($_)} @array
, that list is considered being used in a void context. This means, in this case, all the hard work of creating a list of results via the map is wasted, the list is thrown away. Because screwed() doesn't explicitly return a value, it defaults to using the return value of the close() statement at the end of the sub. If you really dont care about the return values of applying a function using the elements of an array as parameters, it is 'better'(tm) to use this idiom
foreach (@array) {sub_without_meaningful_return($_)}
This makes it clear that the function has side-effects - that is, the function uses and possibly changes some variable outside its scope- in screwed()'s case, STDOUT is used.
merlyn has lectured me once on this - so I now pass this on.

In reply to Re: opening a file destroys nulling entries in a list?!?! by leriksen
in thread opening a file destroys nulling entries in a list?!?! by matpalm

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

  • 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, 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, 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    [Discipulus]: good morning marto! a better weekend? i hope

    How do I use this? | Other CB clients
    Other Users?
    Others chilling in the Monastery: (7)
    As of 2018-05-21 07:51 GMT
    Find Nodes?
      Voting Booth?