in reply to Re: Tying
in thread Need simple example tying scalar to localtime()

you are my hero.

Taking your example, and my pathetic perl ability, I came up with:
#!/usr/bin/perl -w use strict; use Tie::Scalar; package Tie_timer; sub TIESCALAR { bless {}, shift } sub FETCH { scalar localtime } package main; my $now; tie ($now, "Tie_timer"); print "$now\n"; sleep 5; print "$now\n"

... which worked perfectly. Perhaps I even understand it better.

thanks again. --sandy

Replies are listed 'Best First'.
Re: Re: Re: Tying
by davorg (Chancellor) on Sep 25, 2001 at 13:22 UTC

    It's a small thing, but you don't actually need to use Tie::Scalar. You're not using anything from it.

    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you don't talk about Perl club."

      really? I didn't realize that "tie" was a built-in. while I like modules as much as the next guy, It's great that this is one less then I need to use.

      Thanks, --Sandy