[Omaha.pm] Tighter/cleaner way to do this? map { grep {} } ?

Jay Hannah jay at jays.net
Thu Feb 5 12:33:04 PST 2009


James Harr wrote:
> If you're dealing with large amounts of resultant data, it might be
> better not to copy and print, but rather just print in the loop.
>
> $first = 1;
> foreach(@a){
> 	next unless /(gold\w+)/;
> 	print ", " unless $first;
> 	$first = 0 if $first;
> 	print $1;
> }
>   

Ya, in my real problem they're small lists and I'm not printing, just 
needing a stripped subset.  :)

Thanks,

j




More information about the Omaha-pm mailing list