Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

perlembed - global variables

by jithoosin (Scribe)
on Dec 26, 2005 at 14:12 UTC ( #519144=perlquestion: print w/replies, xml ) Need Help??

jithoosin has asked for the wisdom of the Perl Monks concerning the following question:

 
From 
     Kiran Pradeep
     Perl Beginner
     
To
     The Monks
     Perl Monastry
     The Earth 
     Solar System
Respected Monks,
I am calling a perl subroutines in a perl file repeatedly from a C file.My question is that if i have GLOBAL variables in the perl file ,will the value of global variables be retained between each of function calls from the C file. I also want to when the global variables will actually be initialized? Are they initialized when i call "perl_parse" or "perl_run" or when i call "perl_argv"?

Replies are listed 'Best First'.
Re: perlembed Ė global variables
by Aristotle (Chancellor) on Dec 26, 2005 at 15:17 UTC

    Caveat lector: I donít know what Iím talking about, because I havenít written any code that embeds a Perl interpreter.

    That said, if the embedding interface works the way I would intuitively expect it from my experience with the way things work when writing Perl that runs in a standalone interpreter then global variables are initialised when the code that initialises them runs, which is usually part of the file-level code, so that would be when you call perl_run; however, if the initialisation is within BEGIN blocks or such, it will happen when you call perl_parse.

    And if mod_perl is any indication, then global variables are retained between function calls.

    Makeshifts last the longest.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://519144]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2023-01-29 15:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?