use warnings; use strict; use feature 'state'; sub xyz { open state $foo, '<', '/tmp/foo' or die $!; chomp( my $bar = <$foo> ); close $foo; return $bar; } open our $foo, '>', '/tmp/foo' or die $!; print $foo "Hello\n"; close $foo; use Test::More tests=>1; is xyz(), "Hello"; # => PASS