open( IN, $filename ) or die "$filename: $!"; { local $/ = ''; # cf. perldoc perlvar about $/ and "paragraph mode" while () # read a whole record into $_ { @fields = split( /\](\w)\[/ ); # use parens to capture the letters shift @fields; # split puts an empty element before ']a[', so drop that my %record = @fields; # convert array to key=>value hash # you now have tags as hash keys, strings as hash values: # $record{"a"}==1, $record{"b"}=="FORTUNE BAY", etc. # to use as you see fit. } }