#!/usr/bin/perl -w use strict; open(FH, '-'); # using STDIN instead of a real file. while (){ my $entry = $_ =~ /:::(.*?):::/ms; open(FH2,'>filename'); print FH2 "$entry"; } #### #!/usr/bin/perl -w use strict; open(FH,'-'); my $file = do {local $/; }; #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";