Questions tagged [perl]

Perl is a language optimized for scanning arbitrary text files, extracting information from those text files, and printing reports.

Filter by
Sorted by
Tagged with
4
votes
0answers
32 views

Get specific lines from a huge text file

I had a 50 Gb text file (ca. 45 mln lines) and needed to extract about 1500 lines from it. I knew their indices, that is, line numbers. Those 1500 lines were spread across the whole file up to the ...
3
votes
1answer
30 views

Frequency analysis for simultaneous dice rolls - follow-up

I had another question for my Perl class assignment. Related question: Frequency analysis for simultaneous dice rolls ...
7
votes
0answers
68 views

Frequency analysis for simultaneous dice rolls

My professor told me to optimize my perl code, but he wouldn't tell me what exactly - just make it simpler. I changed some little things but nothing major. Am I missing something? The task was: ...
7
votes
1answer
60 views

This perl script renames all files in a directory to have an equal amount of digits

I took a lot of pictures with my camera and I wanted to make a time-lapse out of them. The camera saved the pictures as picture1, ...
6
votes
1answer
65 views

Extract strings from nested array in Perl

Extract the strings from nested arrays in Perl. It prints: a, b, c, d, E ...
3
votes
1answer
84 views

Automation of application utilities on Linux

I am working on a project to automate utilities of our application on Linux. The utilities are basically chunks of programs with specific options for specific tasks. They are run like UNIX commands. ...
6
votes
0answers
68 views

DSL for Makefile generation for dotfiles using symlinks

As I explain in my rant, I have been searching for a replacement to hand-crafted POSIX-make-compatible makefiles to manage my dotfiles (which use symlinks). I ...
9
votes
2answers
877 views

Count line of code for a JavaScript project

Here is my bash script that I just wrote to count line of code for JavaScript project. It will list number of: Comment lines Blank lines All lines Here is my script: ...
8
votes
0answers
50 views

Checking whether a string fragment could be part of a longer UTF-8 string

Although UTF-8 validation is a common task, I'm trying to solve a slightly different task; given a string of bytes, work out whether it could potentially be a fragment of a valid UTF-8 string. That's ...
24
votes
4answers
2k views

Perl CGI script to serve a PDF file

In a different post I showed the following Perl CGI script. Someone in the comments said that "You're using a lot of very unperlish syntax, and I'd like to give you some feedback". So, here it ...
7
votes
1answer
61 views

Perl one-liner for parsing host names from ssh config file

Here is the working code (intended to be executed with perl -e '<code>' ~/.ssh/config): Actual version: ...
13
votes
1answer
122 views

New Moon (not Twilight) Calculator

Photography is one of my hobbies, and, living in Canada, I have the possibility of seeing, and photographing, the Aurora Borealis (Northern Lights). Now, these happen when there's ionization in the ...
10
votes
1answer
118 views

Convert British and Irish National Grid references to or from WGS84 geodetic coordinates

I've been using this wgs84togrid program for a few years. It converts in both directions between National Grid coordinates for GB or Ireland (beginning with a ...
7
votes
1answer
111 views

Git pie - Perl oneliner for Git

I often make changes on my code-base and manually using sed, awk or perl -pi -e is not ...
4
votes
0answers
102 views

Perl PasteBin scraper

I'd like to optimize my code and get a better of understanding of how I can perform the task I am doing better. I've only used Perl threads about 3 or 4 times now. The purpose of my script / code ...
3
votes
0answers
170 views

Using Perl's fork() to parallelize processing

I use bash scripts to process last names through a Perl program, and I parallelize the execution like this, by name initials: ...
8
votes
3answers
230 views

Executable wrapper around Perl script on Windows

I have ack (the searching tool) "installed" as a single file at C:\ack\bin\ack.pl on a Windows 10 machine and was wondering how to make it executable from the ...
2
votes
0answers
112 views

Lemonbar + perl scripting for workspaces

I have made this program to simulate polybar's bspwm module. So far, it works flawlessly, however it consumes too much ram and cpu ie 16-30%. I suspect it is the while loop causing the trouble but ...
7
votes
1answer
1k views

Spherical Voronoi diagram, binary splitting approach [closed]

EDIT: My code DOES not work, see https://gis.stackexchange.com/questions/294380/if-rectangle-corner-points-have-same-nearest-neighbor-does-whole-interior Given 5 (currently hardcoded) cities, this ...
7
votes
0answers
44 views

Perl Script to import flat-file versioned files into git repositories

I wrote a perl script to import local files with "File-Ending-Versioning" (like file.1.12.pm) into a git repository. I tried to use the concept of roles in this script and I am not shure if I applied ...
7
votes
2answers
205 views

Extending Mojo::Promise

First time poster, be gentle. I wanted something similar to Mojo::Promise->all, except with an option to discard certain rejected (or, I guess, resolved) promises dependent on rejection value, as ...
6
votes
1answer
123 views

Perl script to set IP settings

This is my first go at a Perl script to (semi-) automate setting the correct IP settings. I use it to configure a virtual machine after creation. It's also my first Perl script as a whole, so I'm ...
4
votes
2answers
78 views

Assigning several variables from request URL using regexes

I refactored some of my code: Summary: This implementation works with PSGI/Plack. It gets the URL from $env->{PATH_INFO} and assigns a different variable ...
8
votes
1answer
83 views

Highly nested bioinformatics processing

I have a script for parsing BAM files. The script's input thus is lines like ...
4
votes
2answers
334 views

Matching Fasta file header and section of sequence, printing each header only once

