use strict; use warnings; use List::Util qw( max ); use Variable::Magic qw( cast wizard ); # Make $x a magical variable that always returns 5. cast(my($x), wizard( get => sub { ${ $_[0] } = 5 }, ) ); $x = 3; if ($ARGV[0]) { no warnings 'void'; 0+$x } print('max($x, 4)=', max($x, 4), "\n"); print('$x=', $x, "\n");