#!/usr/bin/perl use strict; print "Enter the txt\n"; my ($input,@ss,$i); chop($input=<STDIN>); open(FILE,"txt.txt") or die $!; @ss=<FILE>; close(FILE); foreach $i(0 .. scalar @ss){ if($ss[$i] =~ /$input/) { if($i ne 0){print "$ss[$i-1]";} print "$ss[$i]"; print "$ss[$i+1]"; } }
In reply to Re: Extracting Lines of a text file
by sanku
in thread Extracting Lines of a text file
by fatfinger
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |