Hello iThunder,

As GrandFather says, you should put text into paragraphs using <p> ... </p> tags, and you should enclose code and data in <code> ... </code> tags. I also moved your post from Perl Monks Discussion to Seekers of Perl Wisdom.

Regarding the flip-flop operator (viz., .. in scalar context), you are confusing line numbers with sequence numbers. Actually, the flip-flop operator evaluates to a boolean value, i.e., either true or false. When the operator evaluates to true, Perl, as a convenience, returns “true” in the form of a sequence number. Consider:

use strict; use warnings; my $p; while (<DATA>) { chomp; if ($p = 3 .. 5) { print "$_: \$. is $.: p is $p\n"; } } __DATA__ line 1 line 2 line 3 line 4 line 5 line 6 line 7

Output:

14:00 >perl 1020_SoPW.pl line 3: $. is 3: p is 1 line 4: $. is 4: p is 2 line 5: $. is 5: p is 3E0 14:00 >

Note that the string E0 is appended to the final true value: this “gives you something to search for if you want to exclude the endpoint.” — perlop#Range-Operators.

Update: Added printout of $..

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,


In reply to Re: flip flop operator and if statement by Athanasius
in thread flip flop operator and if statement by iThunder

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.