Dear Monks,
In furthering my explorations into text mining and comparison, I'm looking to try and take two strings from a database (which represent sentences), split them into pieces if they are unequal. What I want to do is to compare $additional against $index and then print out the differences between the two which I'll ultimately write to a file though at the moment, I'd be happy to only print out the diffs.
#!c:\perl\bin\perl.exe
use strict;
use warnings;
use DBI;
my $index;
my $additional;
#Create the strings first
my $db = DBI->connect('dbi:mysql:sequence:localhost', 'db', 'pass');
my $sth = $db->prepare('SELECT * FROM milton');
$sth->execute();
my $indexstring = $sth->fetchrow_array;
$sth = $db->prepare('SELECT * FROM milton1');
$sth->execute();
my $additionaltext = $sth->fetchrow_array;
print "$indexstring\n";
print "$additionaltext\n";
if ($indexstring eq $additionaltext) {
print "lines match";
}
else {
print "lines do not match";
#$index = split //, $indexstring;
#$additional = split //, $additionaltext;
}
$sth->finish;
$db->disconnect();
The error message that I was getting says that use of @_ is deprecated in split but is there a cleaner, more efficient way of achieving my desired result?
Thanks.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.