[CDBI] Has Many Problem

Martin H. Sluka fany+perl.class-dbi at noris.net
Thu Nov 16 17:24:18 GMT 2006


Oliver Jeeves wrote:
> James Hargreaves wrote:

> sub fixtures
> {
> 	my $self = shift;
> 	my %fixtures = map {$_ => 1}
> 		($self->home_fixtures, $self->away_fixtures);
> 	
> 	return keys %fixtures;
> }
> 
> That's just off the top of my head, I haven't tested it.

I think this is supposed to return objects, which will by
stringyfied when used as hash keys. So I'd suggest:

	sub fixtures {
	    my $self = shift;
	    my %fixtures = map +( $_ => $_ ),
	                       $self->home_fixtures,
	                       $self->away_fixtures;
	    values %fixtures;
	}

Or:
	sub fixtures {
	    my $self = shift;
	    my %seen;
	    grep !$seen{$_}++,
	         $self->home_fixtures,
	         $self->away_fixtures;
	}

Regards,
fany

-- 
noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
Tel +49-911-9352-112 - Fax +49-911-9352-100

http://www.noris.de - The IT-Outsourcing Company



More information about the ClassDBI mailing list