I forgot to mention
my $IMAGE_SIZE=eval{require Image::Size};
...
if ($IMAGE_SIZE) {
my ($x, $y) = Image::Size::imgsize($imagen); ###Call the function
with the module
}else{
### More code
### Runs if it's not installed
}
-rm-
----- Original Message -----
From: "Ramon Chavez" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, July 13, 2004 1:13 PM
Subject: Re: use module only if it exists
> Hi.
> This may be not a high enlightened answer but has solved me some time
> looking for an answer to a question like yours:
>
>
> my $IMAGE_SIZE=eval{require Image::Size};
> ...
> if ($IMAGE_SIZE) {
> ### Some code
> ### Runs only if Image::Size is installed
> }else{
> ### More code
> ### Runs if it's not installed
> }
>
>
> HTH
>
> -rm-
>
>
> ----- Original Message -----
> From: "perl.org" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, July 13, 2004 12:39 PM
> Subject: use module only if it exists
>
>
> > I want my code to call some subroutines in a custom module only if that
> module
> > exists on the system. I can think of at least three techniques to
> determine
> > if the module exists: scan @INC, use UNIVERSAL::can (not sure that would
> > work), or put the code in an eval block. What is the best solution? I
> think
> > an eval block sounds right, but I'm not sure. My guess would look
> something like:
> >
> > eval
> > {
> > use module;
> > module::subroutine();
> > };
> >
> > But the use statement of course throws a compiler error, so I think the
> > appropriate thing is to put this code into a string and eval that. But
> this
> > code is going to get replicated to a large number of files and I want
the
> > shortest syntax possible, or if there is some better way...
> >
> > TIA,
> >
> > -John
> >
> >
> >
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > <http://learn.perl.org/> <http://learn.perl.org/first-response>
> >
> >
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>