- File Handling Methods
- Text Access Methods
- Converting Methods
- Formatting Methods
- Interactive Editing Methods
- Class Methods
PBib::Document - Abstract Base and Factory class for Documents
use PBib::Document; my $doc = new PBib::Document( 'filename' => $filename, 'mode' => 'r', 'verbose' => 1, ); print $doc->filename(); my @paragraphs = $doc->paragraphs(); $doc->close();
Factory class to create documents that are processed by PBib.
- $doc = new PBib::Document('filename' => $filename);
Arguments are passed as hash:
- filename => string for filename
- class => document class to use, e.g. 'RTF' or 'MSWord'
If class is not defined, it is tried to be guessed by looking at the file. (Currently, the filename's extension only.)
- formatOptions => hash with options passed to ReferenceFormator
- bibitemOptions => hash with options passed to BibItemFormator
- converter => string for ReferenceConverter class
- formator => string for ReferenceFormator class
- mode => "r" | "w"
Mode for this document, used to open the file. "r" = Read, "w" = Write
- verbose => If true, produce more verbose output.
- $filename = $doc->filename();
Return the document's filename.
- $handle = $doc->handle();
Return the document's Perl FileHandle.
Caution: This method might not be used by all subclasses of PBib::Document.
Return the document's encoding.
Returns undef if not specified.
Close the file.
Read the document from disk. Return the content of the document in a format internal to the document class. (Per default a ref to an array of the lines.)
Write the document back to disk, if the document has been opened and it contains paragraphs().
- $boolean = $doc->exists()
Check, if this document is exists, independent of being accessable. (Perl's -f test)
- $boolean = $doc->isValid()
Check, if this document is ok, e.g. if the file exists and can be accessed. (Perl's -w or -r, depending on $doc->mode()
Methods used by PBib to access the document.
- $inDoc->processParagraphs($func, $rc, $outDoc, @_)
Process all paragraphs of the $inDoc by calling $func. If $outDoc is defined, the result of the function call is added to $outDoc.
The default implementation assumes a linear sequence of paragraphs, using $inDoc's paragraphCount() and getParagraph().
$func is called on $rc with the current paragraph, its index and @_ as parameters:
$par = $rc->$func($par, $i, @_);
- $int = $doc->paragraphCount();
Return the number of paragraphs in document.
- $string = $doc->getParagraph($int);
Return the paragraph with index $int
- @strings = $doc->paragraphs()
Return all paragraphs in document as an array with all paragraphs as plain (ascii) strings.
Calles $doc->read() if the file has not been read before.
- $doc->addParagraph($str1, $str2, ...), $doc->addParagraphs($str1, $str2, ...)
Append paragraphs to document.
Methods used by PBib::ReferenceConverter::convert().
Do anything you want to before being converted. (Hook for subclasses.) The document object that is returned is used for conversion.
This is called by PBib::ReferenceConverter::convert() on the input document with $conv as the current converter.
Do anything you want to after being converted. (Hook for subclasses.) The object that is returned is used for further processing.
This is called by PBib::ReferenceConverter::convert() on the output document with $conv as the current converter.
Methods used by PBib to create formatted text.
Methods used by PBib for interactive editing of documents, e.g. open in editor.