in reply to how to store data in file with out using print

Use an editor. Open file, type "10", save, close ;-)

Or use Sys::Mmap:

use Sys::Mmap; { new Sys::Mmap my $foo, 2, "bar" or die $!; $foo = 10; } open my $fh, '<', 'bar' or die $!; my $foo = <$fh>; print "read: '$foo'\n"; __END__ read: '10'