#!/usr/bin/perl use strict; use warnings; my $a, $b, $c, $d, $e; my $file = "data.txt"; open(my $fh,'<', $file) or die "can't open $file $!"; my @stack = <$fh>; chomp @stack; $a = pop @stack; print $a . "\n"; $b = pop @stack; print $b . "\n"; $c = pop @stack; print $c . "\n";