In "The Perl Review" spring 07 page 10 it states:

"With Perl 5.10 I can write my own lexical pragmas.
In fact, feature was implemented this way. The
%^H special variable lets me attach "references" to
the optree, which I can then inspect with caller.
Perl passes this information as a new item in the
return list for caller: a hash reference of pragma
settings."

Questions:
1) What is the optree and how is it useful?
2) What is the official name for %^H
3) Using caller, what is element 10 in the code below?
   I looked in Programming Perl (w/out hope) and did
   not find it.

($package, $filename, $line, $subr, $has_args,
$wantarray )= caller($i);
#   0         1         2       3       4          5


CODE AS BELOW:

package foomagazin;
use feature qw(say ~~);
sub import{
   $^H{german} = 1 if @_ ~~ 'german';
}

sub unimport{
   $^H{german} = 0 if @_ ~~ 'german';
}

sub hello_world{
   my $hash = (caller(0))[10];
   if( $hash->{german} ) {
      say "Hallo Welt!";
   }
   else {
      say "Hello World!";
   }
}
1;

thank you


 
____________________________________________________________________________________
It's here! Your new message!  
Get new email alerts with the free Yahoo! Toolbar.
http://tools.search.yahoo.com/toolbar/features/mail/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to