[PLUG] Perl compatison not working...
someone
plug_1 at robinson-west.com
Wed Jun 6 20:03:45 UTC 2007
Here is a simple history file entry:
arthematics.com|unknown|89.40.244.63|mhanniganzcum at arthematics.com|
sonya.h at robinson-west.com
There is one special header line in the history file which
starts with a #.
The test record to compare it to gets formatted the same way
and both strings get split into arrays ( because doing a string
comparison doesn't seem to work right. ). The whole record
has to match to be the same, not just part of it.
...
# Catch the depth of match...
----------------------------------------------
if ( 1 == $TESTPRINT3 )
{
print "\n","The string for the current record: $addteststr","\n","\n";
}
@test_arr=split(/\|/,$addteststr);
$ltest_arr=$#test_arr + 1;
$curr_rec="";
foreach $curr_rec (@histrec)
{ # Verify that $addteststr isn't recorded already.
chomp($curr_rec);
if ( 1 == $TESTPRINT3 )
{
print "\n","The string for the history record: curr_rec","\n","\n";
}
@hist_arr=split(/\|/,$curr_rec);
$lhist_arr=$#hist_arr + 1;
$testing=0;
$other_rec="";
$hist_rec="";
for ( $counter=0 ; $counter < 5 ; ++$counter )
{
if ( $ltest_arr > $counter )
{ $other_rec=$test_arr[$counter]; }
else
{ next; }
if ( $lhist_arr > $counter )
{ $hist_rec=$hist_arr[$counter]; }
else
{ next; }
if ($other_rec eq $hist_rec)
{ $testing+=1; }
else
{ next; }
}
}
#
---------------------------------------------------------------------------
...
The last comparison doesn't always work right and I don't know why.
I know that email addresses and DNS hostnames have periods and @ symbols
in them which may be special characters in Perl. I know this code isn't
working right because the length of my history file grows longer even if
I run it on the exact same input data multiple times.
What I need to do is a string comparison that won't pay attention
to special characters.
Michael C. Robinson
More information about the PLUG
mailing list