#!/usr/bin/perl -w use strict; while () { $_ =~ tr/!@#$%^&*//d; # will you encounter funky chars? next unless ($_ =~/(^\d+)/); print $_; } __DATA__ START 1 2 3! 4 5 END START 1* 2 3 4 5 6 END