in reply to Modify a line following a target line?

#!/usr/bin/perl -- use strict; use warnings; die "Usage: $0 filetoprocess\n" unless @ARGV; my %subst = ('C25' => 'SMS0011', 'U23' => 'TQF0022', # ... 'U25' => 'TQF1223', ); $/ = "\nI "; # use own input record separator while (<>) { # read a record and substitute if a ma +tch found if (my ($rd) = /REFDES=(\w+)/) { s/PKG_TYPE=(\w+)/PKG_TYPE=$subst{$rd}/ if exists $subst{$rd}; } print; }