By: James Reynolds - Revised: 2014-01-23 richard


PerlObjCBridge & plist Files - by James Reynolds
This presentation will show how to use the PerlObjCBridge to read plist files in Perl scripts.

plist files are used by Mac OS X to organize data as effectively as possible.  It strives to be human readable, easy to use, easy to store, and be a burden on the computer.  It can be stored or displayed as XML, binary, and an old NeXT format (the human readable form before XML).  The data contained in plist files consists of the data types in the Core Foundation framework, but are typical to all programming languages: strings, numbers, booleans, dates, data, arrays, and dictionaries.  The structure of plist files revolves around arrays (numbered list) and dictionaries (key-value list).

Mac OS X uses plist files to configure networking, store application preferences, replace a lot of the resource fork functionality of Classic, and will be used even more in the future.  Although some 3rd party applications have their own data formats for storing information, and the Unix side of Mac OS X relies on plain text configuration files, the plist format is the dominant method of storing data on Mac OS X.

Cocoa applications can read and write plist files very easily.  The defaults and plistBuddy commands lets you perform read and write plist files from the command line and scripts.  Ruby and Python both have methods of reading and writing plist files as well.  For a long time I had a hard time editing plist files with Perl.  The PerlObjCBridge lets Perl scripts run Cocoa code, which means they now can access plist files as easily as Cocoa applications.