in reply to read nth lines in a text file

Judging by your data, it looks like you only need to keep track of one line (not 4): the line above the +.
use warnings; use strict; my $prev; while (<DATA>) { chomp; if (/\+/) { print length($prev), "\n"; } $prev = $_; } __DATA__ @HWI-ST591:68:D0DBPABXX:5:1101:1197:2084 1:N:0: GGTAGTTCGACCGTGGAT + B@@FFEFFHDHHFHIJJE @HWI-ST591:68:D0DBPABXX:5:1101:1086:2085 1:N:0: GCTGGAACTTGGCAAAGAAGAGAG + @@@FFEFFGHHHH@@FEHBEHJGG
prints...
18 24

See also:

Replies are listed 'Best First'.
Re^2: read nth lines in a text file
by adansonia (Initiate) on Aug 30, 2011 at 21:14 UTC
    Thanks so much! that was just what I wanted!