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

Re: [MacPerl] Any way to Tee in MacPerl?



At 11.17 1998.02.13, Mark Manning/Muniz Eng. wrote:
>The solution presented (the subroutine) should work ok.
>You do not even have to pass in the FILE1 and FILE2 as long
>as you create them in the main program.  This is because
>those variables are global to all other programs.
>Actually, now that I think about it, if you don't put the
>words LOCAL or MY in front of a variable in a subprogram it
>automatically becomes globally defined.  So you could
>create FILE1 and FILE2 anywhere you want and they would be
>usable by the subroutine.

This is not really a MacPerl issue, but I need to correct some
misinformation here.  local() variables are global.  my() variables are
lexical (local, not local()).  A local() variable simply saves the value of
a global variable, and restores that value to that variable when the
dynamic scope of the local() variable exits.

Filehandles are global, and belong to package main.

#!perl -wl
use Data::Dumper;
print Dumper(\%main::);
package A;
use Data::Dumper;
print STDOUT "hi\n";
print Dumper(\%A::);

As you can see here, STDOUT is in %main::, but not in %A::, yet you can
still print to STDOUT from A without specifying main.  Special variables
($^O, $\, etc.) are also globals that belong to main, and are accessible
without qualification from any package.

If you want more information on this, let me know in private e-mail, and I
can point you in the right direction or explain it further.

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])
#==               New Book:  MacPerl: Power and Ease               ==#
#==    Publishing Date: Early 1998. http://www.ptf.com/macperl/    ==#



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