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

learn more… | top users | synonyms

3
votes
0answers
42 views

Simple port scanner

At the moment, prtscn takes a server, and a list of port ranges to test (of the form x,y-z,a-c,d,e etc). The -v option will show ...
4
votes
1answer
30 views

Extend API of complex source-code parsing CPAN module

I am working on a source line parser using PPI. After working a while, I realized that it would be nice if the PPI API had ...
3
votes
1answer
32 views

Replacing XML tag values

This function replaces some XML tag values. The tags appear in the XML exactly once.I want to know if this can be done in a better way. ...
4
votes
2answers
72 views

Terminal Chat Room

Summary I have written a pair of Perl scripts that form a UDP chat room allowing users to send messages over the internet with RSA encryption, making the messages imune to MITM attacks. The scripts ...
3
votes
2answers
42 views

Configuring fields to be extracted by a data processor

I solved this problem using closures with Perl and I wonder if/how I could/should have done it differently? Background: User creates config file describing properties of some source data file that ...
2
votes
2answers
49 views

splitting multiple joined words, port from perl to PHP

Though i have never worked on perl, not even once. I have ported the perl code into PHP and it seems like giving a correct result. But as I am going to use it on production server. I want this code ...
4
votes
2answers
37 views

Dynamically generated attribute accessors in Perl

In my spare time I'm working at a perl library, which is the lightweight implementation of a package I did some time ago. In the previous iteration I used Moose as object-oriented framework, as ...
3
votes
3answers
57 views

Perl DBI insert of hash

How can this method that inserts a hashref into a database table be improved? It assumes that the columns of the database table are named identically to the fields in the hashref. The return value ...
1
vote
1answer
27 views

Compare sequence & maps headers in fasta file

This is the perl code which compares the sequence in fasta file & maps the header. Though the code is working well, I still would like to make it more efficient. Since the files I compare has ...
2
votes
1answer
76 views

Find the number closest to 0, breaking ties in favor of positive numbers

I'm a Perl beginner and I really love this language, and I was wondering if it was possible to reduce the size of this code, just for fun and so as to learn Perl specificities: ...
6
votes
2answers
81 views

Perl recursive copy and move functions

I know a module like this already exists on CPAN, but I wanted to write my own simplified version that accepts wildcards in the input. I don't write many Perl modules so I figured I would post the ...
6
votes
1answer
67 views

Dealing with a command line argument (path) with spaces

I created a key in Windows registry to have an option on every folder which allows me to simply right click, choose the right option and have a PDF made, either from JPGS, or PNGs, or TIFs. My ...
3
votes
0answers
42 views

Recurse on complex Perl data structure, applying needed rules

Inspired by this answer and previous a commentator of code review use: Given a complex Perl data structure, traverse/jigger/modify as follows: If ORACLE_SID is ...
5
votes
0answers
47 views

Git Insert Delete Graph

I attempted to recreate the github code frequency graph(example) with a daily granularity using perl and git log. How did I do, ...
1
vote
1answer
32 views

Compare a sequence with the reference frequency of hexamers

I have written this function (and others similar to that one) But I am not sure I am using references on their full power. My currently concerns is if I make a huge use of memory. The subroutine ...
1
vote
2answers
117 views

Programs for different language learning - Perl

I've created a program for my own purposes in three different languages, Perl, Python, and Ruby. Each program will be posted in with their own tag but I will add links to them through on each post. ...
4
votes
1answer
67 views

100 Doors Problem in perl

I'm solving this in perl: https://github.com/kennyledet/Algorithm-Implementations/tree/master/100_Doors_Problem Puzzle: There are 100 doors in a long hallway. They are all closed. The first ...
2
votes
1answer
42 views

Determine column averages

I'm trying to write terse Perl code to calculate the average of each column in a file. The file can have >= 1 columns. ...
2
votes
3answers
36 views

Perl code that breaks a line after fixed number of columns

Here is a simple program that I created to print a file by breaking it after a fixed number of columns. I feel it can be optimized but not sure how. Any feedback is great. ...
3
votes
2answers
140 views

Treat undef in Perl's <=> operator as +inf instead of 0

I have to sort some numbers with Perl. But some of the numbers are undefined. Perl's compare operator <=> treats undef as ...
5
votes
1answer
103 views

Network chat in Perl

I have written a network chat program as my first major project in Perl. It makes simple use of REGEXP's, modules, sockets, command-line option parsing, and forking and uses these features to produce ...
6
votes
1answer
59 views

Perl parsing code

I've extracted a subroutine from some perl code I've written. (I also included the use enum line for easy reference.) Its purpose is to parse the given code, ...
6
votes
1answer
52 views

Perl pie alternative

Running on Cygwin, I cannot easily use perl -pi -e because it will always produce .bak files even though I don't want them. I ...
5
votes
2answers
125 views

Terrain height map generator

