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