Quicksilver has asked for the wisdom of the Perl Monks concerning the following question:
Is there, perhaps, a better of doing this (though this nearly gives the me the results I'd love)?#!c:\perl\bin\perl.exe use strict; use warnings; use DBI; use Text::Diff; use IO::File; my $diff; my $dbh; #Create the strings first $dbh = DBI->connect('dbi:mysql:dickens:localhost', 'admin', 'pass'); #my ($indexstring) = $dbh->selectrow_array('SELECT sentence FROM seque +nce'); #my ($additionaltext) = $dbh->selectrow_array('SELECT sentence FROM se +quence1'); my @indexstring; my @additionaltext; my $result; my $sth = $dbh->prepare("SELECT sentence FROM sequence"); $sth->execute; while (my @result = $sth->fetchrow_array) { push @indexstring,$result[0]; } $sth = $dbh->prepare("SELECT sentence FROM sequence1"); $sth->execute; while (my @result = $sth->fetchrow_array) { push @additionaltext,$result[0]; } $dbh->disconnect(); ################################ #Compare strings or arrays ################################ #Use Text::Diff for arrays. #Need a regex to get the relevant data out my @difference = diff \@indexstring, \@additionaltext; foreach $diff(@difference) { my $unequal = split(/+/, $diff); print "$unequal\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Splitting on + after using Text::Diff
by Corion (Patriarch) on Apr 04, 2008 at 10:44 UTC | |
by Quicksilver (Scribe) on Apr 04, 2008 at 11:49 UTC | |
|
Re: Splitting on + after using Text::Diff
by deibyz (Hermit) on Apr 04, 2008 at 10:57 UTC |