$_ =~ /(\d*).*SWITCH\sFastEthernet(\d)/; # just an example on how to extract some data my $id = $1; # get the iD my $switchNr = $2; # get the number of the switch