Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

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
[Corion]: Meh. I have a very simple mechanism to scrape+track prices, and even to send me mail if something changes (via cron), but SQLite doesn't support window functions, so my simple SQL to determine a price change won't work :-( Maybe I should store the DB ...
[Corion]: ... in Pg, but that would mean that I'd have to deal with credentials and stuff :)
[Corion]: In fact, the whole thing is just four simple programs, one App::scrape, another being DBIx::RunSQL, and one some glue to convert a JSON object into an SQL INSERT statement (+DBI connect/execute), so it would be an incredibly simple solution...
[Corion]: ... but that simplicity falls down due to SQLite letting me down and me being too lazy to move to a real DB. Maybe DBD::CSV can handle window functions...
[hippo]: Pg has the "trust" mechanism if you don't fancy using credentials for a trivial db.
[Corion]: hippo: Oooh, that sounds quite nice - let me read the documentation on that :)
[hippo]: https://www. docs/current/ static/auth- methods.html#AUTH- TRUST
[erix]: or compile & run an instance as yourself (not user 'postgres')
[erix]: easiest setup is to run with PG* env variables set, and a custom .pgpass files (can be a $PGPASSFILE)
[Corion]: Hmm - "trust" sounds interesting, but I have still to find whether I can restrict that on a per-DB level ;)

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2018-02-23 15:08 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (302 votes). Check out past polls.