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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I didn't test it but INIT kicks in when everything is finished compiling, perlsub -
"INIT" blocks are run just before the Perl runtime begins execution, in "first in, first out" (FIFO) order. For example, the code generators documented in perlcc make use of "INIT" blocks to initialize and resolve pointers to XSUBs.

So various modules can register INIT blocks. The INIT blocks are all postponed until just before perl starts executing, at which point it runs all the INIT blocks in the order they were registered and then finally it goes to line 1 of your program.

$@ is the only place where an error from an eval will show up, if you don't do something about it, the error will disappear forever, that's what makes it possible to ignore an error with eval. Of course if there is something wrong with the module and we ignore the error, the program will probably fail anyway however it will fail with a confusing error message. For example if mod.pm is

package mod; sub foo{ print "hello world\n; # eek! missing a double quote } 1;
and we do
eval "use mod"; mod::foo();
we get
Undefined subroutine &mod::foo called at - line 2.
because foo didn't compile however what we really want is
eval "use mod"; die $@ if $@; mod::foo();
Can't find string terminator '"' anywhere before EOF at mod.pm line 3.
Compilation failed in require at (eval 1) line 2.
BEGIN failed--compilation aborted at (eval 1) line 2.

In reply to Re^3: interface.pm explained by fergal
in thread interface.pm explained by gaal

Title:
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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-16 18:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found