Perl check values

bt707
bt707 used Ask the Experts™
on
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

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2014
Top Expert 2015
Commented:
What does the input look like?

Author

Commented:
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,

Author

Commented:
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.

Author

Commented:
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 _ )

Author

Commented:
I got it figured out so closing the question.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial