in reply to Bioinformatics, Error: explicit package name

Yes, the missing semi-colon is the cause for the errors displayed on your screen, but the most important issue is that this line:
my @third_fragments = grep -v ($rsite3), $second_fragments[$i];
is just plain wrong Perl syntax (even with the added semi-colon). Perl's grep has little to do with the Unix shell grep (at least as far as syntax is concerned). The "-v" flag does not exist in Perl for the grep function. Please try:
perldoc -f grep
Just a quick example on how to use grep in Perl:
$ perl -e 'my @number_larger_than_5 = grep {$_ > 5} 1..10; print " @nu +mber_larger_than_5";' 6 7 8 9 10