|
|
| Pathologically Eclectic Rubbish Lister | |
| PerlMonks |
Re^3: Using grep in a scalar contextby tobyink (Prior) |
| on Feb 07, 2013 at 12:44 UTC ( #1017645=note: print w/ replies, xml ) | Need Help?? |
|
I simply didn't think about doing it that way. I could probably count the number of times I've used map in a scalar context on my fingers. That said, given that the original question was about gene sequences, which can be pretty long strings, it seems preferable to avoid the creation of a temporary array containing all matches. Whether that's an important concern or not depends on many factors (typical number of matches expected; typical length of matched strings; etc).
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||