#!/usr/bin/perl while(<>){ /^/ or next; ($output) = ($_ =~ /^(.*)<\/name>/); print "$output\n"; } #Alternative way to isolate name from line. #What happens if you get rid of the parenthesis around #the first occurance of $output?