nntp2http.com
Posting
Suche
Optionen
Hilfe & Kontakt

Arrays vergleichen

Von: Helmut Schneider (jumper99@gmx.de) [Profil]
Datum: 18.09.2009 10:41
Message-ID: <7hgve0F2td6m8U1@mid.individual.net>
Newsgroup: de.comp.lang.perl.misc
Hi,

Ich möchte Arrays vergleichen und verwende derzeit Text::Diff[0]. Das ist
eigentlich kein Problem:

---
use Data::Dumper;
use Text::Diff;

my @array1 = ( "A", "B", "c" );
my @array2 = ( "a", "B", "C" );

@diff = (diff \@array1, \@array2, {STYLE => "Unified"});

print Dumper(@diff);
---

# perl ./test.pl
$VAR1 = '@@ -1,3 +1,3 @@
-A+a B-c+C';
#

Nur, wie bekomme ich die Diffs zeilenweise[1]?

$VAR1 = '@@ -1,3 +1,3 @@
-A
+a
B
-c
+C';

Mache ich den Diff nicht von Arrays, sondern von Dateien, klappt das.

Liegt es an Text::Diff, oder an mir?

Danke und Gruß, Helmut

[0] http://kobesearch.cpan.org/htdocs/Text-Diff/Text/Diff.html
[1]
http://kobesearch.cpan.org/htdocs/Text-Diff/Text/Diff.html#Text_Diff_Unified

--
No Swen today, my love has gone away
My mailbox stands for lorn, a symbol of the dawn


[ Auf dieses Posting antworten ]

Antworten