Why does this throw a syntax error when declaring the @chicago, @wisconsin, and @rockford variables?
#!/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";
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.