开发者

How to check, is excel plugin enabled in PERL

开发者 https://www.devze.com 2023-02-03 03:43 出处:网络
Am just started working for exporting excel spread shee开发者_运维百科t in PERL, Before start i want confirmation, that is, is excel spread sheet realted plug is enabled or not,

Am just started working for exporting excel spread shee开发者_运维百科t in PERL,

Before start i want confirmation, that is, is excel spread sheet realted plug is enabled or not,

Advise some simple PERL syntax ,

Thanks


If you are using a module from CPAN such as Excel::Writer::XLSX then you can just use a simple script to test if the module is installed:

#!/usr/bin/perl
use Excel::Writer::XLSX;

And run that script. You'll get an error about

Can't locate Excel/Writer/XLSX.pm in @INC

if the module is not installed on your system.


If by "excel plugin" you mean a CPAN module, then the solution is to try to load it and see what happens. If you wrap the loading attempt in an "eval" statement then your program won't die if it fails.

Something like this:

eval 'use Spreadsheet::ParseExcel';

my $have_module = ! $@;

This method is a little imprecise as I'm just looking to see if $@ has been given a value. For more control, you might want to check the contents of $@ for specific error message. You're looking for one that starts "Can't locate ...".


Assuming you mean:

How can I tell if an Excel document delivered from my webserver to a browser will open in a browser plugin (as opposed to being saved or opened in a standalone application)?

Then you can't. Browsers don't send that information to the server, so no server side process (written in Perl or otherwise) can tell.


perl -MExcel::Writer::XLSX -e "print 'ok'"

If it prints 'ok' then you're good. If you get a can't locate ... in @INC then you need to install it.

0

精彩评论

暂无评论...
验证码 换一张
取 消