> -----Original Message-----
> From: Beckett Richard-qswi266 [mailto:[EMAIL PROTECTED]] 
> Sent: Tuesday, February 18, 2003 10:07 AM
> To: [EMAIL PROTECTED]
> Subject: RE: Trouble with my variables.
> 
> 
> Still having harassments...
> 
> I now invoke the sub thusly...
> 
> update_value("ftp", $ftp{$key}{value}, $key);
> 
> The sub is like this...
> 
> sub update_value {
>       $entry{$_[0]}{$key} -> delete (0, "end");
>       $entry{$_[0]}{$key} -> insert ("end", $_[1]);
> }
> 
> I get:
> 
> Global symbol "$key" requires explicit package name at 
> v06b.pl line 1561. Global symbol "$key" requires explicit 
> package name at v06b.pl line 1562. Execution of v06b.pl 
> aborted due to compilation errors.
> 
> If I use $_[2] instead of $key, then it works. Is there a way 
> of passing $key as $key to the sub?
> 
> Thanks.
> 
> R.

The reason $key won't work is that if you want it to, you'll have to
create a new local variable called $key inside the sub...change the
subroutine like so:

sub update_value {
        $key = $_[2];
        $entry{$_[0]}{$key} -> delete (0, "end");
        $entry{$_[0]}{$key} -> insert ("end", $_[1]);
}

Note that it'll take a little extra time and memory to copy $_[2] to
another variable, but since I don't know why you want to do it, I can't
advise on whether you should bother or not.



perl -e "sub Sub{return reverse(@_);}$i='ohce';$_='.$yyye k ca i Xl
$yyye jX $yyyehto ZfX tq $uQ';s+[ \$]++g;s-j-P-;s^yyy^r^g;s:i:H:;s!X!
!g;s|Z|n|;s*Q*J*;s{q}{s}g;s(f)(A);system(join('',Sub(split('',$i))),(joi
n('',Sub(split('')))));"

To the optimist, the glass is half full.
To the pessimist, the glass is half empty.
To the engineer, the glass is twice as big as it needs to be. 

Adrian "Okay, I won't top-post unless it's an emergency" Stovall 
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to