ZHAO, BING <mailto:[EMAIL PROTECTED]> wrote:

:              I am doing this simple enough script, but somehow
: it generates error:
:
: open COO, "1898.inf" or die "Cannot open file 1898.inf:$!";
: @shrimp=<COO>;
:
: foreach @shrimp{
:      $squid=substr($_,0,4);
:      $shark=$_.".pdb";
:
: Global symbol "@shrimp" requires explicit package name at
: ./pdbReadbrk2000.pl line 19.

    Declare your variables in the smallest scope possible.
Read http://perl.plover.com/FAQs/Namespaces.html

my @shrimp = <COO>;

    Since you are probably finished with the file now, it is a
good time to close it.

my @shrimp = <COO>;
close COO;

    Without knowing more about your data, I would probably chomp
the line endings too.

chomp( my @shrimp = <COO> );
close COO;



: syntax error at ./pdbReadbrk2000.pl line 21, near
: "foreach @shrimp"

    The list or array goes in parenthesis.

foreach ( @shrimp ) {

    Or, more likely:

foreach ( @shrimp ) {
    my $squid = substr( $_, 0, 4 );
    my $shark = "$_.pdb";


: Global symbol "$to" requires explicit package name at
: ./pdbReadbrk2000.pl line 21.

    This error did not originate from the given code. This happens
a lot when you are trying to debug and write a message at the same
time. Get a good programmer's editor. It will allow you to quickly
test code and cut and paste errors just before you post it to the
group.



    Add the following to the top of your script. It will give you
more detailed error messages.

use diagnostics;


HTH,

Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


  • RE: hi Charles K. Clarkson

Reply via email to