A file handle is an abstract indicator for accessing a file. It is retrieved after successfully opening the file using the file name. Afterwards the file handle is used instead of the file name for all file operations.
Questions tagged [filehandle]
407 questions
8
votes
1 answer
Getting a file path from a file handle in Windows
In Windows, is there a straightforward way to get the full path of a file, given only the file's handle?
I can't use GetFinalPathNameByHandle() because that's Vista+ only and our product has to work on XP. However, something that simple, or close…

Wilson F
- 1,250
- 1
- 20
- 37
8
votes
7 answers
How can I process a multi line string one line at a time in perl with use strict in place?
I'm trying to figure out the proper PBP approved way to process a multi line string one line at a time. Many Perl coders suggest treating the multi line string as a filehandle, which works fine unless you have "use strict" in your script. Then you…

Kurt W. Leucht
- 4,725
- 8
- 33
- 45
8
votes
1 answer
Support autovivified filehandle as arguments to Perl XS routine
Question
How can I support autovivified filehandle arguments in an XS function?
I'm XS-wrapping a C function which returns a file descriptor, and I'd like to present that file descriptor as a perl filehandle argument in the manner of open(). …

pilcrow
- 56,591
- 13
- 94
- 135
8
votes
5 answers
How can I suppress STDOUT temporarily in a Perl program?
Is there any easy way to tell perl "now ignore everything that is printed"?
I have to call a procedure in an external Perl module, but the procedure prints a lot of unnecessary information (all through standard print).
I know select can be used to…

Karel Bílek
- 36,467
- 31
- 94
- 149
7
votes
2 answers
No error or warning for trying to print to an already closed filehandle
In the following small code, I do not get an error or a warning for lines [09] and [18]. The only warning I get is with line [21]:
use strict; # [01]
use warnings FATAL => 'unopened'; …

mak
- 197
- 9
7
votes
3 answers
Perl memory usage with map and file handle
Does calling map { function($_) } ; load the entire file into memory when using perl?

Eric Pruitt
- 1,825
- 3
- 21
- 34
7
votes
3 answers
How can I tell a Perl function that takes a file to read from the special ARGV handle?
In perldoc perlvar, I read this:
Note that currently "ARGV" only has
its magical effect within the "<>"
operator; elsewhere it is just a plain
filehandle corresponding to the last
file opened by "<>". In particular,
passing "*ARGV" as a…

Ryan C. Thompson
- 40,856
- 28
- 97
- 159
7
votes
3 answers
List all currently open file handles?
Possible Duplicate:
check what files are open in Python
Hello,
Is it possible to obtain a list of all currently open file handles, I presume that they are stored somewhere in the environment.
I am interested in theis function as I would like to…

Thorsley
- 1,003
- 2
- 9
- 11
7
votes
2 answers
How can I store and access a filehandle in a Perl class?
please look at the following code first.
#! /usr/bin/perl
package foo;
sub new {
my $pkg = shift;
my $self = {};
my $self->{_fd} = undef;
bless $self, $pkg;
return $self;
}
sub Setfd {
my $self = shift;
my $fd =…

Haiyuan Zhang
- 40,802
- 41
- 107
- 134
7
votes
2 answers
Python equivalent of piping zcat result to filehandle in Perl
I have a huge pipeline written in Python that uses very large .gz files (~14GB compressed), but need a better way to send certain lines to an external software (formatdb from blast-legacy/2.2.26). I have a Perl script someone wrote for me a long…

Julian Egger
- 71
- 1
- 3
7
votes
5 answers
ant error Unable to rename old file to temporary file
I'm using ant 1.8.0 and java 1.6.0.17 and I'm running into a strange problem.
In my build.xml, I have a simple task that compiles the code

karoberts
- 9,828
- 4
- 39
- 39
7
votes
2 answers
How to derefence a copy of a STDIN filehandle?
I'm trying to figure out how to get a Perl module to deference and open a reference to a filehandle. You'll understand what I mean when you see the main program:
#!/usr/bin/perl
use strict;
use warnings;
use lib '/usr/local/share/custom_pm';
use…

cooldood3490
- 2,418
- 7
- 51
- 66
6
votes
2 answers
How can I write to Perl filehandles that I stored in array?
I have a list of filenames. I have to create a file for each of those names, write lines to the various files (in no particular order), then close them.
How can I do that in perl? I envision something like the following code (which will not work in…

Frank
- 64,140
- 93
- 237
- 324
6
votes
2 answers
Debugging file handle issues in c#/.NET
I have a program that in turn accesses a DLL. It uses files in various ways, creating them, copying them and establishing them as attachments to an emailMessage object. I have a 'file in use' error, preventing overwrite of a file.
Is there any…

Glinkot
- 2,924
- 10
- 42
- 67
6
votes
2 answers
What does local do on the standard streams / bareword word filehandles: STDIN?
I was thinking about doing
open(*STDIN, "<", "/dev/null" );
open(my $fh, "-|", "/bin/bash", "/tmp/foo");
print for <$fh>;'
However, I would like *STDIN restored, afterward, so I tried.
{
open(local *STDIN, "<", "/dev/null" );
open(my $fh, "-|",…

Evan Carroll
- 78,363
- 46
- 261
- 468