On Thu, Sep 25, 2003 at 12:04:39AM -0700, Cory Bennett wrote:
> O'well, in typical fashion I found the answer to my own question.  There still 
> might be an easier way to do it, but perlintern helped with the padlist 
> walking:
> 
> ===
> my $VAR3 = "abc3";
> 
> use Inline C => q{
> #define PAD_LEN (av_len(PL_comppad_name) + 1)
>   SV * find_my_sv( char * name ) {
>     int i;
>     for( i=0; i < PAD_LEN; i++ ) {
>       AV ** elem = av_fetch(PL_comppad_name, i, FALSE);
>       if( elem && strEQ( SvPV(*elem,PL_na), "$VAR3" ) ) {
>         return PAD_SV(i);
>       }
>     }
>     return NULL;
>   }
> 
>   void func3() {
>     printf("VAR3 = %s\n", SvPV(find_my_sv("$VAR3"),PL_na));
>   }
> };
> 
> func3();
> ===

Which perl version(s) did you test this with?
I'm pretty sure that accessing the pads is not in any official API, and
the pad internals have changed for 5.8.1

You might also find some inspiration in the implementation of PadWalker:

http://search.cpan.org/author/ROBIN/PadWalker/

I don't think that Robin has updated it to cope with 5.8.1 yet
(although he's aware of the problem)

Nicholas Clark

Reply via email to