Discussion:
Problems with Text:Diff
(too old to reply)
Sebastian Hagedorn
2008-02-28 10:02:29 UTC
Permalink
Hi,

i have to compare two files with eachother and work out the differences.
I found the module Text::Diff, that would do this task fine, as it says
on the description.
I tried it like that:

use Text::Diff;
my $d = Algorithm::Diff->new (@array1, @array2);

but it throws me this Error:

Can't use string ("w") as a HASH ref while "strict refs" in use at
$perlpath/lib/Text/Diff.pm line 589.

Can anyone tell me, what is wrong on that?
Sebastian Hagedorn
2008-02-28 14:56:40 UTC
Permalink
Post by Sebastian Hagedorn
Hi,
i have to compare two files with eachother and work out the differences.
I found the module Text::Diff, that would do this task fine, as it says
on the description.
use Text::Diff;
Can't use string ("w") as a HASH ref while "strict refs" in use at
$perlpath/lib/Text/Diff.pm line 589.
Can anyone tell me, what is wrong on that?
Ok, I'm already done:

my $d = Algorithm::Diff->new(\$string1, \$string2, {STYLE => "Context"});
print $$d;

But this gives me the following error:
Not an ARRAY reference at $perlpath/lib/Text/Diff.pm line 164.

Whats wrong with it?
Jim Gibson
2008-02-28 20:12:51 UTC
Permalink
Post by Sebastian Hagedorn
Post by Sebastian Hagedorn
Hi,
i have to compare two files with eachother and work out the differences.
I found the module Text::Diff, that would do this task fine, as it says
on the description.
use Text::Diff;
Can't use string ("w") as a HASH ref while "strict refs" in use at
$perlpath/lib/Text/Diff.pm line 589.
Can anyone tell me, what is wrong on that?
my $d = Algorithm::Diff->new(\$string1, \$string2, {STYLE => "Context"});
print $$d;
Not an ARRAY reference at $perlpath/lib/Text/Diff.pm line 164.
Whats wrong with it?
Algorithm::Diff requires two array references. Text::Diff has a more
flexible interface as a front-end to A:D, but judging from its
documentation does not have an object-oriented interface. Try
(untested):

use Text::Diff;
my $diff = diff( \$string1, \$string2, { STYLE => "Context" });

or

use Algorithm::Diff;
my $d = Algorithm::Diff->new( \@array1, \@array2 );
--
Jim Gibson

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Loading...