in reply to Re: Perl beginner's issue with hash
in thread Perl beginner's issue with hash

Thanks so much for this! Just as a quick follow-up, do you have any thoughts why I might be receiving an error when I change the 'if' to a 'while' statement? All I've changed is the 'if' for a 'while', but then the following appears when I try to run:
syntax error at step_two_redux.pl line 19, near "else" syntax error step_two_redux.pl line 28, near "}" Execution of step_two_redux.pl aborted due to compilation errors.

Replies are listed 'Best First'.
Re^3: Perl beginner's issue with hash
by AnomalousMonk (Bishop) on Apr 23, 2020 at 18:50 UTC
    All I've changed is the 'if' for a 'while' ...

    If all you've done is change
        if (CONDITION) { ... } else { ... }
    to
        while (CONDITION) { ... } else { ... }
    then yes, this is a syntax error because there is no  while ... else ... statement block structure in Perl. (The only  if statement | statement block I can see in the OPed code is  if (/$id/g) { ... } — is this the one you're referring to?)

    I'm not sure what you were trying to accomplish with this change, so I'm not sure what to advise as the proper change.


    Give a man a fish:  <%-{-{-{-<