Okay here's what I learned today from a friend.
"You are sipping when you should be slurping."

Of course if I had told you all what I was doing before
that line you would have definitely seen my real problem.

Okay here's close to what I did have (I burned that code long ago):

#!/usr/bin/perl -w use strict; open(FH, '-'); # using STDIN instead of a real file. while (<FH>){ my $entry = $_ =~ /:::(.*?):::/ms; open(FH2,'>filename'); print FH2 "$entry"; }
Of course this didn't work because I was only working with
the first line and what I wanted was further in the file
and on multiple lines. Here's what I am using.
#!/usr/bin/perl -w use strict; open(FH,'-'); my $file = do {local $/; <FH>}; #A really elegant way to slurp an entire file and fast too. #It creates a "disposable subroutine" in effect. #I can't take credit for coming up with it though. close FH; open(FH2,">filename"); my $entry = $file =~ /:::(.*?):::/ms; #Thanks Corion print FH2 "$1\n";

Thanks everyone. I liked the hint dws.
Thanks Corion for telling me about the not so greedy (.*?).
I liked the hint dws.
I learned from that hint but it wouldn't work for me until I slurped. :)
I'm REAL glad to know about perlre until I can make time for Mastering Regular Expressions


In reply to Re: Help!! Regular Expressions by providencia
in thread Regular expression to match text between two tags (was: Help!! Regular Expressions) by providencia

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.