#!/usr/bin/perl use strict; use IO::All; use warnings; use Data::Dumper; use feature 'say'; my $io = io 'file.txt'; # Miscellaneous: my @lines = $io->chomp->slurp; print Dumper \@lines; # Tie::File support: $io->[2] = 'This is the changed line in the file.'; # Change a line say $io->[@$io / 2]; # Print middle line print Dumper \@lines; __DATA__ This is the first line in the file. This is the second line in the file. This is the third line in the file. This is the forth line in the file. __OUTPUT__ $ perl test.pl $VAR1 = [ 'This is the first line in the file.', 'This is the second line in the file.', 'This is the third line in the file.', 'This is the forth line in the file.' ]; This is the changed line in the file. $VAR1 = [ 'This is the first line in the file.', 'This is the second line in the file.', 'This is the changed line in the file.', 'This is the forth line in the file.' ];