Questions tagged [filehandle]

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.

407 questions
2
votes
1 answer

defining a file handle attribute in moose

I am trying to define a file handle attribute in my Perl code using moose as follows: has validation_log_file_handler => ( is => 'ro', isa => 'File', builder => '_build_validation_log_file_handler' ); The builder: sub…
Mike
  • 1,007
  • 2
  • 16
  • 33
2
votes
2 answers

Using Perl FileHandle with a scalar containing string instead of filename

My script download a plain text file using from the internet using LWP::Simple's get() function. I'd the like to process this string in a filehandle way. I found this 'elegant' (well, I like it) way of doing this from…
moigescr
  • 87
  • 6
2
votes
4 answers

How to get open write handles on a file using C#?

I'm copying from a client computer to a server computer in a shared directory. My server detects the new file, and after the copying is complete it has to process it. The problem is that, when writing a big file and using FileSystemWatcher, you get…
LolaRun
  • 5,526
  • 6
  • 33
  • 45
2
votes
4 answers

Java File handles won't close

Yes this question has been asked before however the issue is a little more complex it seems. I have used all solutions from previous questions that relate to this. Relates to: Freeing Java File Handles , Java keeps file locks no matter what package…
CoasterChris
  • 91
  • 1
  • 10
2
votes
2 answers

Perl not matching contents in an array

I have a file which consists of three names: daniel, elaine and victoria. If I search for daniel I get "you are not on the list". Could someone kindly point out where my mistake is? Thank you. #!/usr/bin/perl #open file open(FILE, "names") or…
il-fox
  • 75
  • 2
  • 8
2
votes
8 answers

How can I avoid Perl::Critic warnings when I process a multi-line string with a filehandle?

Does anyone have a solution to the task of processing a multi-line string one line at a time, other than the string-as-a-filehandle solution shown below? my $multiline_string = "line one\nline two\nline three\nline four"; my $filehandle; open(…
Kurt W. Leucht
  • 4,725
  • 8
  • 33
  • 45
2
votes
1 answer

Perl: how to prevent SIGALRM from closing a pipe?

My pipe (filehandle, socket) breaks (sometimes). I can reproduce it with the following code: my $counter = 5; alarm(1); open(FH,"while(sleep 2); do date; done |") or die $!; while () { print; } close(FH); BEGIN { $SIG{ALRM} = sub { …
Willem
  • 3,043
  • 2
  • 25
  • 37
2
votes
1 answer

does pythons tar file finalize a file added, or wait till its closed?

I apologize if the questions title is not clear. I am creating a very large compressed TarFile using python. I need to know if when using TarFile.Add() does that close and/or finalize the file added, or can the file still be modified? For instance,…
Inbar Rose
  • 41,843
  • 24
  • 85
  • 131
2
votes
2 answers

perl process filehandle

I am trying to learn how to read from a process using filehandles. I have tried to write a program that opens a filehandle from the 'date' command and reference that as requested using the following program: #!/usr/bin/perl use warnings; use…
2
votes
1 answer

How can I use tie() to redirect STDOUT, STDERR only for certain packages?

I need to work with some libraries that unfortunately log diagnostic messages to STDOUT and STDERR. By using tie, I can redirect those writes to a function that captures those. Since I don't want all STDOUT and STDERR output of my programs to be…
hillu
  • 9,423
  • 4
  • 26
  • 30
2
votes
1 answer

Game holds handle to wma file after exit

I have an xna game exported in a dll file. Everything to run the game (except the content) is in this library, especially the main game class. In another assembly, I load the game dll, instantiate the game class and call Run() on it. This will run…
Nico Schertler
  • 32,049
  • 4
  • 39
  • 70
2
votes
3 answers

iOS Efficiency File Saving Efficiency

I was working on my iOS app and my goal is to save a file that I am receiving from the internet bit by bit. My current setup is that I have a NSMutableData object and I add a bit of data to it as I receive my file. After the last "packet" is…
Gavy
  • 1,939
  • 1
  • 19
  • 20
1
vote
1 answer

perl process inlude files recursively

I would like to process files recursively. I have a config file, and this config file can include an "include" statement. Once the include-statment is identified, the file shall be processed. It could happen, that in the file processed again an…
averlon
  • 325
  • 3
  • 14
1
vote
2 answers

Is a FileHandle.synchronize() still necessary on iOS if closing the file?

On Windows and Linux systems an accidental power loss could cause a recently written file to be corrupted with junk or null bytes (very often when running inside non-Hyper-V VMs which would otherwise have aligned the .vhdx with the physical storage…
oxygen
  • 5,891
  • 6
  • 37
  • 69
1
vote
0 answers

How to fix Stale File handle Issue in java application?

I have a java application, which generates files (ranging from a few Mb to 100s of Mb). I am getting this error when I try to close the file in the "finally" block. Flow: Application read the database, create a CSV file in the server in a specified…
Hemant Kumar
  • 135
  • 1
  • 1
  • 12