Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Using the strict pragma, I have found that I need to do some editing to the open function. Yet the print function alludes me.use diagnostics; use strict; open (FILE, "c:\\my\\dir\\src.file.txt") || die "failed to open src file"; while (<FILE>){ my $var_a = $_; my $var_b = "_INDEX"; my $var_c = $_; $var_a =~ s/(^[A-Z]{4})(.*)/$1/o; $comb = $var_a . $var_b; open ($comb, "c:\\my\\dest\\dir\\" . $comb . "found.txt") || die "failure to create" . $comb; print $comb $var_c . "content detail for file found\n"; } close FILE; #_## do some other functions that add more information to file. close $comb.
ERROR output: Can't use string ("ACFT_INDEX") as a symbol ref while "strict refs"WORKS: open ('$comb', "c:\\my\\dest\\dir\\" . $comb . "found.txt") Unable to figure out the print function. ERROR: print $comb $var_c . "content detail for file found\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do you properly use a variable for FILEHANDLE in print vs open
by chromatic (Archbishop) on Jul 03, 2004 at 00:00 UTC | |
|
Re: How do you properly use a variable for FILEHANDLE in print vs open
by Zaxo (Archbishop) on Jul 03, 2004 at 00:06 UTC | |
by Anonymous Monk on Jul 07, 2004 at 17:52 UTC |