while(<>){ if(/([^<]*)<\/a>/){ push @ar, "$3\t$2"; } else { warn "Err: $_\n"; } }