Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: one of these codes is not like the other

by runrig (Abbot)
on Jul 17, 2001 at 00:03 UTC ( [id://97158]=note: print w/replies, xml ) Need Help??


in reply to one of these codes is not like the other

I have a feeling that you are not using strict. Use it, make your code work with it, e.g., use 'foreach my $entry (@GILIST) {...', and see if your problem becomes apparent. If it does not become apparent, at least problems will be easier to find (for all of us).
  • Comment on Re: one of these codes is not like the other

Replies are listed 'Best First'.
Re: Re: one of these codes is not like the other
by speedo (Initiate) on Jul 17, 2001 at 01:07 UTC
    I followed your suggestion, and ended up with 20 or so: Global symbol "%blahblah" requires explicit package name. so I remedied this by adding "my"'s to my variables. But there's a syntax error I don't get: it's near "$specieslist{" of the following line of code:
    unless (my $speciesname eq (my specieslist{$entry})) {
    And then the pgm is aborted due to compilation errors. Does anyone see fundamental problems with that line? Thanks again -speedo
      unless (my $speciesname eq (my specieslist{$entry})) { You don't blindly put my in front of every variable. It is a way to declare variables, so you only put it in front of the first use of a variable (and in a scope where every other use can 'see' it). First, 'specieslist' is a hash, so somewhere you would have 'my %specieslist;' or 'my %specieslist = ....;'. and so speciesname and specieslist in your clause above would not have a my.

      And your clause above also has another typo, the lack of a '$' in front of specieslist (but I'm just assuming that's just a typo here from your error message). FYI, you are declaring a new lexical variable '$speciesname' above, which is only scoped (it only exists) in the 'unless' block, and it has an undefined value.

      Update: Just noticed this node that might help.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://97158]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-19 06:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found