Matthew Glidden wrote:

> Just started working on scripts and wanted to compare strings yesterday,
> but using strEQ (or strcmp) gets me an undefined method error. What
> library should I "use" in my script to get those API? Couldn't find the
> answer in any on-line tutorials.

strEQ is a C API for writing C extension for Perl. usage is straight 
forward:

#!/usr/bin/perl -w
use strict;

use Inline 'C';

printf("'ab' and '12' is %s\n",
        compareTwoString("ab","12") ? "same" : "different");

printf("'xx' and 'xx' is %s\n",
        compareTwoString("xx","xx") ? "same" : "different");

__END__
__C__
bool compareTwoString(char* s1,char* s2){
        bool r;
        r = strEQ(s1,s2);
        return r;
}

prints:

'ab' and '12' is different
'xx' and 'xx' is same

but if you are coding in Perl, you don't need to use this function. use 
'eq','ne','cmp','gt','ge','le' and 'le' instead. i am almost certain that 
you are looking at the wrong doc as a beginner. you should be looking at:

perldoc perlop

david
-- 
sub'_{print"@_ ";* \ = * __ ,\ & \}
sub'__{print"@_ ";* \ = * ___ ,\ & \}
sub'___{print"@_ ";* \ = * ____ ,\ & \}
sub'____{print"@_,\n"}&{_+Just}(another)->(Perl)->(Hacker)

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to