Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: How to extract Name and No from .vcf file.

by pme (Prior)
on Aug 03, 2015 at 05:25 UTC ( #1137208=note: print w/replies, xml ) Need Help??


in reply to How to extract Name and No from .vcf file.

Hi shankonit,

I hope the comments help you to understand the code.

#!/usr/bin/perl use strict; use warnings; my $filename = $ARGV[0]; my ($name, $number); open my $fh, "<", "$filename" or die "$!"; open my $fh2, ">", "list.txt" or die "$!"; while (<$fh>) { # read line to variable $_ chomp; # removes any trailing str +ing from $_ if ( /^FN:(.*)/ ) { # get the name $name = $1; } elsif ( /=PREF:(.*)/ ) { # get the number $number = $1; printf $fh2 "%15s -> %s\n", $name, $number; # %d changed to %s in + order to keep leading '+' } } close $fh2 or die "$!"; close $fh or die "$!";

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1137208]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2018-06-24 08:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (126 votes). Check out past polls.

    Notices?