Tie::Scalar::Epoch - Create a scalar that always returns the number of non-leap seconds since whatever time the system considers to be the epoch.
# create a variable and tie tie my $epoch, 'Tie::Scalar::Epoch'; print "$epoch\n"; # eg. 1351113480 sleep 2; # wait 2 seconds... print "$epoch\n"; # ... 1351113482 # this will die; $epoch is a readonly variable $epoch = '2012'; # don't die if no_die is true tie my $epoch, 'Tie::Scalar::Epoch', { no_die => 1 }; $epoch = '2012';
This is a very simple class that creates readonly scalars that always return the current epoch.
A variables tied to this class is readonly, and attempting to assign to it will raise an exception.
The following options can be passed in a hashref to tie.
tie
no_die
Do not throw an exception when attempting to assign to a tied scalar. This module will still emit a warning if you have warnings enabled.
perltie, Tie::Scalar,
Victor Houston, <vichouston@cpan.org>
<vichouston@cpan.org>
Copyright ©2012 by Victor Houston.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Tie::Scalar::Epoch, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tie::Scalar::Epoch
CPAN shell
perl -MCPAN -e shell install Tie::Scalar::Epoch
For more information on module installation, please visit the detailed CPAN module installation guide.