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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |