Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^3: disable functions if module not installed

by almut (Canon)
on Nov 03, 2008 at 22:51 UTC ( #721235=note: print w/replies, xml ) Need Help??


in reply to Re^2: disable functions if module not installed
in thread disable functions if module not installed

almut your code gave me an out of memory too.

Weird.  Can you just plain load the module with use Image::Magick; (or require Image::Magick;)?  In case the machine (or user limit) doesn't provide sufficient memory to load the module (which in theory could be possible), I'd expect that you get "out of memory" either way.

An example of one of these block eval's ?
eval { require Image::Magick }; my $is_magick = $@ ? 0 : 1;

Replies are listed 'Best First'.
Re^4: disable functions if module not installed
by lepetitalbert (Monsignor) on Nov 03, 2008 at 23:05 UTC

    Hi again

    use Image::Magick; works like a charm, am using it for weeks.

    eval { require Image::Magick }; my $is_Magick = $@ ? 0 : 1;

    produces out of memory too :(

    I have : XP, 2Gb ram, perl 5.10, IM 6.4.4-2, PerlMagick installed with IM installer

    Thanls again.

    "There is only one good, namely knowledge, and only one evil, namely ignorance." Socrates
      produces out of memory too

      This doesn't make much sense, as the eval { ... } is essentially also just loading the module (or trying to), only with fatal errors trapped.

      I have : XP, 2Gb ram, perl 5.10, IM 6.4.4-2, PerlMagick

      This is your web server machine, is it?

        hi almut,

        It's my notebook.

        Ok after a reboot

        #!/usr/bin/perl -w use strict; use warnings; eval { require Image::Magick }; my $is_Magick = $@ ? 0 : 1; print "Content-type: text/html; charset=ISO-8859-1\n\n"; print "<h1>$is_Magick</h1>";

        works.

        Found what send me out of memory : a use lib statement ?!

        Is that expected behaviour ?

        Time to sleep.

        Thanl you all :)

        Have a nice, nice day !

        "There is only one good, namely knowledge, and only one evil, namely ignorance." Socrates

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://721235]
help
Chatterbox?
[choroba]: The problem was bigger, as the test tried to call a method that didn't exist anymore
[marinersk]: :: ducking ::
[choroba]: because, someone renamed the method, but didn't notice it was used in the test, as the test was skipped
[marinersk]: Well, if the method doesn't exist, it would be hard to pass the test.
[choroba]: later, someone removed the new method, as all its usage places were safe, but didn't notice the test still used the old name
[choroba]: fortunately, it wasn't that hard to replace the method and fix a few remaining failures due to the changes we did to the codebase over the years
[marinersk]: choroba Sounds like a process improvement opportunity; tests may not all need to be run, but they should all be compiled with perl -c before check-in/promotion happens.
[choroba]: so, now I have the test, so I can start making changes in the code. Back to the original ticket, yay!
[marinersk]: I definitely love it when my $current_taask=& taskPop(); if ($current_task eq $original_task) { } is true.
[marinersk]: s/taask/task/g;

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (14)
As of 2017-05-25 15:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?