what's wrong with this?
my $first = shift || die "first file\n"; my $sec = shift || die "second\n";
The || operator has higher precedence than the = operator so you need to either enclose the assignment in parentheses or use the lower precedence or operator.
You can accomplish the same result more simply with a single hash:
#!/usr/bin/perl use strict; use warnings; my $first = shift or die "first file\n"; my $sec = shift or die "second\n"; open my $FIRST, '<', $first or die "$first: $!"; open my $SEC, '<', $sec or die "$sec: $!"; print "processing $first\n"; my %common = map { /^\s*(\?.*?)\s/, 0 } <$FIRST>; print "processing $sec\n"; /^\s*(\?.*?)\s/ and $common{ $1 }++ while <$SEC>; print "finding common keys\n"; delete @common{ grep !$common{ $_ }, keys %common }; print "there are @{[scalar keys %common]}:\n"; system 'pause'; for my $key ( keys %common ) { print "\n\n\n$key\n\n\n"; }
In reply to Re: what's wrong with this?
by jwkrahn
in thread what's wrong with this?
by Alien
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |