in reply to Re^2: unquoted string error??!!
in thread unquoted string error??!!
Here is my (humble) opinion on why it is best to avoid bareword file handles...(Update: except for STDIN, STDERR, DATA, ARGV, and the like...)
While it doesn't matter in a situation as simple as in the OP, in a non-trivial situation, if you use a lexical file handle (and 'use strict'), you can avoid the following bug:
This exact sort of thing happened here@work, where there is a serious lack of lexical file handle use, and took a non-zero amount of time to debug. It also failed to influence anyone's decision in choice of file handle type :-(#!/usr/bin/perl use strict; use warnings; my $file = "file.txt"; CreateFile($file); system frobnicate => $file; sub CreateFile { my $f = shift; open(OUTPUT_FILE, ">$f") or die "Err: $!"; for (1..100) { print OUTPUT_FILE "$_\n"; } # blah, blah, blah... close OUTPUT_FH }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: unquoted string error??!!
by JavaFan (Canon) on May 05, 2011 at 11:04 UTC | |
by runrig (Abbot) on May 05, 2011 at 15:57 UTC | |
|
Re^4: unquoted string error??!!
by tchrist (Pilgrim) on May 04, 2011 at 17:31 UTC | |
by runrig (Abbot) on May 04, 2011 at 18:05 UTC | |
by JavaFan (Canon) on May 05, 2011 at 11:16 UTC | |
by tchrist (Pilgrim) on May 04, 2011 at 18:16 UTC | |
by runrig (Abbot) on May 04, 2011 at 22:23 UTC | |
by tchrist (Pilgrim) on May 04, 2011 at 22:58 UTC | |
|