Actual Perl question

Charles Curley charlescurley at charlescurley.com
Wed Mar 20 13:12:38 MDT 2019


I would like to convert a spreadsheet to vcards. The closest I have
come to anything useful is to use Perl's vCard::AddressBook module.

If you know what your phone numbers are, you can do:

# complex getters/setters
$vcard->phones([
    { type => ['work', 'text'], number => '651-290-1234', preferred => 1 },
    { type => ['home'],         number => '651-290-1111' }
]);

My spreadsheet has three columns for phones, home, work and mobile,
which may or may not have a phone number for any given row. What I have
now is:


  if (length($fields[6]) > 0) {
    $vcard->phones ([{type => ['home'], number => $fields[6]}]);
  }
  if (length($fields[7]) > 0) {
    $vcard->phones ([{type => ['work'], number => $fields[7]}]);
  }
  if (length($fields[8]) > 0) {
    $vcard->phones ([{type => ['mobile'], number => $fields[8]}]);
  }


If I call $vcard->phones twice, the second call obliterates the data
passed in by the first call. So that doesn't work.

I need to accumulate such phone numbers as I have, then pass them all
in at once. My question is, how do I do that?

-- 
"When we talk of civilization, we are too apt to limit the meaning of
the word to its mere embellishments, such as arts and sciences; but
the true distinction between it and barbarism is, that the one
presents a state of society under the protection of just and
well-administered law, and the other is left to the chance government
of brute force."
- The Rev. James White, Eighteen Christian Centuries, 1889
Key fingerprint = CE5C 6645 A45A 64E4 94C0  809C FFF6 4C48 4ECD DFDB
https://charlescurley.com


More information about the PLUG mailing list