From: Peng Yu on
Hi,

In the bioperl Eutilities cookbook,
http://www.bioperl.org/wiki/HOWTO:EUtilities_Cookbook

I see the following code,

print join(',', grep {$field->$_} qw(is_date
is_singletoken is_hierarchy is_hidden is_numerical)),"\n
\n";

I'm not understand how $field->$_ work with. I'm trying to break the
above code so that I can understand. But I failed. Could you please
help generate a minimal example to help me understand the above usage
of "grep {$field->$_}"?

--
Regards,
Peng
From: Randal L. Schwartz on
>>>>> "Peng" == Peng Yu <pengyu.ut(a)gmail.com> writes:

Peng> I'm not understand how $field->$_ work with. I'm trying to break the
Peng> above code so that I can understand. But I failed. Could you please
Peng> help generate a minimal example to help me understand the above usage
Peng> of "grep {$field->$_}"?

It'd help for you to explain what you *do* understand.

Do you know what this does:

$x = "foo":
$field->$x;

Do you know what this does:

print join ", ", grep { $_ > 5 } 1, 2, 4, 8, 16;

If you know both of them, you should be able to work out what the
combination does.

Which part of that is unclear?

print "Just another Perl hacker,"; # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn(a)stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
From: Peng Yu on
On Jun 4, 6:32 pm, mer...(a)stonehenge.com (Randal L. Schwartz) wrote:
> >>>>> "Peng" == Peng Yu <pengyu...(a)gmail.com> writes:
>
> Peng> I'm not understand how $field->$_ work with. I'm trying to break the
> Peng> above code so that I can understand. But I failed. Could you please
> Peng> help generate a minimal example to help me understand the above usage
> Peng> of "grep {$field->$_}"?
>
> It'd help for you to explain what you *do* understand.
>
> Do you know what this does:
>
>   $x = "foo":
>   $field->$x;

'foo' is a member function of $field, right?
From: Randal L. Schwartz on
>>>>> "Peng" == Peng Yu <pengyu.ut(a)gmail.com> writes:

>>   $x = "foo":
>>   $field->$x;

Peng> 'foo' is a member function of $field, right?

Perl doesn't have "member functions".

However, if you mean "is this the same as $field->foo", yes. :)

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn(a)stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion