I'm thinking about tossing a module up onto CPAN, but figured I'd open up for comment first.

As the name implies, it reads Macintosh Property List files, much like Mac::PropertyList and Mac::PropertyList::SAX and Mac::Tie::PList. So why do we need another module? Two words - "write access".

About a year and a half ago, I needed to transmit some information from an OS X app to a server, parse it, manipulate it, and send it back to the OS X app. I decided that the simplest thing would be to use the existing property list format - it held all the data I needed, I wouldn't need a new parser on the cocoa side, and parsing it on the perl side was easy.

What I found lacking in the CPAN options was write access - I needed to manipulate the data, not just simply read it. So I wrote my own module to do it. I recently dusted off the code for a different project and realized that the available offerings are still claiming that write access is a future item.

So, here it is. You can try the code at http://www.bassetsoftware.com/perl/Mac-Plist-Writable.tar.gz (please note, Basset is required (on CPAN)), and any feedback or suggestions would be appreciated before I unleash it (assuming I do at all).

I did my best to translate it directly into perl structures. So your NSDictionaries become hashrefs, your NSArrays become arrayrefs, and your scalars are still..scalars. But, the scalars are also tied objects that let you set the type of the object as well (Note! this is not automatic!).

use Mac::Plist::Writable; my $plist = Mac::Plist::Writable->from_plist_file('/path/to/some.plist +'); $plist->{'CFBundleIdentifier'} = 'com.bassetsoftware.PerlMonkNode'; Mac::Plist::Writable->add_node($plist, 'NewKey', '42', 'integer'); print Mac::Plist::Writable->to_plist($plist);

In reply to Proposed module: Mac::PropertyList::Writable by jimt

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.