|new( VALUE )||Create the object.|
|value||Access the value of the object. At the moment you cannot change the value|
|type||Access the type of the object (string, data, etc)|
|write||Create a string version of the object, recursively if necessary.|
|as_perl||Turn the plist data structure, which is decorated with extra information, into a lean Perl data structure without the value type information or blessed objects.|
These functions are available for individual or group import. Nothing will be imported unless you ask for it.
use Mac::PropertyList qw( parse_plist ); use Mac::PropertyList qw( :all );
parse_plist( TEXT ) Parse the XML plist in TEXT and return the Mac::PropertyList object. parse_plist_fh( FILEHANDLE ) Parse the XML plist from FILEHANDLE and return the Mac::PropertyList data structure. Returns false if the arguments is not a reference.
You can do this in a couple of ways. You can open the file with a lexical filehandle (since Perl 5.6).
open my( $fh ), $file or die "..."; parse_plist_fh( $fh );
Or, you can use a bareword filehandle and pass a reference to its typeglob. I dont recommmend this unless you are using an older Perl.
open FILE, $file or die "..."; parse_plist_fh( \*FILE );
parse_plist_file( FILE_PATH ) Parse the XML plist in FILE_PATH and return the Mac::PropertyList data structure. Returns false if the file does not exist.
Alternately, you can pass a filehandle reference, but that just calls parse_plist_fh for you.
create_from_hash( HASH_REF ) Create a plist dictionary from the hash reference.
The values of the hash can only be simple scalarsXnot references. Reference values are silently ignored.
Returns a string representing the hash in the plist format.
create_from_array( ARRAY_REF ) Create a plist array from the array reference.
The values of the array can only be simple scalarsXnot references. Reference values are silently ignored.
Returns a string representing the array in the plist format.
read_string read_data read_integer read_date read_real read_true read_false Reads a certain sort of property list data read_next Read the next data item read_dict Read a dictionary read_array Read an array plist_as_string Return the plist data structure as XML in the Mac Property List format. plist_as_perl Return the plist data structure as an unblessed Perl data structure. There wont be any Mac::PropertyList objects in the results. This is really just as_perl.
This project is in Github:
Thanks to Chris Nandor for general Mac kung fu and Chad Walker for help figuring out the recursion for nested structures.
Mike Ciul provided some classes for the different input modes, and these allow us to optimize the parsing code for each of those.
Ricardo Signes added the as_basic_types() methods so you can dump all the plist junk and just play with the data.
* change the value of an object
* validate the values of objects (date, integer)
* methods to add to containers (dict, array)
* do this from a filehandle or a scalar reference instead of a scalar
+ generate closures to handle the work.
brian d foy, <firstname.lastname@example.org>
Copyright X 2004-2014 brian d foy. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
|perl v5.20.3||MAC::PROPERTYLIST (3)||2014-09-12|