Re: suggestion for URI::GoogleChart

Gisle Aas <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.lwp
Message-ID <[email protected]>
Thanks for your suggestion!

I would like to avoid this kind of test.  First because that allow me
to use the native type names directly, and secondly because this allow
the module to support types that the web-service introduce after the
module was released.

I don't belive passing the wrong type will be a common error.  You
will need to test the generated URLs anyway and the error will be
discovered then.

--Gisle

On Wed, Jun 10, 2009 at 20:51, Jeff Stoner<[email protected]> wrote:
> URI::GoogleChart will pass $type through to the final URL, invalid chart
> types will cause Google to choke, eg.
>
> my $var = GoogleChart->new("fred", 300, 100, data => [45, 80, 99, 33]);
>
> produces
>
> http://chart.apis.google.com/chart?cht=fred&chs=300x100&chd=t:18.2,71.2,100,0
>
> To prevent users from passing an invalid chart type, I added this to the
> beginning of new()
>
> croak("Unsupported chart type") unless (grep /^$type$/, %TYPE_ALIAS);
>
>
> --Jeff
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.