while(<$in_fh>) { my $line = $_; if ( $line =~ m[(\$\d?,?\d\d\d\.\d\d\b){3}] ) { print "$1"; print "$2"; print "$3"; $ctr ++; }