Skip Menu |

This queue is for tickets about the XML-Twig CPAN distribution.

Report information
The Basics
Id: 97461
Status: patched
Priority: 0/
Queue: XML-Twig

People
Owner: MIROD [...] cpan.org
Requestors: SREZIC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: (no value)
Fixed in: (no value)



Subject: Confusing error message if using parse() on a filehandle
The following command (which deliberately works on an invalid XML file) gives a confusing error message: $ perl -MXML::Twig -e 'XML::Twig->new->parse(do { open my $fh, "$ENV{HOME}/.bashrc"; $fh })' you seem to have used the parse method on a filename (GLOB(0x190f860)), you probably want parsefile instead at -e line 1. Obviously the input parameter was a filehandle, not a filename as stated in the error message. Problem is that the -f operator may work also on filehandles, so cannot be used to check whether a filename or filehandle was provided. Try: $ perl -e 'warn -f "$ENV{HOME}/.bashrc"' 1 at -e line 1. Regards, Slaven
OK, it's fixed in the development version. The fix is to test whether the argument to parse is a GLOB before returning the error message. Thanks for the report. -- mirod On Thu Jul 24 10:50:34 2014, SREZIC wrote: Show quoted text
> The following command (which deliberately works on an invalid XML > file) gives a confusing error message: > > $ perl -MXML::Twig -e 'XML::Twig->new->parse(do { open my $fh, > "$ENV{HOME}/.bashrc"; $fh })' > you seem to have used the parse method on a filename > (GLOB(0x190f860)), you probably want parsefile instead at -e line 1. > > Obviously the input parameter was a filehandle, not a filename as > stated in the error message. > > Problem is that the -f operator may work also on filehandles, so > cannot be used to check whether a filename or filehandle was provided. > Try: > > $ perl -e 'warn -f "$ENV{HOME}/.bashrc"' > 1 at -e line 1. > > Regards, > Slaven
-- __ mirod