Without bothering with the GUI framework, here's a possible general approach to handling the VALUEs file:

c:\@Work\Perl\monks>perl use strict; use warnings; use autodie; use Data::Dump qw(dd); my @tags = qw(NAME TASK CAPS PKG_TYPE STACK SHIP); my $rx_value_intro = qr{ \s* [|] \s* VALUE \s+ = \s+ }xms; my $rx_value = qr{ [[:alnum:]]+ }xms; my ($rx_tag) = map qr{ \b (?: $_) \b }xms, join ' | ', map quotemeta, reverse sort @tags ; print "rx_tag $rx_tag \n"; # for debug my $data_file = <<'EOF'; NAME|VALUE = a TASK|VALUE = copy CAPS|VALUE = 0 PKG_TYPE|VALUE = premium NAME|VALUE = z TASK|VALUE = cut CAPS|VALUE = 0 PKG_TYPE|VALUE = premium NAME|VALUE = c TASK|VALUE = paste STACK|VALUE = 2 SHIP|VALUE = lowtier EOF open my $fh_input, '<', \$data_file; local $/ = ''; while (my $record = <$fh_input>) { my $got_params = my %params = $record =~ m{ \G \s* ($rx_tag) $rx_value_intro ($rx_value) \s+ }xmsg; die "bad params record '$record'" unless $got_params; # dd \%params; # for debug process_params(%params); } sub process_params { my (%params, ) = @_; print "processing params: @{[ %params ]} \n"; } __END__ rx_tag (?msx-i: \b (?: TASK | STACK | SHIP | PKG_TYPE | NAME | CAPS) \ +b ) processing params: NAME a PKG_TYPE premium TASK copy CAPS 0 processing params: NAME z PKG_TYPE premium TASK cut CAPS 0 processing params: STACK 2 NAME c SHIP lowtier TASK paste
See haukex's article Building Regex Alternations Dynamically. Of course, much testing of the code is needed.


Give a man a fish:  <%-{-{-{-<


In reply to Re: Need your help in a pattern based text manipulation algorithm by AnomalousMonk
in thread Need your help in a pattern based text manipulation algorithm by kaushik9918

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.