in reply to Usage of File Handles

here are the errors that are thrown when running script

Variable "$CONFIG" is not imported at ./Chapter9_Exer3 line 15. Variable "$OUTPUT" is not imported at ./Chapter9_Exer3 line 20. syntax error at ./Chapter9_Exer3 line 8, near "'three_Freds.out':" Can't use global $0 in "my" at ./Chapter9_Exer3 line 12, near "Usage: +$0" Global symbol "$CONFIG" requires explicit package name at ./Chapter9_E +xer3 line 15. Global symbol "$OUTPUT" requires explicit package name at ./Chapter9_E +xer3 line 20. Execution of ./Chapter9_Exer3 aborted due to compilation errors.

Replies are listed 'Best First'.
Re^2: Usage of File Handles
by haukex (Archbishop) on Feb 08, 2019 at 20:43 UTC

    You already got suggestions on how to fix these errors:

    Variable "$CONFIG" is not imported at ./Chapter9_Exer3 line 15. Variable "$OUTPUT" is not imported at ./Chapter9_Exer3 line 20. Global symbol "$CONFIG" requires explicit package name at ./Chapter9_E +xer3 line 15. Global symbol "$OUTPUT" requires explicit package name at ./Chapter9_E +xer3 line 20.

    You open the filehandles CONFIG and OUTPUT, and then try to use the variables $CONFIG and $OUTPUT, these are two different things. You need to either change your open calls to use lexical variables, like I showed here, or remove the $ sigil, as pointed out by Your Mother and kcott.

    syntax error at ./Chapter9_Exer3 line 8, near "'three_Freds.out':" Can't use global $0 in "my" at ./Chapter9_Exer3 line 12, near "Usage: +$0"

    The first error was pointed out by poj: You have a typo in that line. The second error is just being caused by the parser getting confused after seeing the first error.