Popcorn Dave has asked for the wisdom of the Perl Monks concerning the following question:
My question is, that I've tied two different variables to two different modules ( please excuse me if my terminology isn't quite right, I'm still learning this bit ). Is it permissible to tie to two different modules?
My problem is arising in that I'm passing a scalar in to the module, in to a referenced scalar, but I can't get it to do anything to the values. My code is:
package Celcius; #use strict; sub TIESCALAR{ my $class=shift; my $data=shift; return bless \$data, $class; } sub STORE{ my $self=shift; my $data=shift; return ($$data*(9/5)+32); } sub FETCH{ my $self=shift; my $data=shift; return $$data; } 1;
Can someone please tell me what I'm missing here? I've looked in a few different perl books, but since there's more than one way to do things, I've gotten a few different examples of code - none of which are the same - and I'm stumped at present.
Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problems using ties
by RMGir (Prior) on Apr 18, 2002 at 19:26 UTC | |
|
Re: Problems using ties
by Popcorn Dave (Abbot) on Apr 18, 2002 at 23:25 UTC |