in reply to reading from filename '-'
You're getting error because you're trying to open file named '-', not stdin. @ARGV works because <> operator uses two arguments open. Compare these:
open my $fd, "<", "-"; # will try to open file "-" open my $fd, "-"; # will open STDIN
Update: concerning second question, the best practice is to use three arguments form of open, so you solution is ok.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: reading from filename '-'
by 7stud (Deacon) on Nov 07, 2009 at 10:40 UTC | |
by zwon (Abbot) on Nov 07, 2009 at 10:52 UTC | |
by 7stud (Deacon) on Nov 07, 2009 at 12:57 UTC |