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


In reply to Re: Print Match name for certain rows by kcott
in thread Print Match name for certain rows by penny1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.