my %log_file_hash = (); my @log_file_array; my $linenum = 0; my $line; open FILE, "logfile.txt"; while ($line = ) { chomp $line; $log_file_hash{$linenum} = $line; push @log_file_array, $line; $linenum++; } #now the whole file is in the hash and array. print "The first line is " . $log_file_hash{"0"} . "\n"; print "From the array... " . $log_file_array[0] . "\n"; #### $line_0 = ""; $line_1 = ""; $line_2 = ""; $line_3 = ""; while ($line = ) { chomp $line; $line_3 = $line_2; $line_2 = $line_1; $line_1 = $line_0; $line_0 = $line; }