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

learn more… | top users | synonyms

6
votes
1answer
33 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
51 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
41 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 ...
7
votes
1answer
50 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
35 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
22 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
44 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
31 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
73 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
2answers
38 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
27 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
58 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
53 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
75 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
74 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 ...
0
votes
0answers
41 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
88 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
173 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
198 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
44 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
169 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
55 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
73 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
111 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
63 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
65 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
53 views

HTML Tree Parsing in Perl

I finally converted my horrific HTML regex parsing: ...
7
votes
1answer
97 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/ ...
16
votes
1answer
116 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
150 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
631 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
383 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
775 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
119 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
92 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
75 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 ...
1
vote
1answer
55 views

Perl script to handle include files

I am trying to extend the JSON format (for private use) to include an include statement. This could be used to include other ...
4
votes
1answer
39 views

Perl module to deal with numbered nested objects

I wrote a small perl module that dealing with PHP-ish array structures, and I'm going to release it to CPAN. I want it to be reviewed before the release about the module naming and the code itself. ...
3
votes
2answers
92 views

Align text (left, center, right) without additional packages

I wrote this short subroutine to left, center, right-align a multiline string. How can I make it better (shorter, prettier, optimized)? Can you offer some suggestions? ...
6
votes
1answer
141 views

Readability of this Perl script to generate HTML code

I'm writing some scripts for a project which need to be maintainable. Someone will be coming in and taking over after a while and I want it to be easy for them to understand what's going on. What it ...
2
votes
2answers
40 views

Creating two output files from two formatted files

I've been working on a project to take data from csv files, re-format it, and display it as charts. I'm working for a company over the summer and when I leave, I would like my code to be ...
5
votes
2answers
161 views

How easy is it to crack this encryption algorithm?

When I was about 13 or 14 years old, I was a little interested in cryptography (which is, after all, an interesting field). I learnt quite a lot since that time (it has been about 8 years since then), ...
3
votes
1answer
450 views

Perl script to check disk usage

I'm looking for input on the code itself and formatting/style. This script parses the output of df -h on a Linux server and emails the user if the usage percentage ...
4
votes
1answer
263 views

Simple password dictionary attack script

This is my simple Perl script implement password dictionary attacking, encryption algorithm SHA1 with different length. It takes 2 arguments as input: first argument is password dictionary file path, ...
6
votes
1answer
56 views

Canonicalizing a large set of addresses using many regex substitutions

I have a script that is standardizing a large amount of data in the database. The standardization involves applying over 500 regular expressions to the data. Here is some quick pseudocode: ...
2
votes
2answers
86 views

Determine if a path matches a pattern

I have been struggling with a regular expression involving path names. Immediately, this is a bit troublesome, owing to the embedded / in the pattern, but braces to the rescue. First the convention ...
2
votes
1answer
45 views

Check the hardrive performance of the particular process using a Perl script

I have written the following Perl script to monitor the hardrive performance of the particular process (say, for example, Chrome). ...
5
votes
3answers
83 views

Command line tools to format tables

I am a big fan of one-liners using sed awk perl and other tools. But there are that are ...
1
vote
1answer
176 views

Optimizing Perl script which looks for world-writable files

A script which scans a local filesystem and writes to a file a list of world-writable files found on the filesystem. I ran it on a server with a couple terabytes of storage; not all of it used. In ...