skendric has asked for the wisdom of the Perl Monks concerning the following question:
I write scripts which compare two text files and then do interesting things if they are different.
(2) Suggestions on how to tackle the problem differently?
--sk
Typically, I want to ignore certain changes ... in the example below, I am uninterested in lines which contain the string 'set password ENC'. I end up writing code like:use Text::Diff qw(diff); [...] $diff = diff "$config_dir/$config_old", "$config_dir/$config_new", { STYLE => "OldStyle"}; @diff = split '\n', $diff; [...]
Now, I'm discovering that I am uninterested in changes to private keys ... a typical line in a file might look like this:LINE: for my $line (@diff) { next LINE if $line =~ /set password ENC/; [...] }
I'm struggling to figure out how to ignore such lines. My brain wants to construct a regex which identifies "random strings", so that I could write a line like:set private-key "-----BEGIN ENCRYPTED PRIVATE KEY----- MIIFDjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDgQInXCep+2zzpgCAggA MBQGCCqGSIb3DHMHBAiSZZZ3CUL1cQSCBNhxHiU0wI3XOMU05aVZybU6OOJOJBa/ M+b28ad6P8VZiN+eToUfs3pTg+VqzAc273fdnZPZFMClXpJk8kQZv0ruEoA99RqE pgsnYGVxzZNmDy5HT3yBDGjRCssDnQ8QUBqabFCpW6d7fzilw9PnoHjFRmLxKnNE [...]
(1) Suggestions on how to construct such a regex?next LINE if $line =~ /{looks like random stuff to me}/;
(2) Suggestions on how to tackle the problem differently?
--sk
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: regex for identifying encrypted text
by Eily (Monsignor) on May 16, 2018 at 10:22 UTC | |
Re: regex for identifying encrypted text
by hippo (Bishop) on May 16, 2018 at 10:28 UTC | |
Re: regex for identifying encrypted text
by QM (Parson) on May 16, 2018 at 10:18 UTC | |
Re: regex for identifying encrypted text
by cavac (Parson) on May 16, 2018 at 12:22 UTC | |
by hippo (Bishop) on May 16, 2018 at 12:44 UTC | |
by QM (Parson) on Sep 03, 2019 at 11:40 UTC | |
Re: regex for identifying encrypted text
by james28909 (Deacon) on May 16, 2018 at 16:44 UTC | |
| |
Re: regex for identifying encrypted text
by skendric (Novice) on Jun 29, 2018 at 22:57 UTC | |
by Anonymous Monk on Sep 02, 2019 at 09:19 UTC | |
A reply falls below the community's threshold of quality. You may see it by logging in. |
Back to
Seekers of Perl Wisdom