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
2
votes
2 answers
(empty?) return of readline is not caught by control structure
I have a multidimensional hash containing opened file handles on SEEK_END with the intention to always read the latest line without getting to much I/O (what I would get with tail).
I'm now going through all of these handles with a for loop and…

David
- 21
- 2
2
votes
1 answer
How do I execute a PHP function for every line in standard input?
With some background in Linux I have come accustomed to these so called oneliners. Today I want to convert some HTML-garbage (entities) to plain text with html_entity_decode from core PHP.
e.g.
>> html_entity_decode( '>' )
'>'
According to the…

Ярослав Рахматуллин
- 7,599
- 1
- 41
- 60
2
votes
3 answers
Libgdx file handle.. reading a single line
I am trying to save and load files on a project that is coded on libgdx. Which means that i cant use a buffered reader because android wont read it.. and i cant move the project to android because it has to be in the core... after days and days or…

Joe
- 65
- 1
- 8
2
votes
2 answers
Using the same variable to open and close files in foreach loop in Perl
I am having difficulty getting my head around this considering variable declarations. Scenario: I have a file with ten words, one per line. First I want to loop through the file and create new files based on the data.…

Bram Vanroy
- 27,032
- 24
- 137
- 239
2
votes
4 answers
Set a filehandle so that prints to it are quietly skipped?
This strange interest comes from expanding requirements and no time to change design (refactor). This is not good design, sure, but I need to deal with it now and hope to refactor later.
There are a few log files opened early on which are printed…

zdim
- 64,580
- 5
- 52
- 81
2
votes
2 answers
Problem with piped filehandle in perl
I am trying to run bp_genbank2gff3.pl (bioperl package) from another perl script that
gets a genbank as its argument.
This does not work (no output files are generated):
my $command = "bp_genbank2gff3.pl -y -o /tmp $ARGV[0]";
open( my…

David B
- 29,258
- 50
- 133
- 186
2
votes
1 answer
Ensure a file is not changed while trying to remove it
In a POSIX environment, I want to remove a file from disk, but calculate its checksum before removing it, to make sure it was not changed. Is locking enough? Should I open it, unlink, calculate checksum, and then close it (so the OS can remove its…

Alex Morega
- 4,132
- 1
- 24
- 25
2
votes
4 answers
Parse lines of integers in C
This is a classical problem, but I can not find a simple solution.
I have an input file like:
1 3 9 13 23 25 34 36 38 40 52 54 59
2 3 9 14 23 26 34 36 39 40 52 55 59 63 67 76 85 86 90 93 99 108 114
2 4 9 15 23 27 34 36 63 67 76 85 86 90 93 99 108…

Jérôme
- 2,640
- 3
- 26
- 39
2
votes
2 answers
OleDbConnection locks Excel xls file if the file is corrupted
I have a legacy code that imports Excel (*.xls) to our db, then move the file to specific directory after processing.
The code works fine except in one case, when the file is corrupted (even MS Excel cannot open it)! What happens in this case is…

Sameh Deabes
- 2,960
- 25
- 30
2
votes
4 answers
Java File Handling, what did I do wrong?
Wrote up a basic file handler for a Java Homework assignment, and when I got the assignment back I had some notes about failing to catch a few instances:
Buffer from file could have been null.
File was not found
File stream wasn't closed
Here is…

Urda
- 5,460
- 5
- 34
- 47
2
votes
1 answer
Opening and closing a hslogger log file, within the GHCi REPL
I am annoyed with my implementation of hslogger, when running within the GHCi REPL.
import System.IO (Handle)
import System.Log.Logger (Priority( DEBUG ), updateGlobalLogger, addHandler, setLevel, debugM)
import System.Log.Handler.Simple…

indi
- 386
- 3
- 15
2
votes
4 answers
copying the contents of a binary file
I am designing an image decoder and as a first step I tried to just copy the using c. i.e open the file, and write its contents to a new file. Below is the code that I used.
while((c=getc(fp))!=EOF)
fprintf(fp1,"%c",c);
where fp is the source…

Gan
- 1,349
- 2
- 10
- 27
2
votes
2 answers
Array got flushed after while loop within a filehandle
I got a problem with a Perl script.
Here is the code:
use strict;
use Data::Dumper;
my @data = ('a','b');
if(@data){
for(@data){
&debug_check($_)
}
}
print "@data";#Nothing is printed, the array gets empty after the while loop.
sub…

Carlitos_30
- 371
- 4
- 13
2
votes
2 answers
Determine how much can I write into a filehandle; copying data from one FH to the other
How to determine if I can write the given number of bytes to a filehandle (socket actually)? (Alternatively, how to "unread" the data I had read from other filehandle?)
I want something like:
n = how_much_can_I_write(w_handle);
n = read(r_handle,…

Vi.
- 37,014
- 18
- 93
- 148
2
votes
3 answers
Is it possible to read multiple files with a single filehandle in Perl?
I have a few log files like these:
/var/log/pureftpd.log
/var/log/pureftpd.log-20100328
/var/log/pureftpd.log-20100322
Is it possible to load all of them into a single filehandle or will I need to load each of them separately?

rarbox
- 486
- 5
- 14