#!/usr/bin/perl print qq||; print "\n"; while($_ = ){ if (/^\[\w+\]/ .. /^\[\w+\]/) { $save = $_; $save =~ s/\[//g; print $save; } } #### __DATA__ [DATA] data1 [ENTRY] entry here [STORY] story details [DATA] [ENTRY] another entry here [STORY] another story