Questions tagged [fileslurp]
11 questions
91
votes
4 answers
How to combine the sequence of objects in jq into one object?
I would like to convert the stream of objects:
{
"a": "green",
"b": "white"
}
{
"a": "red",
"c": "purple"
}
into one object:
{
"a": "red",
"b": "white",
"c": "purple"
}
Also, how can I wrap the same sequence into an array?
[
{
…

Jennifer M.
- 1,398
- 1
- 9
- 11
6
votes
1 answer
File::Slurp into a multi-GB scalar - how to split efficiently?
I have a multi-GB file to process in Perl. Reading the file line-by-line takes several minutes; reading it into a scalar via File::Slurp takes a couple of seconds. Good. Now, what is the most efficient way to process each "line" of the scalar? I…

Chap
- 3,649
- 2
- 46
- 84
5
votes
2 answers
File::Slurp faster to write a file to perl
I have a perl script where I am writing out a very large log file. Currently I write out my file in the 'traditional' Perl way of doing it:
open FILE, ">", 'log.txt';
print FILE $line;
.....
close FILE;
I've heard a lot of good things about…

srchulo
- 5,143
- 4
- 43
- 72
3
votes
3 answers
Perl: Add hash as sub hash to simple hash
I looked at the other two questions that seem to be about this, but they are a little obtuse and I can't relate them to what I want to do, which I think is simpler. I also think this will be a much clearer statement of a very common problem/task so…

skeetastax
- 1,016
- 8
- 18
2
votes
1 answer
Reading UTF8 files with File::Slurp
I try to read an HTML file with the Perl module File::Slurp:
binmode STDOUT, ':utf8';
my $htmlcontent = read_file($file, {binmode => ':utf8'});
But when I print the $htmlcontent variable, some characters are not understood, due to French accents or…
user4960633
1
vote
1 answer
Perl6::Slurp of DATA
could someone please post a reference example of Perl6::Slurp with the DATA filehandle?
use strict;
use Perl6::Slurp;
my $contents = slurp(*DATA);
__END__
line 1
line 2
fails.

ivo Welch
- 2,427
- 2
- 23
- 31
1
vote
1 answer
read_file 'File::Slurp' - sysopen: No such file or directory
What could be wrong here?
I am trying to display the content of an existing file:
perl -MFile::Slurp -e 'print File::Slurp->read_file("/tmp/001.jpg", { binmode => ":raw" } ) if -e "/tmp/001.jpg"; '
and I get the error:
read_file 'File::Slurp' -…

Tudor Constantin
- 26,330
- 7
- 49
- 72
0
votes
0 answers
Can't export symbol at File/Slurp.pm line 10 in perl
Perl version is 5.26.1
Background : We have migrated our machines recently from SLES11 to SLES12.
Error : Can't export symbol: at File/Slurp.pm line 10.
The issue happens randomly and only for one specific file which we are reading.
The same script…

pupil
- 185
- 9
0
votes
0 answers
What is wrong with my IOException in my slurp method?
I am making a slurp method which in essence accepts a File and returns its contents as a String.
I keep getting exception errors and I am not sure why. I don't know if I'm throwing the wrong exception, but I need help on addressing why I am…

Adan Vivero
- 422
- 12
- 36
0
votes
2 answers
Regex substitution in perl
I have a string that needs to be inserted before semi-colons(;) in all create table ddls found in a file.
CREATE TABLE Persons
(
PersonID int,
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),
City varchar(255)
);
The output…

May
- 1,158
- 2
- 13
- 24
0
votes
1 answer
multiline matching PERL
I have a quick question..
I am trying to match a specific mulitline instance. The problem is that when I execute my code, it only prints what I have edited and not the entire file with it.
For example. This is my input:
JJJ
1234 123.00 …

joshE
- 81
- 2
- 8