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
5
votes
2 answers

How can I treat many log files as one virtual file in Perl?

I've got multiple access logs in the logs directory, following the naming convention below: access.log.1284642120 access.log.1284687600 access.log.1284843260 Basically, the logs are "rotated" by Apache per day, so they can be sorted in order. I am…
Michael Mao
  • 9,878
  • 23
  • 75
  • 91
5
votes
2 answers

Timer that supports overlapped I/O (for IOCP)?

I need to add timers support in an application based on I/O Completion Ports (IOCP). I would like to avoid the use of a specific thread to manage timers. On Linux, you can create a timer that delivers expiration notifications via a file descriptor…
Cédrics
  • 1,974
  • 11
  • 13
5
votes
3 answers

Program stuck, pipe file descriptor open when shouldn't?

I am creating a small shell that can read commands. When I run my program and type:"cat file.txt > file2.txt" it creates the file and then it gets stuck at the line: if(execvp(structVariables->argv[0], argv) < 0). (waiting for input/output??). If I…
Fjodor
  • 529
  • 1
  • 7
  • 19
5
votes
1 answer

QSerialPort effect on `/dev/ttyS*` after process end?

When a Qt app using QSerialPort experiences a non-clean shutdown (e.g. due to receiving and not handling SIGINT), how is the file descriptor of the serial port affected? After running an app that opens a QSerialPort on /dev/ttyS0, then quitting with…
Kyle Strand
  • 15,941
  • 8
  • 72
  • 167
5
votes
3 answers

How can a Perl subroutine distinguish between file names, file handes, *DATA, and *STDIN?

If I have a function that might be passed a file name or various file handles or typeglobs, how can the function distinguish among these arguments -- including telling the difference, for example, between *DATA and *STDIN? Updated code, based on…
FMc
  • 41,963
  • 13
  • 79
  • 132
5
votes
2 answers

What is the -t used for in this Perl code

I read in the perldoc that the -t file operator is used to decide if a filehandle is opened to a tty or not. Then i read what a tty was and from what i understand it's an old term for a terminal? My main question however is what this code is used…
rage
  • 1,777
  • 5
  • 25
  • 36
5
votes
4 answers

How can I read from a Perl filehandle that is an array element?

I quickly jotted off a Perl script that would average a few files with just columns of numbers. It involves reading from an array of filehandles. Here is the script: #!/usr/local/bin/perl use strict; use warnings; use Symbol; die "Usage: $0…
pythonic metaphor
  • 10,296
  • 18
  • 68
  • 110
5
votes
2 answers

What happens internally when you have < FH >, <>, or < * > in perl?

I apologize if this question sounds simple, my intention is to understand in depth how this (these?) particular operator(s) works and I was unable to find a satisfactory description in the perldocs (It probably exists somewhere, I just couldn't find…
heypano
  • 185
  • 1
  • 8
5
votes
2 answers

How can I convert a string to a file handle in perl?

I have a very big-size string $s="dfasdfasdfafd....", of nearly 1,000,000 characters. I want to convert it to a file handle, making it look like this string is read from a file. But I don't want to store it to a temp file and read it. Can anyone…
wuchang
  • 3,003
  • 8
  • 42
  • 66
5
votes
1 answer

Why does an open DLL Handle not protect file from being moved?

I just had a surprising bug where a DLL file that was loaded using the LoadLibrary API call was renamed while being loaded. Apparently, having an open DLL handle on a file does not prevent that file from being renamed, or even moved to a different…
ComicSansMS
  • 51,484
  • 14
  • 155
  • 166
5
votes
3 answers

Send file handle as argument in perl

Is it possible to send a file handle as an argument to a subroutine in PERL? If yes, can you help with a sample code snippet showing how to receive it and use it in the subroutine?
Daanish
  • 1,061
  • 7
  • 18
  • 29
5
votes
2 answers

winsock socket as file handle

i have been scratching my head and been searching for an answer for this for hours now. Basically what I do is open a socket to some other machine and reading the data from it. This socket is than "converted" to a file handle via an fdopen call…
André
  • 61
  • 1
  • 4
4
votes
5 answers

Perl glob and filehandle problems

Ok, I have a bit of an issue here. I realize that I don't need to set a $handle to *::HTML to get this snippet to work, however this code is taken out of context from its use and I do in fact need this to work with the $handle. The output I am…
user105033
  • 18,800
  • 19
  • 58
  • 69
4
votes
2 answers

WIndows: subprocess making new console window, losing stdin/out

I'm using Windows Vista and Python 2.7.2, but answers needn't be in Python. So I can start and interact with a subprocesses stdin/stdout normally (using python), for command-line programs such as `dir'. - however - the program I now want to call…
asdf
  • 43
  • 1
  • 4
4
votes
1 answer

How to do cURL PUT requests with a php://memory file handle?

I'm using a 3rd party PHP class to access an API, it has got the following code: $fh = fopen('php://memory', 'w+'); fwrite($fh, $xml); rewind($fh); $ch = curl_init($req->to_url() ); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch,…
Ali
  • 261,656
  • 265
  • 575
  • 769