1 #!/usr/bin/perl 2 use strict; 3 use warnings; 4 5 open my $FH , "+>", "input"; 6 7 my @contents = <$FH>; 8 print "@contents\n"; 9 10 print $FH "4\n"; 11 12 @contents = <$FH>; 13 print "@contents\n"; 14 close($FH); Before executing the perl script: Initial file ananda@ananda-desktop:~/Documents/perl_programs/try$ cat input 1 2 3 ananda@ananda-desktop:~/Documents/perl_programs/try$ perl test.pl ananda@ananda-desktop:~/Documents/perl_programs/try$ cat input 4 ananda@ananda-desktop:~/Documents/perl_programs/try$ After executing the perl script: Updated file