[Pdx-pm] oh, gross (object method in regex)

David Wheeler david at kineticode.com
Sun Mar 12 14:46:05 PST 2006


On Mar 12, 2006, at 13:03, Randall Hansen wrote:

> this works:
>
>      grep /${ \$object->method }/ => @stuff;
>
> but it looks disgusting.  is there a prettier way to do it?

Sure, if $object->method is sure to return the same value for each  
iteration over @stuff:

   my $match = $object->method;
   grep { /$match/ } => @stuff;

Best,

David


More information about the Pdx-pm-list mailing list