Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I might add the one bit that made me curious (and that I've never really investigated) you didn't really expand on. Specifically, how the function of "$/" works. Admittedly, it's not something one fools with too often, but a bit of explanation may be in order.

So, I ran some quick tests just to look at what happens when you modify $/. Some of these have implications even when you don't modify $/ -- for example, only one newline will be removed, even if there are two.
$/='abc'; $_='lafbabc'; chomp; print; ##prints 'lafb', removes 'abc' as expected $_='lafbabcq'; chomp; print; ## prints 'lafbabcq', does not remove embedded 'abc' $_='lafbab'; chomp; print; ## prints 'lafbab', does not remove partial $/ -- 'ab' $_='lafbc'; chomp; print; ## prints 'lafbc', does not remove partial $/ - 'bc' $_='lafabcabc'; chomp; print; ##prints 'lafabc', only removes ONE $/
Note that the whole string in $/ needs to be present to be considered an "end-of-line" (it doesn't pick out portions of $/), and that it won't remove embedded $/'s.

These things I think might be helpful to beginners as examples. Also, you might have included the warning about parentheses
chomp $a, $b; ## this means chomp $a, but leave $b alone! chomp ($a, $b); ## this means chomp both
I'm going to reserve upvotes/downvotes -- I think you can improve the tutorial considerably and make it worthy of an upvote.

In reply to Re: chop() and chomp() by SamCG
in thread chop() and chomp() by Parham

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
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others exploiting the Monastery: (5)
    As of 2018-09-22 08:48 GMT
    Find Nodes?
      Voting Booth?
      Eventually, "covfefe" will come to mean:

      Results (190 votes). Check out past polls.

      • (Sep 10, 2018 at 22:53 UTC) Welcome new users!