#!/usr/bin/perl use strict; print qq{\n}; my $tag; while() { chomp; if ( /^\[(\w+)\]/ ... /^\w+/ ) { $tag = $1 if $1; print "<$tag>$_\n" if ( ! /^\[/ ); } } __DATA__ [DATA] data1 [ENTRY] entrying here [STORY] story details