Good morning Monks,

I am working on a script that will output datasets which users at astronomical observatories can then pick up and plot, say with OpenOffice (or Excel, or what have you).

It has to be pretty generic, that is,

1) the fields in the data have to be pretty dependably common to any of the environments where this script might be used;

2) the default output is just tab-delimited text files.

So far, so easy; however, what is giving me pause is

3) no non-core modules should be required. We can't predict what users will have nor whether they will be allowed to install anything ...

... what I'd like to do is code up routines that will actually go ahead and do graphical plotting if the user has the GD::Graph module installed, but still output the plain text files if s/he doesn't.

So I am thinking I should be able to have the script test whether GD::Graph is installed and, if it isn't, to print a useful message (a suggestion that the user install the module, say) ... but then to continue and generate the plain text files.

I have tried using eval, as follows:

eval { use Fictitious::Module }; print "run anyway\n" if $@;

... but this doesn't work: I don't seem to be able to get around the complaint that Fictitious::Module is not found.

Is there a clean way to do this?


In reply to Base script behavior on presence (or non-) of a module by chexmix

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.