I am using Carp along with Twig.PM, and I receive this error message, when using parsefile:
Missing base argument at /usr/lib/perl5/site_perl/5.6.0/HTTP/Request.pm line 107
As a test, I try parsing a simple segment of XML with parse, and receive this message:
Can't use string ("<doc><para>para1</para></doc>") as a symbol ref while "strict refs" in use at /usr/lib/perl5/site_perl/5.6.0/i386-linux/XML/Parser/Expat.pm line 456.

These errors only occur when Carp is turned on. Twig itself continues to work despite the error messages. Here's the code:
# aidbrowser.pm package aidbrowser; use CGI; use XML::Twig; BEGIN { $allaids = "FindingAids/"; %FullNames = ( "UMASS" => "University of Massachussetts", "Smith" => "Smith College", "MtHolyoke" => "Mt. Holyoke College", "Amherst" => "Amherst College", "Hampshire" => "Hampshire College", "MortimerRareBookRoom" => "Mortimer Rare Book Room, Smith Col +lege", "SophiaSmithCollection" => "Sophia Smith Collection, Smith Col +lege" ); return bless( { }, shift); } sub printDirs() { my $rets; my $content; opendir(THISDIR, $allaids) or die ("Couldn't open finding aids for +browsing!"); my @dircontents = grep !/^\./, readdir THISDIR; closedir(THISDIR); foreach $content (@dircontents) { if(-e $allaids.$content && -d $allaids.$content) { if($FullNames{$content}) { $rets .= p(h2($FullNames{$content}),br,printAids($content +)); } } } return $rets; } sub printAids() { my $aiddir = shift; my $eadid,$eadtitle,$eadauthor,$eadlastchng; opendir(AIDDIR, $allaids.$aiddir."/"); my @dircontents = grep !/^\./, readdir AIDDIR; closedir(AIDDIR); my $rets; if(!@dircontents) { $rets .= em("No finding aids for this institution are available +at this time."); } else { foreach $aid (@dircontents) { if($aid =~ /(\w+).xml/) { $eadid = $1; $rets .= p($eadid); $eadtitle = getAidTitle($allaids.$aiddir."/".$aid); $rets .= p("Title is $eadtitle"); } } } return $rets; } sub getAidTitle() { my $file = shift; my $twig = new XML::Twig(); $twig->parsefile($file); $elt = $twig->get_xpath("//titleproper",0) or "No title"; $elt = $twig->get_xpath('/ead/eadheader/filedesc/titlestmt/titlepro +per',0) or "Invalid title"; $text = $elt->text; $text=~ s/(^\s*|\s*$)//g; return $text; } sub browsingMenu() { return h1("Select a finding aid to open"), printDirs(); } 1;

In reply to Twig.PM and parsing by Comrade

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.