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

Proposed module: Mac::PropertyList::Writable

by jimt (Chaplain)
on Feb 08, 2007 at 00:03 UTC ( #598915=perlmeditation: print w/replies, xml ) Need Help??

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 (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);

Replies are listed 'Best First'.
Re: Proposed module: Mac::PropertyList::Writable
by brian_d_foy (Abbot) on Feb 08, 2007 at 06:22 UTC

    Mac::PropertyList gives you write access. You can read a property list into the internal data structure, play with it how you like, then write it back out as a plist. The example is right in the synopsis.

    Still, I'd be happy to work with you to incorporate your ideas into Mac::PropertyList. Instead of a bunch of separate modules, lets make a single module that's really good. :)

    brian d foy <>
    Subscribe to The Perl Review

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://598915]
Approved by ww
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2017-12-12 18:38 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (335 votes). Check out past polls.