#!/usr/bin/perl use strict; use warnings; # read in the data line by line while (my $line = ) { # chomp off the newline chomp $line; # see if we have a match of two letters at the start # of the line if ($line =~ m|^(\w{2})|) { # if it matched, add tags my $tag = $1; print "<$tag> $line <$tag>\n"; } else { # if it didn't match, just print the line print "$line\n"; } } __DATA__ il yadayadayada df yadayadayada