#!/usr/bin/perl -w use strict; open(F,"test.txt"); foreach(){ if ($_ =~ /.*(\d\d).*(\d\w+)/){ print "$1 : $2 \n"; } } close F;