#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    2
    Rep 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.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Posts
    828
    Rep Power
    496
    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.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    2
    Rep 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.

IMN logo majestic logo threadwatch logo seochat tools logo