in reply to Access to tied variable in the tie constructor???

You can pass additional arguments to tie, like this:
package TestTie;
sub TIESCALAR{
    my ($pkg, $object) = @_;
    my $obj=[] ;
    bless $obj, $package;
    print "$$object\n";
    return $obj;
}
package main;
my $t=9;
tie $t, 'TestTie', \$t;

hth, g
  • Comment on RE: Access to tied variable in the tie constructor???

Replies are listed 'Best First'.
RE: RE: Access to tied variable in the tie constructor???
by lhoward (Vicar) on May 27, 2000 at 16:07 UTC
    I know that I can pass additional arguments to the tie, but I don't think I should have to. In my example $t is already an argument to the tie call and I don't want to have to pass it again. IMHO it looks redundant and un-clean to require the user of the tie to pass the tie variable twice and have the code look like:
    tie $t, 'TestTie', \$t;