Link to home
Start Free TrialLog in
Avatar of bt707
bt707Flag for United States of America

asked on

Perl check values

I'm using a Perl one liner to parse out some info, where I need to see if the set City matches a part of another value such as:

perl -n00e 's/\n //g;if((/employeeType: (contractor|director|employee|student|role)/mi)){print STDOUT m/^id: (.+)/mi,qq{\t},m/^alias: (.+)/mi,qq{\t},m/^c: (.+)/mi,qq{\t},m/^l: (.+)/mi,qq{\t},m/^itbuilding: ([^_]+(?=_)).+/mi,qq{\n}}'

Open in new window


From this one liner I get an output such as:

100151  boulter1        GB      Crawley Crawley
100152  boyden1 US      Princeton       Tulsa
100153  acampbell       US      Houston Houston
100163  nickson1        NL      The Hague       The Hague
100166  asalsman        AE      Abu Dhabi       Mussafah


What I need is the lines where the last two fields do not match, how can I print out just the ones the do not have the last two fields matching and also a way to print out all but mark the ones that do not match with a 6 field such as Match/No Match.

From that example I need the two lines that do not match the last two fields:

100152  boyden1 US      Princeton       Tulsa
100166  asalsman        AE      Abu Dhabi       Mussafah


Thanks,
perl -n00e 's/\n //g;if((/employeeType: (contractor|director|employee|student|role)/mi)){print STDOUT m/^id: (.+)/mi,qq{\t},m/^alias: (.+)/mi,qq{\t},m/^c: (.+)/mi,qq{\t},m/^l: (.+)/mi,qq{\t},m/^slbitbuilding: ([^_]+(?=_)).+/mi,qq{\n}}'

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bt707

ASKER

ozo,

The input is a backup file of thousands of ldap records all seperated by a blank line, each record is very long so I'm using the one liner to pull out the attributes and values I need such as:

id: 545454
alias: boulter1
c: GB
l: Crawley
itbuilding: Crawley

So I'm just pulling out that part that is mixed in a full ldap record with lots of other attributes I do not need.

I hope that helps, I cannot past a full record but can past more if needed but that shows just how the parts I need are in the records.

Thanks,
Avatar of bt707

ASKER

sorry, one update

The itbuilding is like this:

itbuilding: Clamart Clamart_SRPC 1 Rue Henri Becquerel_FR0010

so I am just taking the City part of the itbuilding which is the first of the value up to the first _ underscore.
Avatar of bt707

ASKER

I copied an extra Clamart so it should of been

itbuilding: Clamart_SRPC 1 Rue Henri Becquerel_FR0010

So I'm just taking the Clamart from the rest of the string (the first to the first _ )
Avatar of bt707

ASKER

I got it figured out so closing the question.