#!/usr/bin/perl if (@ARGV !=1) { print "usage: vcf-split.pl \n"; exit; } $src = shift @ARGV; # $out = 'out/'; # uncomment to change the diretory to save .vcf files open SRC, $src or die "*** error: cannot open file $src\n"; $n = 0; $vcf = ''; foreach () { next unless (/^BEGIN:VCARD/ || $vcf); $vcf .= $_; $file = $1 if /^X-EVOLUTION-FILE-AS.*:(.*\S)/; vcf(); } vcf(); close SRC; print "*** $n vcards saved.\n"; sub vcf { if (/^END:VCARD/) { $n++; $file = $n unless $file; open OUT, ">$out$file.vcf"; print OUT $vcf; close OUT; $vcf = $file = ''; } }