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);
In reply to Re^3: pattern and loop
by vinoth.ree
in thread pattern and loop
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |