Questions tagged [perl]
Perl is a language optimized for scanning arbitrary text files, extracting information from those text files, and printing reports.
228 questions
2
votes
0
answers
77
views
Replace real path with symlink
zoxide is a replacement for cd that allows fuzzy matching against commonly accessed directories (e.g., ...
6
votes
1
answer
111
views
Bash/perl function to search `lsblk` for drives whose partitions all match a filter
The following function searches for disks whose partitions all have an attribute that match a filter when listed with lsblk. Comments are in TomDoc format.
...
4
votes
1
answer
104
views
Bash/perl function for filtering and formatting `/etc/fstab`
The following function filters and formats /etc/fstab for future use. Comments are in TomDoc format.
...
5
votes
1
answer
539
views
A file renamer in Perl that gets rid of spaces, commas, dots, and dashes
I often find myself working with files I get from other users that mostly work on Windows machines (I, myself, am on a macOS) and they tend to name their files in all sorts of (weird & difficult ...
6
votes
2
answers
783
views
Python Package Index recursive package dependency resolver
My work has an isolated network that developers write applications to run inside of. These developers often write Python code. This Python code often requires modules from the Python Package Index (...
5
votes
1
answer
190
views
Processing large blocklists with GNU Parallel
This is an ongoing project that has undergone a major update to speed up list processing. Here is the homepage for anyone interested.
It processes lists defined in ...
5
votes
0
answers
210
views
Dijkstra's algorithm in Perl
I have this Perl module project.
My implementation of the Dijkstra's algorithm follows:
...
5
votes
1
answer
108
views
Bidirectional Dijkstra d-ary heap
This is my very first data structure written in Perl for a d-ary heap:
...
4
votes
2
answers
169
views
ds - directory switcher - a *nix command line utility for tagging the directories and switching between them via tags (Perl + bash)
I have this program for tagging directories and switching between the folders via tags. The front end is written in Bash (version 4.4.23) and the back end in Perl (5.26.1).
Critique request
Since this ...
7
votes
1
answer
800
views
Remove duplicate lines without sorting or removing empty lines
I am using the following one-liner to remove duplicate non-empty lines without sorting:
perl -ne 'if ( /^\s*$/ ) { print } else { print if ! $x{$_}++}'
Empty (...
5
votes
1
answer
501
views
Converting IDN domains to Punycode in Perl
Description
This script takes any domain input from STDIN and converts unicode domains into punycode.
Features
Any domains that throw an error get ignored.
When fed any ASCII domains, they just pass ...
3
votes
2
answers
206
views
Amplifying this DDoS code
I am trying to make a DDoS code, and here's what I have so far. I am trying to make it more efficient and powerful, just for testing purposes. I'm new, and I was wondering if I could do that. Is ...
8
votes
1
answer
380
views
Parse data from Input file and print results
I have written a script which does parsing to the input file and take out some values from them with respect to the node and print the data accordingly.
Below is my script, and it works as expected:
<...
9
votes
1
answer
347
views
Is possible to use script for dependencies in c++?
I wanted to make a script that would parse a main file (with int main()) look in its #include "..." local headers, and ...
12
votes
4
answers
3k
views
Simple C transpiler
I wrote a simple transpiler (that may be a bit of a stretch) in perl to cut down on some boiler plate code.
I'm very new to perl, this being maybe my third ever project in it. My main question would ...
2
votes
3
answers
172
views
Perl - Splitting a string
I've decided to work on my Perl skills. I've written a small subroutine that splits a string based on an optional delimiter. I'd like any feedback on this program so I can kick bad habits to the curb. ...
7
votes
1
answer
209
views
Custom template system with introspection
I know I never have to reinvent the wheel, but I did because I need speed performance. Also, I need these features:
introspection or metaprogramming
actuate like API backend
private variables ...
5
votes
2
answers
518
views
Get specific lines from a huge text file
I had a 50 GB text file (about 45 million 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 ...
3
votes
1
answer
69
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
...
9
votes
1
answer
158
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
1
answer
143
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
1
answer
156
views
Extract strings from nested array in Perl
Extract the strings from nested arrays in Perl.
It prints: a, b, c, d, E
...
8
votes
1
answer
282
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
2
answers
3k
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
1
answer
185
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
1
answer
182
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:
...
12
votes
2
answers
302
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 ...
5
votes
1
answer
231
views
PasteBin API scraper for new public pastes that appear at regular intervals
I'd like to optimize my code and get a better 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 code block is to ...
5
votes
1
answer
968
views
Using Perl's fork() to parallelize processing of last names
I use bash scripts to process last names through a Perl program, and I parallelize the execution like this, by name initials:
...
4
votes
1
answer
344
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 (16-30%). I suspect it is the <...
10
votes
4
answers
483
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 ...
8
votes
1
answer
180
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 ...
5
votes
2
answers
154
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 ...
9
votes
2
answers
204
views
Highly nested bioinformatics processing
I have a script for parsing BAM files. The script's input thus is lines like
...
7
votes
2
answers
318
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
1
answer
405
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 ...
7
votes
1
answer
174
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:
...
10
votes
1
answer
181
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
1
answer
488
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
1
answer
147
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 ...
5
votes
1
answer
317
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:
...
5
votes
2
answers
163
views
Python2 to Python3 print fixer in Perl
Sometimes, I'm reviewing old questions written in Python2, with no parentheses around print statements. Or I'm changing one of my older codes, also without ...
25
votes
4
answers
3k
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, ...
8
votes
2
answers
525
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
1
answer
249
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
3
answers
4k
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
2
answers
433
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 ...
9
votes
2
answers
739
views
Remotely collect server data using Net::OpenSSH
I am newbie in Perl programming and currently trying to use Net::OpenSSH module in my code. My code as below which the task is to run multiple commands in remote server:
...
10
votes
2
answers
7k
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
2
answers
150
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 ...