Re: Inserting lines into text files, or howto "fix" vCards having no n: entry
- From: analogquack@xxxxxxxxx
- Date: 6 Jun 2006 18:51:00 -0700
Thank you. Your clue results in a helpful pointer to the Tie::File
module.
It will take me quite a bit to figure out the rest of the puzzle. If
anyone else has any clues regarding how I might use the Tie::File
module to accomplish this task, I'd appreciate it.
Please understand that I am a Perl novice and the following is the best
I can do to describe where I'm trying to go with this. I've got to use
some plain English pseudocode where I've got no idea how to write the
Perl stuff in order to convey myself. I imaging it would be something
like (assuming this processing is done before the vCard file is split
into multiple vCards):
use Tie::File
tie @array, 'Tie::File', $sourcefilename or die;
for (@array) {
If, in a given paragraph there are no lines beginning with "N:" or
"FN:" then {
$org = the line of this paragraph beginning with "ORG:"
$n = $org except we've replaced "ORG" with "N"
$fn = $org except we've replaced "ORG" with "FN"
Insert $n and $fn as two new lines just after the line of this
paragraph which begins with "VERSION:2.1"
}
}
How would I go about completing the "for" statement in proper Perl?
I'm providing an example vCard to complete the illustration, with the
first record (paragraph) being a record which should be ignored,
followed by three that should have "N:" and "FN:" lines inserted into
them:
BEGIN:VCARD
VERSION:2.1
N:LastName;FirstName
FN:FirstName LastName
TITLE:Title
ORG:Company
ADR;WORK:;;WorkAddress;WorkCity;WorkState;WorkZip;WorkCountry
BEGIN:VCARD
VERSION:2.1
ORG:1 Day Paint and Body
ADR;WORK:;;27592 Camino Capistrano;Laguna Niguel;CA
NOTE:7:30am-6pm Mon-Fri
TEL;WORK:(949) 582-1821
X-Palm-Custom1:http://www.1daypaint.com/
END:VCARD
BEGIN:VCARD
VERSION:2.1
ORG:2 Advanced Studios
ADR;WORK:;;65 Enterprise;Aliso Viejo;CA;92656
TEL;WORK:949.443.2112
TEL;FAX:949.330.7581
EMAIL:info@xxxxxxxxxxxxx
X-Palm-Custom1:http://www.2advanced.com/
END:VCARD
BEGIN:VCARD
VERSION:2.1
ORG:604 List
X-Palm-Custom1:www.party.net
END:VCARD
.
- Follow-Ups:
- Re: Inserting lines into text files, or howto "fix" vCards having no n: entry
- From: Gunnar Hjalmarsson
- Re: Inserting lines into text files, or howto "fix" vCards having no n: entry
- References:
- Inserting lines into text files, or howto "fix" vCards having no n: entry
- From: analogquack
- Re: Inserting lines into text files, or howto "fix" vCards having no n: entry
- From: Gunnar Hjalmarsson
- Inserting lines into text files, or howto "fix" vCards having no n: entry
- Prev by Date: Re: filehandle to a member of a zip archive
- Next by Date: Simple GPA calculator program
- Previous by thread: Re: Inserting lines into text files, or howto "fix" vCards having no n: entry
- Next by thread: Re: Inserting lines into text files, or howto "fix" vCards having no n: entry
- Index(es):
Relevant Pages
|