I wrote a Perl script that implements the algorithm described in this article to generate terrain height maps. The idea is to raise a random hill \$i\$ of size \$r_i\$ centered at point \$(x_i, ...
4
votes
1answer
48 views

Deleting most recent files by parsing filename

I have hundreds of .mp3 files in a single directory of the same naming format, title_YYYY-MM-DD.mp3, with maybe 30 different ...
8
votes
1answer
91 views

Calculate all anagrams of a word with Perl

In order to become more familiar with Perl I have implemented a code kata from here. The task was to write a program which prints out all anagrams for a given word. I'd appreciate your review of my ...
5
votes
1answer
45 views

Dump hash in columns

I tried to answer the question "How to print a hash in Perl, such that 3 key value pairs are printed on each line?" like this. As I got an uncommented downvote, I'd like to ask: What's wrong with/How ...
3
votes
1answer
42 views

fork_call every 'n' seconds in AnyEvent

I need to run fork workers every 5 seconds. Is there a way to do it more ideomatic? I'm embarrassed about $running variable. ...
2
votes
1answer
62 views

Advanced multi-conditonal split with an regex in Perl

I would like to split a string on multiple conditions such as: After each /;/ After each /{/ or ...
2
votes
1answer
58 views

Pull data from database to generate XML files

I have the following script in Perl that does the following: Prompts user for time in epoch. If user enters '########', the query will look for all reports generated after that date/time. If user ...
8
votes
3answers
86 views

Calculating bytes of code

I am new to Perl and I wrote this Perl script to calculate bytes of code and lines of code in a directory. I want to know if there are any improvements that can be made to it. ...
5
votes
3answers
58 views

Built-in help in a Makefile

My colleagues often ask me, "Dude could you remind me what I have to type to build this target?". So I eventually implemented a nice workaround in my Makefiles. I wanted my Makefiles to have a help ...
2
votes
1answer
43 views

Convert “String” sqrt(#) into numerical value

I had to come up with a way to convert sqrt(#) into its actual numeric value because before I would have an array containing elements such as: ...
4
votes
2answers
229 views

Merge Sort in Perl

I'm new to Perl and have successfully written a merge sort program. I'll paste the entire program below, but would like mostly a review of the subroutines ...
2
votes
2answers
59 views

Generating random XML documents

I'm trying to generate a fresh XML file using Perl XML::Mini::Document. It's working fine, but I don't know whether it's the right way to do it. Performance is the ...
3
votes
1answer
157 views

Parsing large CSV in Perl

I am getting Out of Memory errors when I try to parse through a large CSV file (2.5Gb). My computer has 32Gb of Memory but Perl uses all of it up. The CSV has 2 ...
1
vote
0answers
166 views

Perl subroutines to flatten and unflatten a complex hash or array key

I have written two Perl subroutines to flatten and unflatten a complex hash or array key. This can be useful in situation when you are traversing/parsing a complex data structure like JSON and want to ...
3
votes
0answers
223 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 ...
2
votes
0answers
587 views

The right way to use IPC::Open3 in Perl

Here is the function which does exactly what is specified by its name: ...
1
vote
1answer
855 views

Regex substitution using a variable replacement string containing backreferences in Perl

I have written a program where the user inputs a regular expression and a replacement string, and the program will search through a set of files and do the replacements. The user is allowed to use ...
4
votes
3answers
47 views

Security feedback sought on Perl code running command on unsafe filename in Unix env

I'm looking for security feedback on the following fully functional code. The code is trying to safely use the Unix 'file' command to give details about the file. A hard link is used to create a ...
2
votes
1answer
473 views

Building a Simple Menu With Perl

I wrote a Perl script to implement a simple menu where you can call subroutines for each menu option. I created a Menu class that can be used to create new menus and a print method that will start ...
2
votes
1answer
86 views

Reading a dynamic record length binary file

I am trying to read a dynamic record length binary file, which has data like this: field1field2field3field4vector1vector2 Here, field3 defines the occurrence of ...
11
votes
1answer
84 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 ...
6
votes
2answers
158 views

Bot for navigating a French dating site

I've been using Perl for the last two years and never really had any code to compare it to. Sometimes I hear people say things like "your code is awful" or "you just write C code with bad ...
10
votes
1answer
69 views

Automatic report generation from BibTeX

I wrote the following code for the question I asked here. Are there any catastrophic mistakes? (actually it did not really work with perltex and I am in doubt about having syntax mistake(s)) Also, I ...
5
votes
3answers
76 views

Some simple Perl and Regex

Reads from a flat file of three columns, delimited by at least one tab character. Filters the three columns based on input; returns list of corresponding emails. Arguments passed like ...
1
vote
0answers
71 views

HTML Tree Parsing in Perl

I finally converted my horrific HTML regex parsing: ...
7
votes
1answer
101 views

Changing desktop background to the next available one

How could I improve this working Perl script, which changes my desktop background to the next available one, without opening a terminal? Specifically, how could I iterate over my .fehbg and walls/ ...
19
votes
1answer
168 views

Network Downtime

A while ago I was experiencing 'flakiness' on my home ADSL line. I run a Linux server in my basement, VOIP, and a few other things (like Netflix) and I was experiencing a few minutes of network ...