filehandle

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 $command_out, "-|", $command ); close $command_out; but this does open( my $command_o...

How to assure that filehandle.write() does not fail due to str/bytes conversions issues?

I need to detect if a filehandle is using binary mode or text mode - this is required in order to be able to encode/decode str/bytes. How can I do that? When using binary mode myfile.write(bytes) works, and when in text mode myfile.write(str) works. The idea is that I need to know this in order to be able to encode/decode the argument ...

How can I pass a filehandle to Perl Expect's log_file function?

I feel stupid for asking this, but I've tried a couple things and I'm not sure where to go with it. From the Expect.pm documentation: $object->log_file("filename" | $filehandle | \&coderef | undef) Log session to a file. All characters send to or received from the spawned process are written to the file. I'd like to pass t...

Appending to a global file handle, is it bad?

Lets say there are multiple functions throughout my program that need to append data to a certain file. I open the file at the beginning of the program with a global file handle so I can append to it wherever I need to. (Note that I know I could pass the file handle as an argument to the functions but that is not the purpose of this ques...

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 trying to "read them one after another", so that they can be treated as one log file. ...

How can I test if I can write to a filehandle?

I have some subroutines that I call like this myWrite($fileName, \@data). myWrite() opens the file and writes out the data in some way. I want to modify myWrite so that I can call it as above or with a filehandle as the first argument. (The main reason for this modification is to delegate the opening of the file to the calling script ...

Create a certain size file and filled with no data on iOS

Hi, I'm developing an iphone app, I need to create a certain size file on filesystem and filled with NO data first, then seek to a offset and write data when get data from somewhere else How can I do it? ...

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 parameter to a function that expects a filehandle may not cause your function to a...