Hi rodinski,

I'll try to explain that last one:

local $_ = join "\n", @trip; printf "%15s to %-15s\n", $1, $2 while /^(.*)\n(?=(.*))/gm;

Let's remove the while for a moment and see what happens:

my $test = "Chicago Saint Looey Joplin OKC Amarillo Gallup Flagstaff Winona Kingman Barstow San Bernandino LA" ; if ( $test =~ /^(.*)\n(?=(.*))/gm ) { printf "%15s to %-15s\n", $1, $2 ; } __END__ Chicago to Saint Looey

(.*) = Chicago

\n = enter

(?=pattern) = Look around assertion. It is used to look ahead after the enter without changing the position where the last match ended. This is done so that the last arrival location becomes the depart location in the next search. https://perldoc.perl.org/perlre.html#Extended-Patterns

(.*) = Saint Looey

g = is in this case used to change the position where the last match ended. If you leave it out, you get a never ending loop (it will match the first found text over and over again) edit:See https://perldoc.perl.org/perlrequick.html#More-matching

m = Treat string as multiple lines


In reply to Re^3: Fence vs. Posts by Veltro
in thread Fence vs. Posts by rodinski

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.