in reply to Re: pattern and loop
in thread pattern and loop

This node was taken out by the NodeReaper on Jun 24, 2014 at 02:06 UTC

Replies are listed 'Best First'.
Re^3: pattern and loop
by vinoth.ree (Monsignor) on Jun 23, 2014 at 17:10 UTC

    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);

    All is well