I don't quite get what you want, I do especially not know where you get that
default-id of
0x10009 from, but this might (or might not) get you started:
#!perl -w
use strict;
use Data::Dumper;
my @fields = qw/attr-name mtype attr-id default-id/;
chomp(my @data = <DATA>);
my (@parsed_data, %temp_hash, %data_hash);
while (@data >= @fields) {
@temp_hash{@fields} = splice @data, 0, @fields;
push @parsed_data, { %temp_hash };
}
for (@parsed_data) {
if ($_->{mtype}) {
$data_hash{$_->{'mtype'}}
= { VALUE => $_->{'attr-id'}, TYPE => 'attr-id' };
} else {
$data_hash{$_->{'default-id'}}
= { VALUE => $_->{'attr-name'}, TYPE => 'attr-name' };
}
}
print Dumper \%data_hash;
__DATA__
model_name
0x234567
0x654321
0x654321
security_string
0x123456
Hope this helped.
CombatSquirrel.
Entropy is the tendency of everything going to hell.
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.