Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
It's really hard to pin down what your problem might be because you're not actually showing any of the code that calls these functions. I'd guess that the problem is you just aren't initializing %ENGINES before you start calling subroutines that use it.

Your use of strict and our is broken, however. Because they are both in a BEGIN block the scope of both is confined to just that block, making them essentially useless.

It's best to have use strict (and probably a use warnings) at the top of your code, outside of any block. The declaration for %ENGINES could be at the top, if you like, but I prefer to have the 'our' declaration near where I actually use the variable. If you intend to initialize %ENGINES at module startup then putting the declaration in a block can be a good idea.

package Data::CryptRecord; use warnings; use strict; { our %ENGINES = (...); } sub set_engine { my($self, $name) = @_; our %ENGINES; ... }

This provides some self-documentation; it's clear that %ENGINES is global. You can also initialize %ENGINES outside a block, and not have to declare it in your subroutines.

In reply to Re: Perl Riddle by Somni
in thread Perl Riddle by lesage

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-04-22 09:30 GMT
Find Nodes?
    Voting Booth?

    No recent polls found