in reply to How to extract Name and No from .vcf file.
use strict; use warnings; my $filename = $ARGV[0]; my ($name, $number); open my $fh, "<", "$filename" or die "$!"; open my $fh2, ">", "list.txt" or die "$!"; my @matches=(); while(my $line = <$fh>) { if (grep { $line =~ $_ } qr/^\s*FN/, qr/\s*TEL/){ if( $line =~ /^\s*FN:(.*)/ ) { push(@matches,$1); } elsif( $line =~ /^\s*TEL;TYPE=CELL;TYPE=PREF:(.*)/ ) { push(@matches , $1); } } else{ next; } } print $fh2 "@matches" ; close $fh2 or die "$!"; close $fh or die "$!";
|
|---|