in reply to Need help in getting a perl script for below logic

Try

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $infile = 'pins.txt'; open my $fh,'<',$infile or die "Could not open $infile : $!"; my @pin; my $flag = 0; my $count = 0; while (<$fh>){ chomp; ++$count; next unless /\S/; # skip blanklines next if /------------/; # end of pin layout if (/VecAddr/){ print Dumper \@pin; s/[^A-Z0-9]//g for @pin; # remove brackets $flag = 1; print join "\t",qw(Cycle Pin-name expected-value),"\n"; next; } if ($flag == 0){ # build pin layout my $str = substr($_,54,16); for my $i (0..15){ $pin[$i] .= substr($str,$i,1) } } else { # process data my @f = split /\s+/,$_; my @p = split '',$f[4]; my $i = 0; for (@p){ if (/[hl]/){ printf "%s\t%s\t%s\n",$f[3],$pin[$i],$_; } ++$i; } } } close $fh; print "$count records scanned from $infile\n";
poj