I have a Fasta file which I am opening and reading. I need to search for certain regions of the DNA sequence and, for each match found, print the sequence header followed by all matches within that ...
3
votes
1answer
767 views

Writing a log file with threads

Here are all the threads write the log file. I want to know if the below script is fine, if it needs any modifications, and whether I am utilising threads properly to execute this code quickly. <...
6
votes
1answer
109 views

Fastest way to find a string delimited by two words

Motivated by this question, I created a simple benchmark for investigating what is the fastest way to extract a substring given two delimiting words: ...
6
votes
0answers
75 views

Perl gradient noise generator

I'm working on 2-D top-down graphics engine, and need a way to simulate clouds. My idea was that I could create a layer comprised of a matrix of rectangles whose alpha value would be picked from a ...
10
votes
3answers
403 views

Robust, know-entropy password generator

My use case is I want a password generator that generates memorable and robust passwords for users, to give me a known minimum entropy. For this - I'm approximating set of Consonant-Vowel-Consonant ...
9
votes
1answer
201 views

Creating a Perl webserver

Intro Finally had the time to do some wargames again, but I have come to the point where I need to build my own test enviroment to test certain ideas, because I can't test it online. The current ...
6
votes
2answers
122 views

MongoDB Perl Wrapper

I'm trying to create a custom "mongodb perl wrapper". I created the following perl module, which local on my machine runs. My questions to the community are: Would you create the module different? Do ...
4
votes
1answer
458 views

Nagios service alert HTML email builder

I have a well functioning Nagios Core system set up. I wanted to make our alerts both easier to read pertinent information quickly as well as provide additional details from custom host and service ...
8
votes
1answer
86 views

Process files in a directory and upload them to URL

I have some code that I wrote for a personal project which takes, as arguments, a directory and a URL. It then processes the files in the named directory, archives them, and uploads the archive to the ...
4
votes
1answer
95 views

Parallel processing in different directories in Perl

I have some subroutines which I commonly copy & paste into much of my work. I recently posted this on StackOverflow and user simbabque suggested that I post my code here for reviews and comments: ...
10
votes
2answers
3k views

Mocking socket calls in C++

Explanation I'm trying to get better unit test coverage of my server. I needed to mock out some system libraries (I could not find anything that worked easily for C++). Because I did not want to do ...
4
votes
1answer
70 views

a Python2 to Python3 print fixer in perl

Sometimes, I'm reviewing old questions written in Python2, with no parenthesis around print statements. Or I'm changing one of my older codes, also without ...
8
votes
2answers
412 views

Letter frequency analysis (Breaking Vigenere)

I'm trying to improve my Perl and am doing some wargames online. I wrote a small utility to help me pass a stage. The main weakness of a simple substitution cipher is repeated use of a simple key. ...
11
votes
1answer
161 views

Becoming a Perl bandit

I've posted a few questions about natas a wargame. But I'm stuck at natas29 it has to do with Perl. I've never coded in Perl before. Thus to help me beat the last few levels, I decided it is time to ...
6
votes
3answers
2k views

Removing empty lines from a file

The below code removes empty line from test.txt. I posted this answer on StackOverflow but someone commented that this code needs review and suggested me to post ...
7
votes
1answer
288 views

Remotely collect server data using Net::OpenSSH Perl

I am newbie in Perl programming and currently trying to use Net::OpenSSH module in my code, my new code as below which the task is to run multiple command in remote server, Code as below:: ...
5
votes
2answers
64 views

Extracting parts of filenames from an array

I am very new to perl. So far I love it, my new favorite interpreted language. I am quickly learning that perl has MANY 'tricks' to it. The following code extracts file names out of one array and into ...
3
votes
1answer
54 views

Access download API

Please review the Perl script on the link below for any bad practice which could potentially blow up in my face. The code itself works, but take note that I removed the real API endpoint hostname, so ...
1
vote
2answers
133 views

Searching for words in a dictionary

I'm using an open source program called MElt which lemmatize (give the lemma example:giving-->give) of words. MElt works on Linux and it's programmed in Perl and Python. So far it's working good but ...
5
votes
0answers
247 views

Perl crypto-scraper

I created a crypto-scraper script to scrape crypto currencies from Coingecko. I have used the library LWP::UserAgent and now I want to know if you could give me ...
5
votes
1answer
280 views

Finding the first non-repeated character in a string

Given a string, find the first non-repeated character in it. E.g. "yellow" should return "y" There are several solutions for this in other languages but I haven't seen one written in Perl. My main ...
5
votes
1answer
782 views

Markov chain-based random text generator in Perl

This is the first thing I've written in Perl besides one-liners. It just generates random text based on a text file. I was inspired by this. Any tips on making this better are welcome. I'd especially ...
5
votes
2answers
191 views

Read lines from a file in chunks

I created a function to read lines from an file into chunks. My hidden agenda in creation this script was in python the yield function in interaction with chunks. The script works fine, but now i ...
6
votes
1answer
163 views

Read a file as 4-line chunks

I want to extract the file content into chunks with perl. I have prepared some code snippets which read a file content into chunks. I want to know what is the best way in Perl? Example-File-Content: ...
4
votes
1answer
104 views

Sokoban solution rotator in Perl

This is a project I always meant to do, but now that I've done it, I am wondering if/how I can do it better. I've made some fixes and done general testing on the parsing to make sure it works, but I ...
6
votes
1answer
1k views

Perl script to check disk usage and report via email

Due to lack of central configuration management I am avoiding any Perl modules which would need to be installed on each of a great many servers. Result is more code than would normally be required in ...

1 2 3 4 5