use strict; use warnings; my $msisdn; while () { $msisdn = $1 if /^\s*MSISDN=(\d+);/; if (/\s*CF=([\w-]+);/) { print "$msisdn,$1\n"; } } __DATA__