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?
...
I have an object with a method that returns a filehandle, and I want to read from that handle. The following doesn't work, because the right angle bracket of the method call is interpreted as the closing angle bracket of the input reader:
my $input = <$object->get_handle()>;
That gets parsed as:
my $input = ( < $object- > ) get_handl...
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, buf, n);
assert(n==write(w_handle, buf, n));
Both filehandles (r_handle and w_handle) ...
I'm trying to read a binary file 40 bytes at a time, then check to see if all those bytes are 0x00, and if so ignore them. If not, it will write them back out to another file (basically just cutting out large blocks of null bytes).
This may not be the most efficient way to do this, but I'm not worried about that. However, right now I'...
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 file and fp1 is the destination file.
The program executes without any error, but the image...
For example:
open (PS , " tail -n 1 $file | grep win " );
I want to find whether the file handle is empty or not.
...
open(my $fh, '>', $path) || die $!;
my_sub($fh);
Can my_sub() somehow extrapolate $path from $fh?
...
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 the block of code that is used for opening a file:
/**
* Create a Filestream, Buffer, a...
Here's the relevant excerpt from the documentation of the ref function:
The value returned depends on the type of thing the reference is a reference to. Builtin types include:
SCALAR
ARRAY
HASH
CODE
REF
GLOB
LVALUE
FORMAT
IO
VSTRING
Regexp
Based on this, I imagined that calling ref on a filehandle would return 'IO'. Surprisingl...
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 115
1 25 34 36 38 41 52 54 59 63 67 76 85 86 90 93 98 107 113
2 3 9 16 24 28
2 3 10 1...
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 = shift;
$self_->{_fd} = $fd;
}
sub write {
my $self = shift;
print $self->{_fd} ...
Using perl 5.8.8 on windows server I am writing a perl cgi script using Archive::Zip with to create on fly a zip that must be download by users: no issues on that side. The zip is managed in memory, no physical file is written to disk using temporary files or whatever. I am wondering how to allow zip downloading writing the stream to the...
I don't know this concept is there or not. Can we store the Files and related information in MySQL database ? If the answer is Yes then how ?
...
In perl, I often need to run a child process, send some input to it, and then read its output. There are a number of modules to do this, but they all seem to require you to pass in pre-existing variables, which are then modified by the function to contain filehandles. Here is an example from the Synopsis of IPC::Open3:
my ($wtr, $rdr, $...
I'm applying UTF-8 encoding to STDIN and STDOUT. However how do I make sure that I apply UTF-8 encoding to the file that I pass to my code below (<> will read from a file instead of STDIN if a text file is passed on the command line) in as few lines as possible.
use open qw(:std :utf8)
while (<>) {
print;
}
...
Hello,
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 (see timerfd.h man), so it's great to use it for example with epoll if your applic...
Is there a filehandle/handle for the output of a system command I execute in Perl?
...
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 inode)? Is there any way to ensure no other process has an open file descriptor on the file...
I'm trying to get my application to display an icon for a custom file extension using the following code:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>My Custom Extension</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<...
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 safely handle any files that are open when a fatal error is raised, i.e. close f...