Hi Rob ,
 Sorry my mistake didn't see that.

Thanxs

if ($found eq $search) {


 #!/usr/bin/perl
> use strict;
> use warnings;
>
>  my @arr=qw(fry ring apple law);
>  print "Enter the string you are searching for:";
>  chomp(my $search=<STDIN>); # you may have to check, if input is not string
>

I don't understand your comment. The input from stdin has to be a
string - it cannot be anything else.


   my (index) =  grep { arr[$_]  eq  $search }0..$#arr ;
>    if( defined (index))
>    {
>       print " found" ;
>     }
>

This code will not compile. It should read


 my ($index) =  grep { $arr[$_]  eq  $search } 0..$#arr ;
 if (defined ($index)) {
   print " found at $index" ;
 }

-- 
Akinleye  Adedamola

Reply via email to