in reply to homemade blat: need help with reverse string.

Hello nikkk,

As ww says, those of us who are not biologists can only guess at what your script is doing. It would help us a lot if you included a (short!) example, showing input data (the contents of $query and $nomefile) together with the desired output. In the meantime, I’ll offer two pieces of advice on your code:

First, always use warnings; As it happens, this won’t produce any warnings for your existing code. Nevertheless, it’s something you should get in the habit of using for every script.1 Why operate without a safety net when you don’t have to?

Second, declare variables only when you need to, not all together in a block at the head of your script. This is better style, and it has the advantage that it makes it much easier to see the relation between a variable’s declaration and its use(s). In the present case, the variable $length is declared near the top of the script, and then not used again until the very end:

my $length; ... if(exists $oligo{$query} || exists $oligo{$revcomp}) { ... } else { print("$revcomp\t appear $oligo{$revcomp} times\t in position ($le +ngth - @{$pos{$query}}) on negative strand\n"); # ^^^ +^^^^ }

— at which point it is guaranteed to have a value of undef, which converts numerically to zero. I doubt this is what you intended. Declaring $length as late as possible (i.e., immediately before the point at which it is first used) would have alerted you to the fact that it’s not being assigned its correct value.

Update: Also, the scalar variable $oligo is declared but never used. This fact is somewhat obscured by the various appearances of $oligo{...}, but they reference the hash variable %oligo.

1Yes, even one-liners. perl -wE is just as easy to type as perl -E. :-)

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,