B
biomahui
If I don't use iteration, how to test if an element belongs to an array
or hash?
Thanks a lot.
or hash?
Thanks a lot.
If I don't use iteration, how to test if an element belongs to an array
or hash?
If I don't use iteration, how to test if an element belongs to an array
or hash?
Thanks.
Another question,
Is there a way to find the keyvals from their values without using
iteration. For instance;
$set{"apple"}="fruit";$set{"pear"}="fruit";$set{"banana"}="fruit";$set{"beef"}="meal";
I need to find "apple","pear" etc from "fruit".
Thanks.
Another question,
Is there a way to find the keyvals from their values without using
iteration. For instance;
$set{"apple"}="fruit";$set{"pear"}="fruit";$set{"banana"}="fruit";$set{"beef"}="meal";
I need to find "apple","pear" etc from "fruit".
Thanks.
Another question,
Is there a way to find the coevals from their values without using
iteration. For instance;
$set{"apple"}="fruit";$set{"pear"}="fruit";$set{"banana"}="fruit" $set{"beef"}="meal";
I need to find "apple","pear" etc from "fruit".
Thanks!
Jim said:my @fruit;
for (keys %set) {push(@fruit, $_) if $set{$_} eq 'fruit'; }
John said:wrote:
for a normal array: -> iteration
for hash, exists
A new question related:
if I created a hash, $set{$a}{$b}=1, I can get the keys of $b for a
given $a, using "keys %{$set{$a}}";
My question is, Is there any function that can test the existence of an
element belongs to $b for a given $a?
Thanks!
John said:wrote:
for a normal array: -> iteration
for hash, exists
How about this way, without iteration? I know you can fool it into
thinking that 'apple banana' is an element though.
#!/usr/bin/perl
use strict;
use warnings;
my @array = ('apple','banana','peach','pear','mango');
my $string = join ' ', @array;
my $input = $ARGV[0];
print "$input is a value of the array\n" if $string =~ /$input/;
Thank you. I am programming with genomic information. Thus I always try
to speed it up.
All of your information has helped me a lot already.
Sorry for my little knowledge on perl.
Thanks a lot.
</fullquote>Yes.
I want to get this.
Thanks.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.