in reply to Re: word based levenstein distance path
in thread word based levenstein distance path

Hi,

Thanks for your reply.

I have tried sdiff and it works fine. But given that I am new in perl, how can I print only the path? The output I am getting is:

$VAR1 = [ [ '+', '', 'before' ], [ 'u', 'the', 'the' ], [ 'u', 'quick', 'quick' ], [ 'c', 'brown', 'green' ], [ 'u', 'fox', 'fox' ] ];

What I need is:

+uucu

Any help would be greatly appreciated

Replies are listed 'Best First'.
Re^3: word based levenstein distance path
by AnomalousMonk (Archbishop) on May 21, 2015 at 09:30 UTC

    c:\@Work\Perl>perl -wMstrict -le "use constant PATH_ELEMENT => 0; ;; my @out = ( [ '+', '', 'before' ], [ 'u', 'the', 'the' ], [ 'u', 'quick', 'quick' ], [ 'c', 'brown', 'green' ], [ 'u', 'fox', 'fox' ], ); my $path = join '', map $_->[PATH_ELEMENT], @out; ;; $path eq '+uucu' or die qq{bad path: '$path'}; ;; print qq{proper path: '$path'}; " proper path: '+uucu'
    Update: Please see the constant pragma, and the join, map and die built-ins. (Update: See also the tutorial Map: The Basics and the subsidiary discussion of map in Complex sorting.)


    Give a man a fish:  <%-(-(-(-<

      Thanks, I have modified my code and it works!

      Once again thank you for your time and consideration