open (FOO, ">$scratches") || die "could not open file:$!"; open (D, "$logf") || die "could not open file:$!"; while () { ## look for 9840S and ebexpire ## declare OFS = tab ## tell split to split on IRS 0, 1 & 5. Very similar to awk print $ if (($_ =~ /9840S/) && ($_ =~ /ebexpire, ebexpire/ )) { local $, = "\t"; print F00 +(split)[0,1,5], $/; print FOO (sort { $a <=> $b } $_ ); } # end if } # end while close (FOO); close (D);