Hi you will find this probably does what you want. The comments are in the code. I read from the <DATA> filehandle but have included code that shows how to read from a file and also to save the results

#!/usr/bin/perl -w use strict; my @saves; # we will save our stuff in here my @ok_posters = qw ( Administrator Sam ); # generate a regex to match our approved posters my $ok_regex = join "|", @ok_posters; my $ok_regex = qr/(?:$ok_regex)/; { # use local to localise the change to the input record # separator to this block only, saves nasty suprises local $/ ="_______________________________________________________ +__\n"; # read in data from file handle one record at a time # each record is stored in the magical $_ var while (<DATA>) { # add data to our array if it matches # the required criteria push @saves, $_ if /^From\s+$ok_regex/; } } print @saves; # this is how you read from the file message.txt instead of <DATA> #{ # local $/ ="______________________________________________________ +___\n"; # open (FILE, "<message.txt") or die "Unable to open file for readi +ng, Perl says: $!\n"; # while (<FILE>) { # push @saves, $_ if /^From\s+$ok_regex/; # } # close FILE; #} # uncomment this to save the results # save("c:/mysaves.txt", @saves); sub save { my $file = shift @_; my @stuff = @_; open (FILE, ">$file") or die "Unable to open file for writing, Per +l says: $!\n"; print FILE @stuff; close FILE } __DATA__ From Sam (Wed Jul 11 18:12:08 2001): This space intentionally filled. _________________________________________________________ From Administrator (Wed Jul 10 01:05:55): Message _________________________________________________________ From Sam (Wed Jul 11 18:12:08 2001): This space intentionally filled. _________________________________________________________ From Blah Blah (Wed Jul 10 01:05:55): Message _________________________________________________________ From Sam (Wed Jul 11 18:12:08 2001): This space intentionally filled. _________________________________________________________ From Blah Blah (Wed Jul 10 01:05:55): Message _________________________________________________________

Hope this helps

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print


In reply to Re: Message Board Mangling by tachyon
in thread Message Board Mangling by achiles

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.