my @index; while (){ my $offset = tell BIGLOG; ### This offset is the start of the *next* line! my $epoch = ( /^\s*#/ or /^\s\n/ or $_ !~ /^\s*\d/ ) ? 0 : Mktime( unpack 'A4xA2xA2xA2xA2xA2', $_ ); push @index, pack 'NN', $epoch, $offset; } #### my( $offset, @index ) = 0; ## The first lines offset is zero while (){ my $epoch = ( /^\s*#/ or /^\s\n/ or $_ !~ /^\s*\d/ ) ? 0 : Mktime( unpack 'A4xA2xA2xA2xA2xA2', $_ ); push @index, pack 'NN', $epoch, $offset; ## Pair with previous offset $offset = tell BIGLOG; ## and now get the start of the next line }