Avatar of bt707
bt707
Flag 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

Perl

Avatar of undefined
Last Comment
bt707

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
ozo

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
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,
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.
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 _ )
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
bt707

ASKER
I got it figured out so closing the question.