Please help me to understand the 'next' command better
For the snippet shown below,
$! = 1; @l_test = (1,2,3,4,5,6,7); foreach $l_rec (@l_test) { next,print '.' if ( 4 == $l_rec); print $l_rec; }
in my opinion the expected output is 123.567
but the actual output is 123567,obviously the print command is getting skipped.
i changed the order in which the next & print is getting called,but the behavior remains consistent
From the documentation I have learnt that :
'Note that a block by itself is semantically identical to a loop that executes once. Thus next will exit such a block early.'
is this the behavior I experience above, please share your thoughts.
Correct my understanding if necessary.

In reply to understanding next by needperlhelp

Title:
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, 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:
    & &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.