in reply to Poor Man's XML?
I second graff's suggestion. Why not just use XML, if you're going to be marking it up anyways?
Once you put it in XML, you can do bunch of cool things, plus you get the bonus of not having to write yet another parser.
use XML::LibXML; my $parser = XML::LibXML->new(); my $xml = $parser->parse_file( '/path/to/file' ); ## find all <speech>.. foreach my $speech ( $xml->findnodes( '/script/speech' ) { .... } ## find all speech by Romeo (assuming: ## <speech><character>Romeo</character><text>....</text></speech> ## ) foreach my $romeo_speech ( $xml->findnodes( '/script/speech/[charact +er = "Romeo"]' ) ) { .... } ## etc...
|
|---|