in reply to Re: Re: Re: method of ID'ing
in thread method of ID'ing
how about adding require Tie::Scalar
There's not much point in having a base class if you override all methods :) Well, I don't use new() and DESTROY(), but those are rather optional...
and throwing this in the code catacombs? this is a nice, simple answer to retrieving the current time.
It doesn't belong there. This use should not be encouraged, just use time instead. This was a one-minute hack, typed in my browser. If you think it belongs there, go ahead, there is no copyright at all :)
While you're at it, create these as well:
Have a look at perlfunc for more ideas. Or just use a one-fits all tie:package Tie::Print; require Tie::Scalar; our @ISA = ('Tie::StdScalar'); sub STORE { print pop } package Tie::Localtime::Scalar; require Tie::Scalar; our @ISA = ('Tie::StdScalar'); sub FETCH { return scalar localtime } etcetera
Which can be used like:package Tie::Scalar::Miscellaneous; use Carp; use strict; sub TIESCALAR { my ($class, %functions) = @_; $_ ||= q(croak 'Not implemented') for @functions{qw/store fetch/}; $_ = eval "sub { $_ ( \@_ ) }" for @functions{qw/store fetch/}; bless \%functions, $class; } sub STORE { shift->{store}->(pop) } sub FETCH { shift->{fetch}->(); }
No, I'm not being serious.tie my $printer, 'Tie::Scalar::Miscellaneous', store => 'print'; $printer = "Hello, world!\n";
- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: method of ID'ing
by particle (Vicar) on Apr 14, 2002 at 15:25 UTC |