The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Perl Programming
|
Need some help stripping some data.
Discuss Need some help stripping some data. in the Perl Programming forum on Dev Shed. Need some help stripping some data. Perl Programming forum discussing coding in Perl, utilizing Perl modules, and other Perl-related topics. Perl, the Practical Extraction and Reporting Language, is the choice for many for parsing textual information.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 28th, 2012, 02:13 PM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 2
Time spent in forums: 37 m 37 sec
Reputation Power: 0
|
|
|
Need some help stripping some data.
Ive got an array in Perl, Its extracted and converted using Dumper::
I have a array that contains the following syntax:
a\something,b\somethingelse,a\something2,c\somethe3
a and b and c can come in any order and any number of times. so for example, a\* can come 1-20 times, and b\* comes any number of times, the same as c\* comes as many times. * may be different.
I want based on a pattern match, match on either a, b, or c. which will be a variable match and replace the total contents of the array with the 'matched' set of data, and drop the unmatched (so if i want a\*, b's and c's, will be lost), and inva/vice/versa.
Can someone give me some advice on this please.
|

November 28th, 2012, 04:07 PM
|
|
|
|
Please explain your data in a more precise manner. Is it a simple array? An array of arrays? I really don't understand your data structure. May be a print-out of the Dumper output would help.
|

November 29th, 2012, 05:05 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 2
Time spent in forums: 37 m 37 sec
Reputation Power: 0
|
|
|
Further information please help me resolve.
He the inputdata looks like this: this is example only
foreach $key (keys(%{$inputdata_ref->{'Inputfilename'}{keynames}})) {
$key=~m/^(Dom|number|User|Account|PWExpire|PW|DNGPair|AO)$/ and next;
if ( defined $inputdata_ref->{'Inputfilename'}{data}{$index}{$key} ) {
$validationinfo{$dom}{user}{data}{$username}{$key}=$inputdata_ref->{'Inputfilename'}{data}{$index}{$key};
}
}
the DNGPair is a comma list of entries:
Dm\NG,Dm\NG2,Dm2\NG3,Dm\NG4
In the list of keys, Dom is the data that has to be matched against Dm, and only if theymatch, do we keep the data, I wnt therefore, to remove DM2 which doesnt apply to Dom,
so something like DOm == Dm, 'keep the data and apply it back to the same key
If there is more than one Dm that matches, append it to the same key (, separated.)
The Inputdata is from a source file.
The Validation data is another file that is used to export information from later in my script as this data has been validated.
Hope that does make sense for someone.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|