I have two fastafiles
I want to compare both and look for best hits:
I am using the following code:

#!/usr/bin/perl -w use strict; open (IN, ARGV[0]); my %assem = (); while(my $line = <IN>){ chomp $line; my @parseblast = split(/\s+/, $line); $parseblast[0] =~ s/\s+//g; $parseblast[1] =~ s/\s+//g; print $parseblast{0}."\n"; $assem{$parseblast[0]} = $parseblast[1]; } close IN; open(IN, $ARGV[1]); my %clc = (); while(my $line = <IN>){ chomp $line; my @assemblast = split(/\s+/, $line); $assemblast[0] =~ s/\s+//g; $assemblast[1] =~ s/\s+//g; print $assemblast[0]."\n"; $clc{$assemblast[0]} = $assemblast[1]; } close IN; my $c=0 while(my $k = each(%assemblast)){ if($clc{$assemblast{$k}} eq $k){ $ c++; } } print $c;

when running:

perl compareAssemblies.pl Assembly1.fa Assembl2.fa

the program generates the following:

syntax error at compareAssem.pl line 4, near "ARGV[" Global symbol "%parseblast" requires explicit package name at compareA +ssem.pl line 11. Global symbol "%assemblast" requires explicit package name at compareA +ssem.pl line 29. syntax error at compareAssem.pl line 29, near "){" Global symbol "%assemblast" requires explicit package name at compareA +ssem.pl line 30. Global symbol "$k" requires explicit package name at compareAssem.pl l +ine 30. Global symbol "$k" requires explicit package name at compareAssem.pl l +ine 30. Global symbol "$c" requires explicit package name at compareAssem.pl l +ine 31. Global symbol "$c" requires explicit package name at compareAssem.pl l +ine 34. Execution of compareAssem.pl aborted due to compilation errors.

Please could someone help me to resolve these errors?


In reply to Compare fasta files by cboPerl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.