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:

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
Have a look at perlfunc for more ideas. Or just use a one-fits all tie:
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}->(); }
Which can be used like:
tie my $printer, 'Tie::Scalar::Miscellaneous', store => 'print'; $printer = "Hello, world!\n";
No, I'm not being serious.

- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.


In reply to Re: Re: Re: Re: method of ID'ing by Juerd
in thread method of ID'ing by Parham

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.