in reply to Re^6: partial match between 2 files
in thread partial match between 2 files
The script that you write needs to insure that only matching words are compared for difference. You can place the code that inserts a "+" at the first string difference position into a subroutine that can be called from anywhere within your script. For example:
use strict; use warnings; my $string1 = 'amayaM'; my $string2 = 'amayamAn'; my $result = firstStrDiff( $string1, $string2 ); print $result, "\n"; sub firstStrDiff { my ( $s1, $s2 ) = @_; ( $s1 ^ $s2 ) =~ /[^\x00]/; substr( $s2, $-[0], 0 ) = '+' if defined $-[0]; return $s2; }
Output:
amaya+mAn
This can help you focus on just the remaining code that aligns the words you want send to this subroutine.
Hope this helps!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^8: partial match between 2 files
by lakssreedhar (Acolyte) on Dec 27, 2012 at 07:10 UTC | |
by Anonymous Monk on Dec 27, 2012 at 07:49 UTC | |
by lakssreedhar (Acolyte) on Dec 27, 2012 at 08:42 UTC | |
by Anonymous Monk on Dec 27, 2012 at 10:21 UTC | |
by Athanasius (Archbishop) on Dec 27, 2012 at 16:36 UTC | |
by lakssreedhar (Acolyte) on Dec 28, 2012 at 06:24 UTC | |
|
In Section
Seekers of Perl Wisdom