#!/usr/bin/perl -w use strict; open my $fh, '<', 'details.txt' or die $!; my $i; my @details; while(<$fh>) { push @details, $_; next if ++$i % 4; print @details, "\n"; @details = (); }