in reply to Reaped: Re^2: pattern and loop
in thread pattern and loop
Hey again its you!!!
Try the below code.
#!/usr/bin/perl use strict; use warnings; my ($file1) = @ARGV; open(FILE, "<","$file1") or die "Can't Open File1 $! \n"; my $pattern='^LOC'; my $pat='TAAAT'; my ($Line1,$Line2); my $flag=0; while (my $line = <FILE>) { chomp($line); if( $line=~ /$pattern/ ) { $Line1 = $line; next; } elsif( $line =~ /$pat/i) { print "$Line1\n"; print "$line\n"; } } close(FILE);
|
|---|