aboutsummaryrefslogtreecommitdiff
path: root/challenge-027/andrezgz/perl5/ch-2.pl
blob: 9e1ed736524d96a1af05206196bbad2e47c50e00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/perl

# https://perlweeklychallenge.org/blog/perl-weekly-challenge-027/
# Task #2
# Write a script that allows you to capture/display historical data.
# It could be an object or a scalar. For example
# my $x = 10; $x = 20; $x -= 5;
# After the above operations, it should list $x historical value in order.

use strict;
use warnings;

my $x;
my $x_ops= 'my $x = 10; $x = 20; $x -= 5;';

my @log;
push @log, eval $_ for (split /;/, $x_ops);
print join "\n",@log;