[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] $^O stickiness



According to Chris Nandor:
> 
> I don't follow.  Global variables work that way, yes.  But that has nothing
> to do with separate invocations of the program.  $^X is a global as well,
> but does not work in the same way:

(Now this might be totally wrong since I do not work on the
internals of Perl/MacPerl.  I'm just putting this forth
since it makes sense to me that what you are describing
would happen.)

Ok, let's take it like this:

Let's say that when you invoke MacPerl you are actually
executing a program who's main loop is to just sit there
and do nothing until you tell it otherwise.

Then let's say that when you execute a program, that
program is loaded into MacPerl in the same fashion as if
you did this:

myProgram.cgi:
#!perl
	require "myProgram.pl";
	exit( 0 );

myProgram.pl:
#
#	Your actual program goes here.
#

Then what would happen is that any of the global variables
defined within the "myProgram.cgi" part would also be
globally defined within the "myProgram.pl" part.

Ok, to relate this back to the $^O problem:

When MacPerl is executed, a set of global variables is
defined and then MacPerl goes into a cycle which simply
waits for a command and, if none is forthcoming, it acts
nice and lets the MacOS do something.  This cycle continues
until you say to execute a program.  MacPerl then loads
that program into memory and jumps to the beginning of the
program.  However, it doesn't re-initialize the globally
defined variables because that is done when MacPerl is
first loaded.  Once defined, all of the $<whatever> special
variables are simply used.

I would suspect the reason for this behavior is because
under Unix Perl is loaded in each time and each time it is
a unique process.  So this type of behavior has never come
up before.  Or rather I should say - it has never been
noticed before.  But it is a logical extension to how Perl
works.  I had seen something like this before with the $|
command, but just took it as that was how Perl was supposed
to run under the Mac's OS.  Probably a bad assumption on my
part - but I didn't really care.

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch