{ open( IN, "pegasus.file" ) or die $!; local $/ = "\x1a"; # change the input record separator while () # $_ now contains one whole message, { # up to and including \x1a # do what you want with the message # including, if you like: @lines = split /\n/; # work on lines # or you could strip off the pegasus header stuff # and treat the remainder as if it were vanilla email # (just like you'd get with common unix mail tools) } } # record separator now reverts back to default