awohld has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; my @chicago{ qw(tiger bob munch toy) } = (); my @wisconsin{ qw( tiger sara munch toy ) } = (); my @rockford{ qw( tiger sara love toy ) } = (); sub intersection { my ( $i, $sizei ) = ( 0, scalar keys %{ $_[0] }); my ( $j, $sizej ); for ( $j = 1; $j < @_; $j++ ) { $sizej = keys %{ $_[ $j ] }; ( $i, $sizei ) = ( $j, $sizej ) if $sizej < $sizei; } my @intersection = keys %{ splice @_, $i, 1 }; my $set; while ( $set = shift ) { @intersection = grep { exists $set->{ $_ } } @intersectio +n; } my %intersection; @intersection{ @intersection } = (); return \%intersection; } my $newIntersection = &intersection( \%chicago, \%wisconsin, \%rockfor +d ); print join(" ", keys %{ $newIntersection }), "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Syntax Error using STRICT and Declaring Variable
by ikegami (Patriarch) on Feb 02, 2006 at 04:45 UTC | |
by diotalevi (Canon) on Feb 02, 2006 at 07:13 UTC | |
|
Re: Syntax Error using STRICT and Declaring Variable
by monarch (Priest) on Feb 02, 2006 at 04:49 UTC | |
|
Re: Syntax Error using STRICT and Declaring Variable
by Cody Pendant (Prior) on Feb 02, 2006 at 04:45 UTC | |
by ikegami (Patriarch) on Feb 02, 2006 at 04:48 UTC | |
by blazar (Canon) on Feb 02, 2006 at 11:15 UTC | |
by awohld (Hermit) on Feb 02, 2006 at 04:48 UTC | |
by ikegami (Patriarch) on Feb 02, 2006 at 04:50 UTC | |
|
Re: Syntax Error using STRICT and Declaring Variable
by tweetiepooh (Hermit) on Feb 02, 2006 at 11:56 UTC |