123456 654321 123456 123456 123456 123456 1234/3456 123456 1234/3456 123456 123456 123456 123456 123456 # From that I want it to loop through and store each ... # From then, if it matches on 4 digits followed by a forward slash I # want it to output the whole to screen, not just the matched lines from second filter. # For that, I've tried this example open(FILE, "< $FILE") or die "ERROR: $!"; while (<>) { if (// ... /<\/DataRecord>/) { @cache=(); } push(@cache, $_); if (m/\d{4}\//){ print @cache; } } close (FILE); # The output of that is 1234/3456 1234/3456 # where I would prefer to see 123456 123456 123456 1234/3456 123456 1234/3456 123456 123456