On Wed, Jun 16, 2010 at 10:30, Aravind Venkatesan <venka...@nt.ntnu.no> wrote: > Hi everyone, snip snip > # Takes in first argument > my $input_file1 = $_; > open (FILEONE, $input_file1); > > my @list1 = <FILEONE>; snip
This does not work. $_ does not hold the first arguent. You mean to say my $input_file1 = shift; or my $input_file1 = $ARGV[0]; This error was complicated by the fact that you are not checking to see if the open function is successful. Try this code: die "invalid number of arguments\n" unless @ARGV == 2; my @list1 = do { open my $fh, "<", $ARGV[0] or die "could not open $ARGV[0]: $!"; <$fh>; }; #lexical filehandle will be auto-closed here my @list2 = do { open my $fh, "<", $ARGV[1] or die "could not open $ARGV[1]: $!"; <$fh>; }; #lexical filehandle will be auto-closed here > > # Takes in first argument > my $input_file2 = $_; > open (FILETWO, $input_file2); > > my @list2 = <FILETWO>; > > > # generates an intersection of terms from the first and second arguments > my @intersection_terms; > foreach (@list1) > { > my $itemlist1 = $_; > > foreach (@list2) > { > my $itemlist2 = $_; > > if ($itemlist1 eq $itemlist2) > { > push @intersection_terms, $itemlist2; > print $itemlist2->id(); > print "\t", $itemlist2->name() if (defined $itemlist2->name()); > print "\n"; > > } > } > } > > close FILEONE; > close FILETWO; > > exit 0; > > Could some guide me on this as to where I have gone wrong (I am new to > programming in perl)? > > thanks a lot, > > Aravind > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > > -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/