Here is one approach using a perl repl.

re.pl
$ my @x = qw(3 1 4 2 9 0)
$VAR1 = 3;
$VAR2 = 1;
$VAR3 = 4;
$VAR4 = 2;
$VAR5 = 9;
$VAR6 = 0;
$ grep {$_ == 4} @x and 'true'
grep {$_ == 10} @x  and 'true' or 'false'

On Thu, Aug 18, 2016 at 7:35 PM, <kp...@freenet.de> wrote:

> Hello,
>
> What's the better way to decide if an element exists in an array?
> Something like what ruby does,
>
> irb(main):001:0>  x=[3,1,4,2,9,0]
> => [3, 1, 4, 2, 9, 0]
> irb(main):002:0> x.include? 4
> => true
> irb(main):003:0> x.include? 10
> => false
> irb(main):004:0> quit
>
>
> I tried searching but found nothing such a method in perl.
>
> thank you.
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>

Reply via email to