my lastFoundTimescale = "undefined"; # declare a variable to hold the last found value while(<>) # read the file line-by-line { if (line with timescale info found) store info to the variable lastFoundTimescale if (line with modulename found) process modulename and lastFoundTimescale }