in reply to Re: Compare of array
in thread Compare of array

I use Data::Compare module

@td = Today([$year,$month,$day]); @tod=($year,$month,$date); $c=Compare($td,$tod); if ($c==1) { $bgcolor="#c0c0c0"; } else { $bgcolor="#FFFFFF"; }

and this error show in Internet Explorer

[920]ERR: 24: Error in Perl code: Undefined subroutine &Embperl::__5:: +Compare called at d:\sukromne\www\epl\calendar.html line 58.

What is wrong ???

Excuse my bad English !!!

Replies are listed 'Best First'.
Re: Compare of array
by jonadab (Parson) on Feb 11, 2004 at 14:46 UTC
    Undefined subroutine &Embperl::__5::Compare

    Without seeing the details of what you're doing, it's hard to be sure (especially since I've never used Embperl), but this looks to me like it might be a namespace issue. When you call the Compare subroutine, try expressly specifying which one you mean:

    @td = Today([$year,$month,$day]); @tod=($year,$month,$date); $c=Data::Compare::Compare($td,$tod); if ($c==1) { $bgcolor="#c0c0c0"; } else { $bgcolor="#FFFFFF"; }

    For comparing dates, though, I would probably be using DateTime or one of the other modules specifically designed to work with dates.

    One last question: did you use the module whose routine you were trying to call? Your code needs to say something like use Data::Compare before you can call anything it defines.


    $;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/
Re:**3 Compare of array
by flounder99 (Friar) on Feb 11, 2004 at 21:06 UTC
    Data::Compare is a bit overkill unless you are comparing a lot of arrays. If you are just doing this compare, I would compare the elements.
    @td = Today([$year,$month,$day]); @tod=($year,$month,$date); if ($td[0]==$tod[0] && $td[1]==$tod[1] && $td[2]==$tod[2]) { $bgcolor="#c0c0c0"; } else { $bgcolor="#FFFFFF"; }

    --

    flounder