# getting the source code from the file my $target_data; { local $/ = "VARIABLE,PM2.5\n"; open my $INFILE, '<', '/home/uila3/rhuff/doh/2010090913.txt' or die "Couldn't open /home/uila3/rhuff/doh/2010090913.txt: $!"; my $discard = <$INFILE>; $target_data = <$INFILE>; close $INFILE; } print $target_data; print '*' x 20; for my $line (split /\n/, $target_data) { if ($line =~ m{ \A ( \p{Uppercase}{2} \d+ ) , .* , (\d+) }xms ) { print "$1 $2"; } }