Re: BEGIN <> BEGIN



"Ferry Bolhar" <bol@xxxxxxxxxxxxxxxxx> wrote:
Hi,

I understand that a "use <module> <vars>;" is similar to

BEGIN {
require <module>;
<module>->import(<args>);
}

When writing BEGIN blocks myself and looking at the
compiled script with B::Deparse, I can see my BEGIN
blocks, but not the BEGIN blocks created by "use".

B::Deparse takes many options, you need to play with them.

$ perl -MO=Deparse,-x5 -e 'use CGI;'
sub BEGIN {
require CGI;
do {
'CGI'->import
};
}
-e syntax OK


Are these BEGIN blocks special in some way? Are
these actually BEGIN blocks or just blocks behaving
_similar_ to BEGIN blocks?

I'm not sure. B::Deparse does say that:

Note that in a few cases this translation can't be
perfectly carried back into the source code -- if the
loop's initializer declares a my variable, for
instance, it won't have the correct scope outside of
the loop.

I don't know if BEGIN blocks are another of those few cases or not.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
.



Relevant Pages

  • Re: Request for comment on my tiny learning project: dfighterdb (mytree)
    ... you may as well post the source code to the group. ... There's a chance someone who's writing a similar application ... the modem users amongst us, ... When I moved ISP, I left a ...
    (comp.lang.c)
  • Re: Request for comment on my tiny learning project: dfighterdb (mytree)
    ... you may as well post the source code to the group. ... relatively permanent existence in various Usenet archives. ... There's a chance someone who's writing a similar application ... My suggestion is to put your struct definitions in source files, ...
    (comp.lang.c)
  • RE: Value of Copyright
    ... State limitations in usage, state clearly that some parts shipped belongs to ... I've discussed the subject with customer a couple of times and they backed ... out of the idea of buying the source code when I told them that once the ... I have been asked to quote for writing a VB program for a potential one time ...
    (microsoft.public.vb.general.discussion)
  • Re: Writing text at an angle on a VB Form
    ... (without source code, of course) ... authors of the Windows font smoothing technology that is included with Win98 onwards or somene ... else who perhaps provides you with a third party solution) has to do the work for you if, ... you are incapable of writing the code yourself. ...
    (comp.lang.basic.visual.misc)
  • Re: Where do i start?
    ... Try looking at some of the C source code examples associated with an ARM ... > I am wanting to migrate to ARM and and wanting to start writing in C ...
    (comp.arch.embedded)