Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Replacing If Elsif Else with Hash

by johnfl68 (Beadle)
on Nov 24, 2012 at 08:51 UTC ( #1005345=note: print w/ replies, xml ) Need Help??


in reply to Re: Replacing If Elsif Else with Hash
in thread Replacing If Elsif Else with Hash

To be honest, I am not exactly sure. The portion of code involves some simple Image::Magick and would run, but would not write the final output image from the external subroutine. I spent most of the day trying to figure out why the image wasn't being created.

I ended up slowly rebuilding the subroutine with small portions, and running with each small addition until the point when the image wasn't being written again, and it turned out to be the if elsif else portion. In the end, I had a subroutine with exactly the same code, with everything except that section.

I use strict and warnings, nothing ever showed up, so I can only assume there was some sort of collision with Image::Magick but not sure what. I even tried changing both $severity and $background to different string names, at first thinking maybe one of them was colliding with something, but still, no image would be written.

With both the hash version I did, and the one suggested by frozenwithjoy, they both work fine in the external sub.

I am still curious as to why it did not work that way, but in the end I am happy that I was at least able to track down what part of the code was causing the problem, and find a solution.


Comment on Re^2: Replacing If Elsif Else with Hash
Re^3: Replacing If Elsif Else with Hash
by roboticus (Canon) on Nov 24, 2012 at 14:05 UTC

    johnfl68:

    If everything worked find (i.e. no error messages, etc.) and if failed only because of the addition of the if/else block, then I think I'd suspect one or more of your braces was a line too high or too low, causing the code to be bypassed or some such. Pure speculation, though.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1005345]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2014-08-29 04:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (275 votes), past polls