use strict; use warnings; while(){ print "$1|$2" if (/EEH_ErrorCode\=\( (\d+), \/\* Component \*\/ (\d+) \/\* Error \*\//); } __DATA__ EEH_ErrorCode=( 15, /* Component */ 65 /* Error */ #### use strict; use warnings; my @array; while( read( DATA, my $buf, 1 ) != 0 ){ push @array, $buf if $buf =~ /\d/; } print @array; __DATA__ a1b2c3d4