Programming pearls are unique problems or solutions that might puzzle a programmer, they have grown from real problems that have irritated real programmers, just as natural pearls grow from grains of sand that irritate oysters.
Questions tagged [programming-pearls]
41 questions
0
votes
4 answers
arithmatic operation in shell script
My shell script look like this ,
sOneCount =5
sZeroCount=12
aa=`expr $sOneCount / $sZeroCount`
successRate=`expr $aa \* 100
since 5/12 results in 0.416 and then 0.416*100 it should give 41.6
but i am getting "successRate" as 0.
Its rounding off…

harish
- 9
- 1
- 3
0
votes
0 answers
How to identify the number for a sequence to generate unique value across 4 data centers
I have three data-centers with 3 oracle databases replicating using Golden gate. Every database has trigger-sequence mechanism to generate Primary keys. We are adding one more data-center to the architecture with a DB.
Logic we are using to avoid…

Nikhil Mehta
- 25
- 1
- 5
0
votes
2 answers
Replace Nth String Match In File
So I've found many solutions to using sed s/regexFind/replacement/n to replace the nth occurence of a word in a line.
For example s/hello hello hello/world/2 > hello world hello
What I'm looking to do however is update the update the third match…

averyrandomusername
- 15
- 3
0
votes
1 answer
how can i import in Matlab text file using PERL script?
i try to import huge text file (~5 million lines). I try with this script
aaa = perl('importFile.pl',fileName);
where "importFile.pl" is
use strict;
use warnings;
while (my $row = <>) {
chomp $row;
print "$row\n";
}
but nothing…

claudio
- 11
- 2
0
votes
1 answer
"Programming Pearls": conflicting types for qsort
This is the solution of Programming Pearls in column 1.6_1:
> #include
int intcomp(int *x, int *y)
{
return *x-*y;
}
int a[1000000];
int main(void) {
// insert code here...
int i,n=0;
while (scanf("%d",&a[n])!=EOF) {
…

zyMacro
- 675
- 7
- 14
0
votes
1 answer
Pearl: How can I get compressed data that zlib understands
I'm trying to create a zipped file in Pearl that can be consumed and deflated in an IPad application using zlib. The current zip modules in Pearl (i.e. IO::Compress::Zip ) seems to output incorrect data for the zlib to understand. I'm using z_stream…

user2665402
- 169
- 2
- 9
0
votes
1 answer
Maximum subarray
In the column 8 of "programming pearls". There is a maximum subarray problem.
Problem :
The input is a vector x of n floating-point numbers; the output is the maximum sum found in any contiguous subvector of the input. To complete the problem…

Fihop
- 3,127
- 9
- 42
- 65
0
votes
1 answer
Uploading Sawtooth Software ACA Survey to web using personal website hosting
The software created a Web Upload folder for me, which I uploaded to the site using an FTP Client (specifically WS_FTP). The first lines of the pearl files say "#!usr/bin/pearl" that I changed to "/home/calakpsi/pearl". However, when I execute the…

AKJ87
- 1
-1
votes
1 answer
What is -quiet in TCL
I need what below if statement gives true or false, Also please explain about "quiet"
if {[sizeof_collection[get_pins $source-quiet]]>0}
What is gives?
Note:-
$source is I_TEST_MODE4.
-1
votes
1 answer
I need to copy a set of files from their original location to a new folder
I’m starting a project that requires assembling files and linking them to around 140 lines in a pdf table of contents (one file per line). The thing is that I have to do this 80 times and it seems very tedious to do it manually each time.
The TOC…

Paul L
- 1
-1
votes
2 answers
Add up a column with the same key feature in csv file
The columns including two key features, one column to sum up, and some other (e.g,1) column that is not important.
key1, key 2, pr, trivial
abc, 43, 23, haha
abc, 43, 456, hok
bcd, 23, 89,kol
I want to add the sum column with the SAME…

user864128
- 147
- 3
- 9