JupiterHost.Net wrote:


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

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

would output:

 1101740477
 1101740480


Thanks everyone that replied, that is exactly what I was looking for!

I beleive I have it now :)

I wonder now, is doing this very resource intensive:

When I benchmark it:

print "Hi " . time();
sleep(3);
print "Hi" . time();

versus

package Local::Tie::Time;

require Tie::Scalar;
our @ISA = ( 'Tie::StdScalar' );
use Carp;
sub STORE { croak "Can't change time.\n" }
sub FETCH { return time() }


package main;

tie( my $time, 'Local::Tie::Time' );
print "Hi $time";
sleep(3);
print "Hi $time";

the tie ranges from 2% slower to 20% slower must be sytem usage causeing the flux eh?

Actually that had to be it because I turned off everything I was running and now get consistently 1 to 3% slower for tie vs. func
i can live with that I think :)


Thnaks again everyone :)

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to