Subject: | parsefile(): filename or a string check |
Date: | Mon, 22 Dec 2008 21:41:48 +0300 |
To: | bug-XML-Tiny [...] rt.cpan.org |
From: | sky08113 <sky08113 [...] yandex.ru> |
Release: XML-Tiny-1.11
Found here: http://search.cpan.org/dist/XML-Tiny/
Has error
=BUGGY=
if(ref($arg) eq '') { # we were passed a filename or a string
if($arg =~ /^_TINY_XML_STRING_(.*)/) { # it's a string
#--------------------------------------^ matches any character except
newline
#
# more efficient: rindex($arg, '_TINY_XML_STRING_', 0) or $file =
substr($arg, 17)
#
$file = $1;
} else {
local *FH;
open(FH, $arg) || die(__PACKAGE__."::parsefile: Can't open
$arg\n");
$file = <FH>;
close(FH);
}
} else { $file = <$arg>; }
#---------------------^ unsuspected value is possible
die("No elements\n") if (!defined($file) || $file =~ /^\s*$/);
--
Regards
Leon