Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: 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 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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-18 18:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found