Re: perl 5.10 questions

2007-04-04 Thread oryann9


> But this is all fairly complicated stuff and
> probably a little advanced
> for a beginners list.  You might find more joy
> asking on
> comp.lang.perl.moderated, or perlmonks.
> 
> -- 
> Paul Johnson - [EMAIL PROTECTED]


yes but there are a lot of advanced members on the
list. ok thanks for responding!


 

Sucker-punch spam with award-winning protection. 
Try the free Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/features_spam.html

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




Re: perl 5.10 questions

2007-04-03 Thread Paul Johnson
On Tue, Apr 03, 2007 at 11:44:33AM -0700, oryann9 wrote:

> In "The Perl Review" spring 07 page 10 it states:
> 
> "With Perl 5.10 I can write my own lexical pragmas.

That should probably be in the future tense, since Perl 5.10 hasn't been
released yet.  But it's fairly close.  I suppose it's in a fairly
squelchy sort of feature slush at the moment.

But you can try these things out with Perl 5.9.4 or bleadperl (the
latest development sources) if you are feeling adventurous.

> 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?

The optree is the tree of ops to which your program is compiled before
it is executed.  It basically tells perl how to run your program.

> 2) What is the official name for %^H

I think %^H probably is the official name.  You could also call it the
hints hash, I suppose, which rolls off the tongue a little easier.

> 3) Using caller, what is element 10 in the code below?
>I looked in Programming Perl (w/out hope) and did
>not find it.

The feature is newer than any edition of Programming Perl.  There is
documentation in the bleadperl sources, but probably nowhere else.

Element 10 is a reference to a hash containing the values of %^H when
the code was compiled.  This is your runtime interface to the lexical
pragma.

But this is all fairly complicated stuff and probably a little advanced
for a beginners list.  You might find more joy asking on
comp.lang.perl.moderated, or perlmonks.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

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




perl 5.10 questions

2007-04-03 Thread oryann9
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/