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

learn more… | top users | synonyms

1
vote
0answers
29 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
21 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
64 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
37 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
48 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
43 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
84 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
46 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
68 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
81 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
56 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
60 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
40 views

HTML Tree Parsing in Perl

I finally converted my horrific HTML regex parsing: ...
7
votes
1answer
89 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/ ...
12
votes
1answer
83 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
110 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
595 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
374 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
305 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
97 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
78 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
64 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
54 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
36 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
81 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
98 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
37 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
129 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
219 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
209 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
55 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
63 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
39 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
81 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
164 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 ...
3
votes
0answers
119 views

Writing a log file with threads

Here are all the threads write the log file. I want to know if the below script is fine, if it needs any modifications, and whether I am utilising threads properly to execute this code fast. ...
4
votes
3answers
542 views

Clean way to get size of directory

I'm working on a Unix machine where I can't use more than vanilla Perl, and I'm using Perl5.8. This script exits with a 1 if the current directory size is smaller than 1 GB (the character after ...
0
votes
0answers
31 views

Proving a conjecture given a set of clauses - calculating complexity

I have written this Perl program to prove a conjecture given a set of clauses. I've actually posted some code from it on here in another question. This time its all done and I've made it as fast as ...
4
votes
4answers
371 views

Optimizing system calls and nested loops

I'm writing a Perl program to take a set of clauses and a conclusion literal and produce a resolution-refutation proof (if possible) using a breadth-first set of support (SOS) search algorithm. The ...
4
votes
2answers
103 views

Data screening using Perl

Background information I've been asked to write a little Perl script that allows genomic data to be screened against reference files in order to determine locations of specific mutations. The input ...
4
votes
0answers
74 views

Building hundreds of C++ components using multiple threads

I'm pretty new to Perl (and multithreading), so I was wondering if someone would be willing to take a look at my script and give me any tips on increasing performance. Motivation The script is ...
3
votes
1answer
99 views

Perl file sorting script

This is my first ever real 100% self made perl script, I'd like to know how I can improve it. ...
3
votes
2answers
85 views

Perl 6: Grammar issues (simple defines)

My goal is to parse defines in Objective-C code: ...
4
votes
1answer
146 views

Little script to Caesar shift strings

I wrote a little Perl script to Caesar shift strings. Usage: ...
3
votes
1answer
166 views

Finding world-writable files in local directories only

Over at Stack Overflow I asked how to scan a local filesystem ignoring all remote mount points. I only really wanted a push in the right direction and received it. After clacking away on my keyboard I ...
1
vote
0answers
93 views

Reliability of flock mutex (LOCK_EX|LOCK_NB)

I would like to test reliability of system flock in a multi-threaded and concurrent environment as some suggest that they are not reliable (in comments). Thus I ...
6
votes
2answers
86 views

Foreach-loop for and print commands

How can I make the following code shorter or efficient (maybe with other loops or other nice ideas), and keep the current functionality? ...
5
votes
1answer
317 views

Convert a mediawiki to dokuwiki script

I have quickly wrote a Perl script to convert a mediawiki to a dokuwiki. I know there's an existing script to make that, but I would have a simpler usage code and some use of the API from mediawiki. ...
3
votes
1answer
57 views

Reading a config file

I am relatively new to Perl and would like to check that the code I am writing docent have any major flaws in it or any bad practices. This is a fairly simple sub but one that gets used often. Seems ...