Skip to main content

Questions tagged [perl]

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

Filter by
Sorted by
Tagged with
42 votes
4 answers
7k 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 ...
Hunter McMillen's user avatar
24 votes
4 answers
3k views

Perl CGI script to serve a PDF file

In a different post I showed the following Perl CGI script. Someone in the comments said that "You're using a lot of very unperlish syntax, and I'd like to give you some feedback". So, here it ...
amblabs's user avatar
  • 341
23 votes
1 answer
519 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 ...
rolfl's user avatar
  • 97.4k
22 votes
1 answer
814 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' ...
rolfl's user avatar
  • 97.4k
16 votes
3 answers
2k views

Reverse Polish notation based compiler

Description 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 information NASM is used as assembler gcc ...
JaDogg's user avatar
  • 4,531
15 votes
3 answers
309 views

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 ...
Demi's user avatar
  • 325
14 votes
5 answers
883 views

Chemistry titration calculator

This is a Perl program intended for my chemistry class. Since I am just learning to write in Perl, which is my first language, can you tell me if you think that this is well written? If not, could you ...
Jonathan Bondhus's user avatar
14 votes
4 answers
557 views

Subroutine to call other subroutines

I have a Perl application that allows the user to choose between two different formats for data output (and there will likely be more in the near future). In the heart of the algorithm, the code makes ...
Daniel Standage's user avatar
13 votes
6 answers
841 views

Bash script that lowercases files

I have the following bash script that: Finds all files with .cfc and .cfm extension and converts them to lowercase Stores the ...
theblindprophet's user avatar
13 votes
1 answer
141 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 ...
rolfl's user avatar
  • 97.4k
12 votes
4 answers
3k views

Simple C transpiler

I wrote a simple transpiler (that may be a bit of a stretch) in perl to cut down on some boiler plate code. I'm very new to perl, this being maybe my third ever project in it. My main question would ...
Shipof123's user avatar
  • 353
12 votes
2 answers
232 views

Convert British and Irish National Grid references to or from WGS84 geodetic coordinates

I've been using this wgs84togrid program for a few years. It converts in both directions between National Grid coordinates for GB or Ireland (beginning with a ...
Toby Speight's user avatar
12 votes
1 answer
189 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, ...
Charles's user avatar
  • 509
11 votes
3 answers
468 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 "," character ...
JaDogg's user avatar
  • 4,531
11 votes
1 answer
203 views

Becoming a Perl bandit

I've posted a few questions about natas a wargame. But I'm stuck at natas29 it has to do with Perl. I've never coded in Perl before. Thus to help me beat the last few levels, I decided it is time to ...
Ludisposed's user avatar
  • 11.6k
11 votes
1 answer
707 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 ...
Janux's user avatar
  • 255
10 votes
3 answers
130 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. ...
HSchmale's user avatar
  • 895
10 votes
3 answers
468 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 ...
Zach Thacker's user avatar
10 votes
1 answer
83 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 ...
trblnc's user avatar
  • 203
10 votes
3 answers
755 views

Robust, know-entropy password generator

My use case is I want a password generator that generates memorable and robust passwords for users, to give me a known minimum entropy. For this - I'm approximating set of Consonant-Vowel-Consonant ...
Sobrique's user avatar
  • 249
10 votes
1 answer
134 views

Perl gradient noise generator

I'm working on 2-D top-down graphics engine, and need a way to simulate clouds. My idea was that I could create a layer comprised of a matrix of rectangles whose alpha value would be picked from a ...
Bee H.'s user avatar
  • 265
10 votes
2 answers
7k views

Mocking socket calls in C++

Explanation I'm trying to get better unit test coverage of my server. I needed to mock out some system libraries (I could not find anything that worked easily for C++). Because I did not want to do ...
Loki Astari's user avatar
  • 95.3k
9 votes
6 answers
386 views

Analyzing genetic tags

I've gone back and forth a few times recently on my Perl coding style when it comes to module subroutines. If you have an object and you want to call the method bar ...
Daniel Standage's user avatar
9 votes
3 answers
428 views

Function, taking up to 27 parameters, that checks for the existence of a path in a graph

There's got to be a better way than this that preserves the logic while sparing me the multitude of lines: ...
bugmagnet's user avatar
  • 193
9 votes
2 answers
3k views

Count line of code for a JavaScript project

Here is my bash script that I just wrote to count line of code for JavaScript project. It will list number of: Comment lines Blank lines All lines Here is my script: ...
Chau Giang's user avatar
9 votes
2 answers
130 views

Highly nested bioinformatics processing

I have a script for parsing BAM files. The script's input thus is lines like ...
Randoms's user avatar
  • 193
9 votes
2 answers
129 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, and what improvements can I make? I ...
HSchmale's user avatar
  • 895
9 votes
2 answers
699 views

