in reply to new to perl : how to match ?

Your question is a little unclear to me, but lets assume that you only want to match on (and return) the 3rd "word" in each line.

Then you could do something like this:
#!/usr/bin/perl -w use strict; while (<DATA>) { my $string = (split)[2]; # extract the 3rd "word" print "$string\n" if $string =~ /^[gH]/; #output if it begins w +ith a "g" or a "H" } __DATA__ data to gbsdff03dfif7 is data to HR620-Asdf2 data to HP650dfgd-Af452 is

Cheers,
--Darren :)