Trying to use file handles for input and output and am getting errors,(i.e. … requires explicit package). Code below.
#! /usr/bin/perl use v5.12; use warnings; ## 2/7/19 open CONFIG, '<', 'three_Freds'; open OUTPUT, '>', 'three_Freds.out': my $three_Freds = $ARGV[0]; if (! defined $three_Freds) { die "Usage: $0 filename"; } while (<$CONFIG>) { #take one line of input at a time chomp; s/fred/\n/gi; s/Wilma/Fred/gi; s/\n/Wilma/g; print $OUTPUT $_ ; }
TIA, the catfish
Here is the error that is being thrown 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_Exer3 line 15. Global symbol "$OUTPUT" requires explicit package name at ./Chapter9_Exer3 line 20. Execution of ./Chapter9_Exer3 aborted due to compilation errors.
In reply to Usage of File Handles by catfish1116
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |