I need to access previous element in array.
File example: 1. SEG|2961|4| |B|N|000| | |91506|91506|Z|06| 37|0|1|Z|06|37|0|8954| 2. NAME|PARKSIDE AVE| | | |O|E|1399|1301|1398|1300|N|Y|Y| 3. 4. SEG|2962|4|A|B|N|000| | |91506|91506|Z|06| 37|0|1|Z|06|37|0|8954| 5. NAME|RIVERSIDE DR| | | |O|E|1799|1701|1798|1700|N|Y|Y| Pattern is PARKSIDE AVE. When I find it, I wont to display the previous line as well, because its one record. while(<TF>){ if (!/$pattern/i){next;} else{$counter++; print $_[-1]; #here I'm trying to display that previous line without success. print "$counter: $_";} } And one more question: File example: #REDIRECT=/net/542/2003q4_2m/db/uca/zone.cfg REDIRECT=/net/542/2003q4_2m/db/uma/zone.cfg I need to get this path: /net/542/2003q4_2m/db/uca/ while (<ZONECFG>){ next if $_ =~ /^#/; ($path_todb) = $_ =~ /\/.*\//; } Instead of correct path I've got - 1. It looks like I'm assigning scalar value of $_ to my variable even if I surround path_todb in parenthesis Could you help me to resolve these two problems? Thanks in advance. -Vladimir