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
1answer
49 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: ...
5
votes
1answer
28 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
48 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
35 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
40 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
28 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
107 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
0answers
57 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
40 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
35 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
134 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
79 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
53 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
50 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
102 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
46 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
77 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
41 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
33 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
53 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
51 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
83 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
56 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
39 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
138 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
58 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
128 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
131 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 ...
1
vote
0answers
60 views

Perl subroutine to clean path name for empty directories

I am writing a Perl application where it would be nice to have a subroutine that could clean up a given pathname such that it does not contain any empty directories. I have written this subroutine ...
3
votes
0answers
195 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
455 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
581 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
46 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
382 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
75 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
83 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 ...
5
votes
2answers
144 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
68 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
69 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
67 views

HTML Tree Parsing in Perl

I finally converted my horrific HTML regex parsing: ...
7
votes
1answer
100 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
151 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 ...
2
votes
2answers
221 views

Splitting a Multi-FASTA file into individual files

I have written a program to split a Multi-FASTA file into individual fasta files. ...
14
votes
3answers
827 views

Reverse Polish Notation Compiler

Description A reverse polish notation based compiler. Very small subset of forth This is a proof of concept level compiler, no optimizations or over/underflow checking see the embedded POD for more ...
10
votes
3answers
390 views

Print Student Names from CSV

Description Print all student names from a CSV file. CSV Format: CSV file does not contain string delimited by double quotes. None of the cells has "," ...
4
votes
2answers
1k views

Parsing command line arguments in Perl

I use this idiom to parse command line arguments in Perl: ...
2
votes
1answer
33 views

line-endings detection

I would like to detect which is the line-endings type of a file. I wrote this function: open my $fh, '<afile.txt'; seteol($fh); Here the eol detection ...
3
votes
2answers
156 views

Finding palindromic numbers most efficiently

After reading why is my project euler #4 program not working?, I was contemplating the most efficient way to approach this (finding the target palindrome as early as possible). Is this snippet about ...
4
votes
1answer
111 views

Split a string of hostnames, expand from regex, return non-duplicated names in original order

I have the following function. It can be passed a candidate_string such as the following examples: "device1 device2" "device1" "device.*" "device.region" "device[123] Assume that target_list ...
6
votes
1answer
90 views

Expand hostnames from a string of hostnames and/or regex

This code will be passed a string which will contain one or more hostnames. A hostname can be dotted-decimal plain name (like my_host) FQDN or even partially ...