Remotely collect server data using Net::OpenSSH

I am newbie in Perl programming and currently trying to use Net::OpenSSH module in my code. My code as below which the task is to run multiple commands in remote server: ...
MrAZ's user avatar
  • 191
9 votes
1 answer
295 views

Is possible to use script for dependencies in c++?

I wanted to make a script that would parse a main file (with int main()) look in its #include "..." local headers, and ...
milanHrabos's user avatar
9 votes
1 answer
428 views

Creating a Perl webserver

Intro Finally had the time to do some wargames again, but I have come to the point where I need to build my own test enviroment to test certain ideas, because I can't test it online. The current ...
Ludisposed's user avatar
  • 11.6k
9 votes
1 answer
136 views

Frequency analysis for simultaneous dice rolls

My professor told me to optimize my perl code, but he wouldn't tell me what exactly - just make it simpler. I changed some little things but nothing major. Am I missing something? The task was: ...
alec's user avatar
  • 131
8 votes
2 answers
479 views

Letter frequency analysis (Breaking Vigenere)

I'm trying to improve my Perl and am doing some wargames online. I wrote a small utility to help me pass a stage. The main weakness of a simple substitution cipher is repeated use of a simple key. ...
Ludisposed's user avatar
  • 11.6k
8 votes
3 answers
410 views

Executable wrapper around Perl script on Windows

I have ack (the searching tool) "installed" as a single file at C:\ack\bin\ack.pl on a Windows 10 machine and was wondering how to make it executable from the ...
Greg Nisbet's user avatar
8 votes
3 answers
2k 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 ...
Kolibrie's user avatar
  • 197
8 votes
1 answer
349 views

Parse data from Input file and print results

I have written a script which does parsing to the input file and take out some values from them with respect to the node and print the data accordingly. Below is my script, and it works as expected: <...
vkk05's user avatar
  • 183
8 votes
1 answer
161 views

Git pie - Perl oneliner for Git

I often make changes on my code-base and manually using sed, awk or perl -pi -e is not ...
nowox's user avatar
  • 1,099
8 votes
1 answer
119 views

Process files in a directory and upload them to URL

I have some code that I wrote for a personal project which takes, as arguments, a directory and a URL. It then processes the files in the named directory, archives them, and uploads the archive to the ...
Jonathan Dewein's user avatar
8 votes
1 answer
130 views

Checking whether a string fragment could be part of a longer UTF-8 string

Although UTF-8 validation is a common task, I'm trying to solve a slightly different task; given a string of bytes, work out whether it could potentially be a fragment of a valid UTF-8 string. That's ...
ais523's user avatar
  • 181
7 votes
4 answers
428 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 things that ...
Tiago's user avatar
  • 171
7 votes
2 answers
537 views

Using an API to obtain JSON data and get the date string and determine if data is stale

This is a nagios check that will use an API URL, get JSON data, flatten the data into a usable perl hash, and ultimately obtain a date string. Once the date is obtained, it should recognize the ...
japtain.cack's user avatar
7 votes
3 answers
2k 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 ...
Stephen Ostermiller's user avatar
7 votes
2 answers
147 views

Finding product palindromes

I am new to perl and want some help in tuning this script if possible cause it takes time if I increased my array. also if I use warnings I get a lot of warnings ...
George Samaan's user avatar
7 votes
2 answers
225 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 performance"...
Arkeopix's user avatar
7 votes
1 answer
744 views

Remove duplicate lines without sorting or removing empty lines

I am using the following one-liner to remove duplicate non-empty lines without sorting: perl -ne 'if ( /^\s*$/ ) { print } else { print if ! $x{$_}++}' Empty (...
Ahmad Ismail's user avatar
7 votes
2 answers
261 views

Improved remake of the Linux 'ls' command

I have written a script that improves the Linux terminal experience. It basically displays the content of the terminal's current folder in a nicer way than the ls ...
john-jones's user avatar
7 votes
1 answer
152 views

Perl one-liner for parsing host names from ssh config file

Here is the working code (intended to be executed with perl -e '<code>' ~/.ssh/config): Actual version: ...
GrandOpener's user avatar
7 votes
1 answer
94 views

This perl script renames all files in a directory to have an equal amount of digits

I took a lot of pictures with my camera and I wanted to make a time-lapse out of them. The camera saved the pictures as picture1, ...
Zwettekop's user avatar
  • 125
7 votes
1 answer
82 views

Perl script to match case law references

I am very new to Perl and decided to work on a simple script that could solve a problem I encounter in my day to day work. The purpose of the code that follows is to search over a body of text and ...
DanielH's user avatar
  • 177
7 votes
1 answer
730 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 ...
jess's user avatar
  • 1,378
7 votes
1 answer
215 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 ...
Mark's user avatar
  • 443

1
2 3 4 5