tie variable to function?

From: JupiterHost.Net (mlists_at_jupiterhost.net)
Date: 11/29/04


Date: Mon, 29 Nov 2004 09:03:39 -0600
To:  beginners@perl.org

Hello list,

I saw this recently on here but can't find the thread and since I'm not
sure what the technique is called (tie variable to function?) I'm not
sure where to look on perldoc :)

What is it called/How do you go about doing it when you have a var that
each time is used (IE printed or in calculation) has the current value
of a function?

For example:

my $time =...
# do magic to make $time always return time()

  print "$time\n";
  sleep 3;
  print "$time\n";

would output:

  1101740477
  1101740480

Any ideas? benefits/drawbacks to consider?

TIA!



Relevant Pages