in reply to Re^3: Perl regex
in thread Perl regex

I think I understand most of it. Except -nE and ++ $seen{$2}.
perl : load perl -nE : $1 stands for : ([^\(]+) for example Metan1_4283 in Metan1_4283(Metac1 +_3189) $2 stands for : \n((.*)\) for example (Metac1_3189) in Metan1_4283(Met +ac1_3189) $1 ne $2 : Means if first pattern does not match second pattern. ++ $seen{$2} : < 2 : less than 2. say "$1 : $2"' : prints out into two columns. raw_data.txt : path to file goes here.

Replies are listed 'Best First'.
Re^5: Perl regex
by 1nickt (Canon) on Jul 12, 2017 at 16:19 UTC

    Hi, so one of the greatest things about Perl is its documentation. You can find answers yourself!

    I Googled for 'perl ++ operand' and got perlop - Perl operators and precedence > Auto increment and Auto decrement. (Here we increment the value stored in %seen for each key *before* making sure that we haven't already seen this key by checking that the value *after* incrementing is less than 2. Also makes use of Perl's autovivification.)

    For -n and -E and all other command line switches for the perl executable, see perlrun - how to execute the Perl interpreter.

    Note that the doc I first pointed you to, perlintro, contains links to all these docs in the overview it gives of each topic. Have you yet allocated a couple of hours of your time to read that document? Seems fair, when you are getting other Monks to give of their time to you.


    The way forward always starts with a minimal test.