Re: searching the array

2011-08-22 Thread AKINLEYE
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=); # you may have to check, if input is not string > I don't u

Re: searching the array

2011-08-22 Thread Shawn H Corey
On 11-08-22 09:19 AM, Uri Guttman wrote: the comment was still off as he seems to imply data that isn't a string. eof isn't data. It's meta-data. :) -- Just my 0.0002 million dollars worth, Shawn Confusion is the first step of understanding. Programming is as much about organization

Re: searching the array

2011-08-22 Thread Uri Guttman
> "SHC" == Shawn H Corey writes: SHC> On 11-08-22 08:23 AM, Uri Guttman wrote: >> it can only be a string as it comes from stdin. what else do you think >> it could be? SHC> 1. The empty string (not really a string) it is a string that also called the null string. and it is hard to

Re: searching the array

2011-08-22 Thread Shawn H Corey
On 11-08-22 08:23 AM, Uri Guttman wrote: it can only be a string as it comes from stdin. what else do you think it could be? 1. The empty string (not really a string) 2. eof( *STDIN ); -- Just my 0.0002 million dollars worth, Shawn Confusion is the first step of understanding. Prog

Re: searching the array

2011-08-22 Thread Uri Guttman
> "ta" == timothy adigun <2teezp...@gmail.com> writes: ta> Hi Rob, ta> my @arr=qw(fry ring apple law); ta> print "Enter the string you are searching for:"; ta> chomp(my $search=); # you may have to check, if input is not string >>> I don't understand your comment. The input from std

Re: searching the array

2011-08-22 Thread Shawn H Corey
On 11-08-22 02:25 AM, anant mittal wrote: Hi! I want to search whether a scalar '$a' contains any one of value of an array '@arr'. How it may be done? as its not correct : print "found" if $a =~ /@arr/; First of all, don't use $a or $b as a variable name. `sort` uses them and although `perl`

Re: searching the array

2011-08-22 Thread timothy adigun
Hi Rob, my @arr=qw(fry ring apple law); print "Enter the string you are searching for:"; chomp(my $search=); # 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. the input from stdin could be

Re: searching the array

2011-08-22 Thread timothy adigun
Hi Rob, my @arr=qw(fry ring apple law); print "Enter the string you are searching for:"; chomp(my $search=); # 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. the input from stdin could be a

Re: searching the array

2011-08-22 Thread Rob Dixon
On 22/08/2011 12:03, AKINLEYE wrote: Hi anant On Mon, Aug 22, 2011 at 8:42 AM, timothy adigun<2teezp...@gmail.com> wrote: Hi Anant, I want to search whether a scalar '$a' contains any one of value of an array '@arr'. How it may be done? as its not correct : print "found" if $a =~ /@arr/;

Re: searching the array

2011-08-22 Thread Rob Dixon
On 22/08/2011 08:42, timothy adigun wrote: Hi Anant, I want to search whether a scalar '$a' contains any one of value of an array '@arr'. How it may be done? as its not correct : print "found" if $a =~ /@arr/; #!/usr/bin/perl use strict; use warnings; my @arr=qw(fry ring apple law); pr

Re: searching the array

2011-08-22 Thread AKINLEYE
Hi anant On Mon, Aug 22, 2011 at 8:42 AM, timothy adigun <2teezp...@gmail.com> wrote: > Hi Anant, > > >>I want to search whether a scalar '$a' contains any one of value of an > array > >>'@arr'. > >>How it may be done? > >>as its not correct : print "found" if $a =~ /@arr/; > > #!/usr/bin/perl >

Re: searching the array

2011-08-22 Thread timothy adigun
Hi Anant, >>I want to search whether a scalar '$a' contains any one of value of an array >>'@arr'. >>How it may be done? >>as its not correct : print "found" if $a =~ /@arr/; #!/usr/bin/perl use strict; use warnings; my @arr=qw(fry ring apple law); print "Enter the string you are searching for

Re: searching the array

2011-08-22 Thread Alan Haggai Alavi
Hello Anant, Please read: perldoc -q 'certain element is contained in a list or array' or http://bit.ly/o9uKat Regards, Alan Haggai Alavi. -- The difference makes the difference. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.o

Re: searching the array

2011-08-21 Thread Alan Haggai Alavi
Hello Anant, > I want to search whether a scalar '$a' contains any one of value of an > array '@arr'. > How it may be done? If you are using perl v5.010 or later, you can use the smart match operator (~~): use 5.010; use strict; use warnings; my @array = qw( foo bar quux ); my $item = 'bar';