data_diff()
DBI::data_diff(string,string[,length])
This function returns the results of both
data_string_desc() and data_string_diff(), describing
the difference between the two given strings. It returns an empty
string if the strings given are identical. Here is an example:
...
my $previous_author = 'Graham Greene';
my $sql_stmnt = "SELECT book_id, author
FROM books
WHERE author LIKE 'Graham%'
LIMIT 1";
my $sth = $dbh->prepare($sql_stmnt);
$sth->execute();
while( my($book_id,$author) = $sth->fetchrow_array()) {
my $diff = DBI->data_diff($previous_author, $author);
if($diff) {
print "$previous_author <=> $author\n$diff \n";
$previous_author = $author;
}
}Here are the results of running this program:
Graham Green <=> Graham Greene a: UTF8 off, ASCII, 3 characters 3 bytes b: UTF8 off, ASCII, 12 characters 12 bytes Strings differ at index 0: a[0]=D, b[0]=G