> -----Original Message-----
> From: Mark Goland [mailto:[EMAIL PROTECTED]
> Sent: Friday, February 13, 2004 1:28 PM
> To: [EMAIL PROTECTED]
> Subject: strings
> 
> 
> Hi All,
> 
> I have a tring which contains 60 to 80 keywords, I need to 
> know what position a keyword is in. I need an efficint way to 
> extra position of key words, here is how I am currently 
> finding positions,
> 
> $string="type,model,color,date";
> 
> # this is how I am currently getting position, which is nto 
> very efficiant
> @keys=split ",",$string;
> foreach( @keys ){
>  $position++;
>  last if m/model/ig;
> } 
> 
> 


use strict;
use warnings;

my $str = "The cat sat on the mat";
print index($str, "sat"); # prints 8

-- 
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