in reply to Print Match name for certain rows

G'day penny1,

Welcome to the monastery.

Here's how you might go about extracting the data:

#!/usr/bin/env perl -l use strict; use warnings; my ($part_no, @part_info); while (<DATA>) { if (/^partnm_(\d)/) { print_part_data($part_no, \@part_info); $part_no = $1; @part_info = (); next; } push @part_info, $1 if /^(prlot|prwafer|prbin)/; } print_part_data($part_no, \@part_info); sub print_part_data { my ($num, $info) = @_; print "$num: ", @$info ? join ',' => @$info : 'empty' if defined $ +num; } __DATA__ partnm_1 prlot prwafer prbin sspec fab partnm_2 sspec fab partnm_3 .... ....

Output:

1: prlot,prwafer,prbin 2: empty 3: empty

You say "I'm able to print the match values in excel file.": you should use the code you're currently using to do this in print_part_data() (I'm just printing to the screen for demo purposes).

-- Ken