diff options
author | H.Merijn Brand - Tux <linux@tux.freedom.nl> | 2024-01-02 22:25:01 +0100 |
---|---|---|
committer | H.Merijn Brand - Tux <linux@tux.freedom.nl> | 2024-01-02 22:25:01 +0100 |
commit | ce19b40b67248edf9dc80a729166537188d85ffe (patch) | |
tree | 6f4d0212f7a2d4f953317961f92375e0cea07c10 | |
parent | 4ab3da176452af5c88ab65b1c794837ebfc1be10 (diff) |
Consistent return value for parses ($type) on failure
-rw-r--r-- | Changes | 3 | ||||
-rwxr-xr-x | Read.pm | 17 | ||||
-rw-r--r-- | t/10_basics.t | 2 |
3 files changed, 13 insertions, 9 deletions
@@ -1,3 +1,6 @@ +0.90 - 02 Jan 2024, H.Merijn Brand + * Consistent return value for parses ($type) on failure + 0.89 - 02 Jan 2024, H.Merijn Brand * Auto-use BOM in CSV *files* with xlscat script * Fix duplicate option letter (typo) (Erix) @@ -38,7 +38,7 @@ use 5.008001; use strict; use warnings; -our $VERSION = "0.89"; +our $VERSION = "0.90"; sub Version { $VERSION } use Carp; @@ -257,7 +257,7 @@ sub parses { $@ = $1; return 0; } - return $can{$type}; + return $can{$type} || 0; } # parses sub sheets { @@ -2003,14 +2003,15 @@ use argument list, or call it fully qualified. $book->parses ("CSV"); # OO C<parses ()> returns Spreadsheet::Read's capability to parse the -required format. L<C<ReadData>|/ReadData> will pick its preferred parser -for that format unless overruled. See L<C<parser>|/parser>. +required format or C<0> if it does not. L<C<ReadData>|/ReadData> +will pick its preferred parser for that format unless overruled. +See L<C<parser>|/parser>. -C<parses ()> is not imported by default, so either specify it in the -use argument list, or call it fully qualified. +C<parses ()> is not imported by default, so either specify it in +the use argument list, or call it fully qualified. -If C<$format> is false (C<undef>, C<"">, or C<0>), C<parses ()> will -return a sorted list of supported types. +If C<$format> is false (C<undef>, C<"">, or C<0>), C<parses ()> +will return a sorted list of supported types. @my types = parses (""); # e.g: csv, ods, sc, sxc, xls, xlsx diff --git a/t/10_basics.t b/t/10_basics.t index a394eb2..7eda35e 100644 --- a/t/10_basics.t +++ b/t/10_basics.t @@ -14,7 +14,7 @@ ok (my @ext = parses (undef), "No sheet type"); is_deeply ([ grep m/^sc/ => @ext ], [ "sc" ], "Supports Squirrelcalc"); is (parses ("zzz0"), 0, "Unknown sheet type"); -is (parses ("zzz1"), "", "Too old sheet type"); +is (parses ("zzz1"), 0, "Too old sheet type"); is (parses ("zzz2"), "Z20::Just::For::Testing", "Testing sheet type"); is (parses ("zzz3"), 0, "Unsupported sheet type"); |