filehandle Questions
3
Solved
I want to create a simple IO object that represents a pipe opened to another program to that I can periodically write to another program's STDIN as my app runs. I want it to be bullet-proof (in tha...
Car asked 13/5, 2012 at 6:34
2
Solved
In Perl I often read data in from the filehandle __DATA__ at the end of the script:
while (<DATA>) {
chomp;
say;
}
__DATA__
line1
line2
I find this quicker for testing code etc than rea...
Optimistic asked 14/7, 2016 at 8:17
4
Solved
How can I use isinstance to determine the 'type' of a file object, such as in the expression:
>>> open(file)
Unconditioned asked 1/7, 2014 at 2:0
4
Solved
What are the differences between this two examples?
#!/usr/bin/perl
use warnings;
use 5.012;
my $str = "\x{263a}";
open my $tty, '>:encoding(utf8)', '/dev/tty' or die $!;
say $tty $str;
close...
Ululant asked 12/1, 2011 at 9:35
3
Solved
I'm working in a program where the user can pass a -o file option, and output should be then directed to that file. Otherwise, it should go to stdout.
To retrieve the option I'm using the module g...
Wong asked 14/8, 2011 at 19:21
2
Solved
I am playing around with cloning a remote existing repo with jGit following the guide here:
https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/CloneRemo...
Diacid asked 1/8, 2015 at 17:29
2
Solved
In the following small code, I do not get an error or a warning for lines [09] and [18]. The only warning I get is with line [21]:
use strict; # [01]
use warnings FATAL => 'unopened'; # [02]
# ...
Zwart asked 26/2, 2021 at 4:32
2
Solved
Perl's odd behavior when reassigning a filehandle variable from STDOUT to a file without undef()
When executing the following simplified code:
use strict; # [01]
use warnings FATAL => 'unopened'; # [02]
# [03]
my ($inHandle, $outHandle) = (\*STDIN, \*STDOUT); # [04]
print $outHandle "...
Tazza asked 25/2, 2021 at 1:24
2
Solved
I was thinking about doing
open(*STDIN, "<", "/dev/null" );
open(my $fh, "-|", "/bin/bash", "/tmp/foo");
print for <$fh>;'
However, I wou...
Quinquennium asked 2/9, 2020 at 17:7
5
Solved
I need to figure out how to write file output to a compressed file in Python, similar to the two-liner below:
open ZIPPED, "| gzip -c > zipped.gz";
print ZIPPED "Hello world\n";
In Perl, this...
Gigantes asked 28/11, 2011 at 21:54
5
Solved
I'm using ant 1.8.0 and java 1.6.0.17 and I'm running into a strange problem.
In my build.xml, I have a simple task that compiles the code
<javac destdir="${dir.build.classes}" debug="on">
...
Milky asked 20/2, 2010 at 0:8
3
Solved
I am getting a "csv file" from a vendor (using their API), but what they do is just spew the whole thing into their response. It wouldn't be a significant problem except that, of course, some of th...
Craniology asked 23/3, 2020 at 17:47
3
Solved
I have grades.tsv file with three columns that show students' names, subjects and grades:
Liam Mathematics 5
Liam History 6
Liam Geography 8
Liam English 8
Aria Mathematics 8
Aria History 7
Aria G...
Mallet asked 30/1, 2020 at 17:21
4
Solved
If you read an entire file with content = open('Path/to/file', 'r').read() is the file handle left open until the script exits? Is there a more concise method to read a whole file?
Newcastle asked 13/9, 2011 at 23:44
2
My bosswrap.pl will generate arbitrary arrays containing whitespace in the elements. It repeatedly sends the array by a system call to wrapped.pl, which creates STDOUT based on the array.
Subsequ...
Crin asked 23/11, 2019 at 19:20
3
Solved
Does STDOUT have a "type"?
printf STDERR ("STDOUT = %s\n", STDOUT);
printf STDERR ("\*STDOUT = %s\n", *STDOUT);
printf STDERR ("\\\*STDOUT = %s\n", \*STDOUT);
Produces:
STDOUT = STDOUT
*STDOUT ...
Joon asked 23/7, 2019 at 2:13
3
Solved
How can I use __DATA__ twice?
#!/usr/local/bin/perl
use warnings;
use 5.012;
while ( <DATA> ) {
print;
}
while ( <DATA> ) {
chomp if $. == 1;
print scalar reverse;
print "\n" if ...
Merrow asked 16/12, 2010 at 10:17
4
How do I find all the open files in a process (from inside itself)?
This seems useful to know after a fork() (before exec()).
I know of the existance of getdtablesize() and the more portable sysc...
Padding asked 22/8, 2009 at 7:22
1
Solved
In Perl 5, I can open a filehandle on string like this:
open my $kfh, "<", \$message->payload;
I have a scenario that uses string as a filehandle and passes it to the open method:
my $fh ...
Fateful asked 18/7, 2018 at 16:56
2
I have a huge pipeline written in Python that uses very large .gz files (~14GB compressed), but need a better way to send certain lines to an external software (formatdb from blast-legacy/2.2.26). ...
Premiership asked 5/5, 2015 at 20:17
2
Solved
It is used on Stack Overflow all the time but I really don't understand it, nor can I get it to work. However it seems like a really good testing tool.
How do I get the script to read in everythin...
Catkin asked 23/10, 2017 at 19:40
2
I have following query in Perl regarding the accessing of file handlers.
Consider the following code snippet which describes the exact scenario.
Main.pl
#!/usr/bin/perl -w
use warnings;
use stri...
Palecek asked 11/11, 2017 at 6:48
1
We use Retrofit/OkHttp3 for all network traffic from our Android application. So far everything seems to run quite smoothly.
However, we have now occasionally had our app/process run out of file h...
Dwarfism asked 22/3, 2017 at 10:30
7
Solved
I'm trying to figure out the proper PBP approved way to process a multi line string one line at a time. Many Perl coders suggest treating the multi line string as a filehandle, which works fine unl...
Behling asked 18/9, 2009 at 15:53
3
Solved
I have a Delphi app that regularly writes to a local disk file. Occasionally it is unable to access the file - a sharing violation results when it tries to open it. A retry after a short delay is a...
Essieessinger asked 4/1, 2012 at 12:31
1 Next >
© 2022 - 2024 — McMap. All rights reserved.