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
6
votes
1answer
31 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
50 views

Extract strings from nested array in Perl

Extract the strings from nested arrays in Perl. It prints: a, b, c, d, E ...
6
votes
0answers
51 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
802 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: ...
7
votes
0answers
44 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 ...
7
votes
1answer
56 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: ...
10
votes
1answer
114 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 ...
4
votes
0answers
73 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
137 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: ...
2
votes
0answers
86 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 ...
8
votes
3answers
208 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 ...
7
votes
0answers
43 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 ...
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 ...
7
votes
2answers
191 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
113 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 ...
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 ...
9
votes
1answer
197 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 ...
8
votes
1answer
80 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
89 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: ...
4
votes
1answer
68 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 ...
23
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 ...
8
votes
2answers
399 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
157 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
1k 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 ...
4
votes
2answers
308 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 ...
8
votes
1answer
232 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:: ...
10
votes
2answers
2k 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 ...
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 ...
5
votes
0answers
243 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
265 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 ...
6
votes
2answers
119 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 ...
5
votes
2answers
169 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
157 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
994 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 ...
7
votes
1answer
102 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 ...
1
vote
0answers
84 views

Perl project - subversion

Code running with subversion. example using ...
10
votes
3answers
392 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 ...
0
votes
1answer
102 views

Adding grocery items [closed]

I have full working code, but when I run it, it shows these warnings: ...
4
votes
1answer
80 views

Perl module validate quoted string literal, test with Test::LectroTest

I guess for some motivation: I ripped this out of a larger library I'm half-working on to parse S-expressions and cleaned it up a bit. I'm trying to write a simple function that tests whether a ...
5
votes
2answers
72 views

Script for updating an Oracle database

I have the following piece of Perl script for updating an Oracle database. It's working perfectly fine, but I want to know how I can simplify this script. ...
3
votes
0answers
149 views

Perl nagios plugin to query an api, obtain date from json, and determine if the date is within thresholds

This is an update of Using an API to obtain JSON data and get the date string and determine if data is stale This is a nagios check that will use an API URL, get JSON data, flatten the data into a ...
5
votes
1answer
153 views

Perl script to print multi line log entries which has a match for given pattern

I am a Java programmer and very new to Perl. I decided to work on a simple script that could solve a problem I encounter in my day to day work. This script will search the log file for a pattern and ...
4
votes
1answer
403 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 ...
6
votes
2answers
376 views

Using an API to obtain JSON data and get the date string and determine if data is stale

This is a nagios check that will use an API URL, get JSON data, flatten the data into a usable perl hash, and ultimately obtain a date string. Once the date is obtained, it should recognize the ...
6
votes
1answer
64 views

Perl script to match case law references

I am very new to Perl and decided to work on a simple script that could solve a problem I encounter in my day to day work. The purpose of the code that follows is to search over a body of text and ...
5
votes
1answer
553 views

Perl script to analyze CSV files

I made a Perl script to analyze CSV files. However, it is running a little slow. Is there anything that I can change to make it more efficient? ...