From your description, I am not 100% sure about how your input data is structured, I assume all variables can appear in any one of the three key columns. A working solution would be as follows: (Sorry if it looks strange, I don't know how your data looks and have used your column widths of 25 and 15. I have just printed out the matches, of course you can e.g. save them in a hash or call a function immediately on them, depending on what you want to do with the data.)
use strict;
use warnings;
#define a regexp matching the interesting variable names
my $interesting_vars =
qr(a111111111111111111111111|c222222222222222222222222);
#sample input rows
my @rows = ('a111111111111111111111111 1b8888888888888888
+888888888 15x222222222222222222222222 2',
'd999999999999999999999999 4b3333333333333333
+333333333 15c222222222222222222222222 123');
for (@rows) {
#split by variable value pairs
for (/.{40}/g) {
#split variable and value
/(.{25})(.{15})/;
#since I am doing an additional match, I have to
#save my submatches
my $var = $1;
my $val = $2;
print "'$var' = '$val'\n"
if $var =~ $interesting_vars;
}
}
Output:
'a111111111111111111111111' = ' 1'
'c222222222222222222222222' = ' 123'
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.