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

learn more… | top users | synonyms

10
votes
1answer
34 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
53 views

Splitting a Multi-FASTA file into individual files

I have written a program to split a Multi-FASTA file into individual fasta files. ...
9
votes
3answers
353 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
353 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
81 views

Parsing command line arguments in Perl

I use this idiom to parse command line arguments in Perl: ...
2
votes
1answer
28 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
1answer
51 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
49 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 ...
0
votes
0answers
26 views

Avoiding redirection of STDERR to /dev/null [closed]

How can I avoid redirection of stderr to bit bucket in my Perl program? Perl seems to be overeager to please by also interpreting command-line arguments as filenames to go and try to open. How do I ...
6
votes
1answer
49 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
44 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
33 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
53 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
63 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
33 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
107 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
45 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
79 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
48 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
37 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
73 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
100 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
52 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
121 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
30 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
309 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
83 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
66 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
46 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
60 views

Perl 6: Grammar issues (simple defines)

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

Little script to Caesar shift strings

I wrote a little Perl script to Caesar shift strings. Usage: ...
3
votes
1answer
115 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
65 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
81 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
189 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
53 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 ...
3
votes
1answer
75 views

Performance optimization in function for datastructure mapping

I want to optimize a Perl function which is frequently used in my application. The function creates a special datastructure from the results of ...
3
votes
1answer
55 views

Parsing psql output into multiple files

I wrote the following simple Perl script to read lines from stdin that are the output from a psql call that returns lines of the ...
13
votes
1answer
146 views

Regular backup/snapshots

A (long) while ago I set up a file server in my basement running Linux. I am OCD when it comes to backups. I set the server up with (remember, this was a while ago): disk for OS disk for 'valuable' ...
10
votes
3answers
240 views

Bowling calculator in Perl

A bowling score calculator is my go-to exercise for learning the basics of a language. I recently had to pick up Perl so I did this. I'm concerned that I'm doing subroutines wrong. I had a hard time ...
17
votes
4answers
1k views

Rainfall challenge

About a year ago when I was applying to jobs for the first time, I had an interview at a company and they posed the following problem to me, which I preceded to bomb. A year later I actually came up ...
4
votes
1answer
47 views

Data structure to RDF

I believe any data structure can be converted to RDF, and I wrote the subroutine below which sort of does this, at least for arbitrarily complex hashes. However, I'm unhappy with it because: ...
1
vote
1answer
163 views

TCPDUMP file (part of a real capture)

I have been working on this code for quite a while and just want to make sure it is up to good standards. I know many of you will have questions, so as they come up, I will edit my initial question to ...
4
votes
1answer
71 views

Find common preamble of a list of strings

Think of a set of text lines starting with a common string, e.g. indented code. ...
4
votes
2answers
517 views

Perl Code Improvements - reading CSV file

I am very new to Perl, but quite pleased with my short introduction to it! So, scenario is I have a number of text files (they are reports from a financial system) stored in a directory. Each report ...
3
votes
1answer
104 views

Parsing text from reports

I want to parse some reports from multiple devices, reports looks like this: ...
7
votes
2answers
114 views

Is the following a good C program for launching an interpreted script?

I was just wondering if this is a good example, following good practices, of a C program for launching an interpreted script from a native binary executable. Here the interpreter is Perl and the ...
1
vote
3answers
195 views

How do you “sordid sort” alphanumeric strings?

The question is about sorting alphanumeric string in a "more natural" order. Source: Marc LeBrun's "Sordid Sort" Computist Quiz Often a system string comparison sorts alphanumeric data ...
1
vote
1answer
501 views

More elegant way to get timestamp from day/hour? (Perl)

http://coolwx.com/buoydata/data/curr/all.html provides weather data from ships (or maybe buoys) at sea, but the date is given as "25/18" (meaning the 18th hour of the 25th day of the month, all ...