blob: 38fc3d33d83e9c7db31daded4abaa73d10918c9a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#!/usr/bin/env perl
package XHistory;
require Tie::Scalar;
@ISA = 'Tie::StdScalar';
use Modern::Perl '2018';
use feature qw(signatures);
no warnings qw(experimental::signatures);
my @history;
sub STORE($self, $value) {
push @history, $value;
}
sub FETCH($self) {
$history[-1];
}
tie my $x, 'XHistory';
$x = 10;
$x = 20;
$x -= 5;
$x += 1;
$x *= 3;
$x = $x / 2;
say "@history";
|