Well. First things first.
Add:
use warnings;
use strict;
Right below the #!/usr/bin/perl line in your script. Do this for all your perl scripts, great or small. Tell your professor I told him to do this as well.
Also, I noticed that $j is never used. Weird, but whatever.
Anyway, the test I decided to use was /\w\w/ - ie 'does the supposed URL contain 2 'word' characters (a-z, plus dash) this rules out a single dash, and a bunch of other possible bogus data.
As an aside, apparently tfproject's software doesn't properly escape '>' and '<' - so you need to change them to '&gt;' and '&lt;' respectively when you post code, even inside a 'code' block - this is what caused the 'while' line to not show up correctly.
Code:
#!/usr/bin/perl
use warnings;
use strict;
my $id = 0;
my $i = 0;
my $j = 0;
my $q = "";
open (IN, "test");
open (OUT, ">testresult");
while (<IN>){
chomp;
my @a = split /\t/;
if ($id == $a[0]) {
if ($a[1] =~ /\w\w/) {
$q = $q . "; $a[1]";
$i++;
}
}
else {
$j++;
print OUT "$id\t$q\t$i\n";
$id = $a[0];
$q = $a[1];
$i = 1;
}
}
close(IN);
close(OUT);
Oh, and as far as your error running the script goes - sounds like perl is missing from /usr/bin/perl - try running 'which perl' and see if it's available. Also try 'perl -v' to make sure it really runs. If it isn't there, install it. Or install a real distro. Ubuntu sux. (I kid. ;-))