my $tag = ""; while () { $tag = $1 if /\{(\w+)\}/; next if /\{/; print $_ if $tag eq "AUTHOR"; }