|
NAMEZML - A simple, fast, and easy to read binary data storage format.VERSIONVersion 1.0.0SYNOPSISThe error handling is unified between all methods. If $object->{error} is ever defined after a function is ran there has been an error. A description of the error can be found in $object->{errorString}. The error string is always defined, but set to "" when there is no error. The error is blanked after each run.use ZML; my $zml = ZML->new(); my $zmlstring="a=0\nb=1\n 2\n"; if ($zml->error){ print "Parsing the string failed with a error, ".$zml->{error}. ", ".$zml->{errorString}."\n"; }; ... METHODSnewCreates a new ZML object.my $ZMLobject=$ZML->new; addVarThis adds a new meta variable for a variable. Two values are required for it.The first variable is the name of the variable being added. The second is the meeta data. This can contain any character. $ZMLobject->addVar("some/variable", "whatever"); addCommentThis adds a new comment for a variable. Three values are required for it.The first variable is the name of the variable the comment is being added for. The second is the name of the comment. This also has to be a legit variable name. The third is the comment. This can contain any character. $ZMLobject->addComment("some/variable", "comment/variable","Some fragging comment."); addMetaThis adds a new meta variable for a variable. Three values are required for it.The first variable is the name of the variable the meta variable is being added for. The second is the meta variable. This also has to be a legit variable name. The third is the meeta data. This can contain any character. $ZMLobject->addMeta("some/variable", "meta/variable","whatever"); clearCommentThis removes a meta variable. Two values are required.The first is the variable name. $ZMLobject->clearComment("some/variable"); clearMetaThis removes a meta. Two values are required.This removes all meta values for a variable. $ZMLobject->clearMeta("some/variable"); delVarThis removes a variable. The only variable required is the name of the variable.$ZMLobject->delVar("some/variable"); delMetaThis removes a meta variable. Two values are required.The first is the variable name. The second is the meta variable. $ZMLobject->delMeta("some/variable", "meta variable"); delCommentThis removes a comment name. Two values are required.The first is the variable name. The second is the comment name. $ZMLobject->delMeta("some/variable", "comment name"); getVarGets a value of a variable.my @variables=$zml->getVar("some variable"); getMetaGets a value for a meta variable.my @variables=$zml->getVar("some variable", "some meta variable"); getCommentGets the value for a commentmy @variables=$zml->getComment("some variable", "some comment name"); keysVarThis gets a array containing the names of the variables.my @variables=$zml->keysVar(); keysMetaThis gets a list of variables with metas.my @variables=$zml->keysMeta(); keysCommentThis gets a list of comments.my @variables=$zml->keysComment(); keysMetaVarThis gets a list of variables for a meta. It required one variable, which is the name of the meta to get the meta variables for.my @variables=$zml->keysMetaVar("some variable"); keysCommentVarThis gets a list of comments for a variable. It requires one arguement, which is the variable to get the comments for.my @variables=$zml->keysCommentVar("some variable"); keyRegexDelCommentThis searches a the comments for a match and removes it.It requires two arguements. The first arguement is the regexp used to match the variable. The second is a regexp to match a name. #checks every meta for any meta variable matching /^monkey/ my %removed=keyRegexDelComment("", "^monkey") #prints the removed my @removedA=keys(%removed) my $removedInt=0; while(defined($removedA[$removedInt])){ my $mvInt=0; while(defined($removed{$removedA[$removedInt]})){ print $removed{$removedA[$removedInt]}[$mvInt]."\n"; $mvInt++; }; $removedInt++; }; keyRegexDelMetaThis searches a the metas for a match and removes it.It requires two arguements. The first arguement is the regexp used to match the meta. The second is the regexp used to match the meta variable. #checks every meta for any meta variable matching /^monkey/ my %removed=keyRegexDelMeta("", "^monkey") #prints the removed my @removedA=keys(%removed) my $removedInt=0; while(defined($removedA[$removedInt])){ my $mvInt=0; while(defined($removed{$removedA[$removedInt]})){ print $removed{$removedA[$removedInt]}[$mvInt]."\n"; $mvInt++; }; $removedInt++; }; keyRegexDelVarThis searches a the variables for a match and removes it.It requires one arguement, which is the regex to use. It returns a array of removed variables. #remove any variables starting with the word monkey my @removed=keyRegexDelVar("^monkey") parseThis parses a string in the ZML format. The only variable it requires is the string that contains the data.stringThis function creates a string out of a the object.my $string=$zml->string; valRegexDelCommentThis searches the comments for ones that have a value matching the regex.It requires one arguement, which is the regex to use. It returns a array of removed variables. #removes any variable in which the value matches /^monkey/ my %removed=keyRegexDelMeta("^monkey") #prints the removed my @removedA=keys(%removed) my $removedInt=0; while(defined($removedA[$removedInt])){ my $mvInt=0; while(defined($removed{$removedA[$removedInt]})){ print $removed{$removedA[$removedInt]}[$mvInt]."\n"; $mvInt++; }; $removedInt++; }; valRegexDelMetaThis searches the variables for ones that have a value matching the regex.It requires one arguement, which is the regex to use. It returns a array of removed variables. #removes any variable in which the value matches /^monkey/ my %removed=keyRegexDelMeta("^monkey") #prints the removed my @removedA=keys(%removed) my $removedInt=0; while(defined($removedA[$removedInt])){ my $mvInt=0; while(defined($removed{$removedA[$removedInt]})){ print $removed{$removedA[$removedInt]}[$mvInt]."\n"; $mvInt++; }; $removedInt++; }; valRegexDelVarThis searches the variables for ones that have a value matching the regex.It requires one arguement, which is the regex to use. It returns a array of removed variables. #remove any variables starting with the word monkey my @removed=valRegexDelVar("^monkey") varNameCheckThis checks a variable name to see if it is legit. It requires one variable, which the name of the variable. It returns two values.The first is a integer which represents the of the error. If it is false, there is no error. The second return is the string that describes the error. my ($legit, $errorString)=varNameCheck($name); ZML FORMATThere is no whitespace.A line starting with a " " is a continuation of the last variable. A line starting with ## indicates it is a comment. A line starting with a #! indicates it is a meta. Any line not starting with a /^#/ or " " is a variable. commentsA line starting with ## indicates it is a comment, as stated above.It is broken down into three parts, variable, comment name, and the value. Each is sperated by a "=". Any thing after the second "=" is considered to be part of the value. metaA line starting with #! indicates it is a comment, as stated above.It is broken down into three parts, meta, meta variable, and data. Each is sperated by a "=". The first field is the meta. The second is the meta variable. The third is the value. variableAny line not starting with a /^#/ or " " is a variable, as stated above.It is broken down into two parts seperated by a "=". Any thing after the "=" is considered part of the value. multi-line dataAny line matching /^ / is considered to be a continuation of the last value section of the value part of the variable. When a string is created s/\n/\n /g is ran over the value to transform it to a storable state.variable namingA variable name is considered non-legit if it matches any of the following regexs./,/ /\/\./ /\/\// /\.\.\// /\/\.\./ /^\.\// /\/$/ /^\// /\n/ /=/ ERROR HANDLING/CODESThis module uses Error::Helper for error handling. Below are the error codes returned by the error method.1The variable name matches /\/\./.2The variable name matches /\/\//.3The variable name matches /\.\.\//.4The variable name matches /\/\.\./.5The variable name matches /^\.\//.6The variable name matches /\/$/.7The variable name matches /^\//.8The variable name matches /\n/.9The variable name matches /=/.10Undefined variable.11This means the variable name matches /,/.AUTHORZane C. Bowers-Hadley, "<vvelox at vvelox.net>"BUGSPlease report any bugs or feature requests to "bug-zml at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=ZML>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.SUPPORTYou can find documentation for this module with the perldoc command.perldoc ZML You can also look for information at:
COPYRIGHT & LICENSECopyright 2012 Zane C. Bowers-Hadley, all rights reserved.This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Visit the GSP FreeBSD Man Page Interface. |