Tagged Questions

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
2answers
56 views

Guess my Number in Perl

I have recently just started learning Perl, so I decided to program the classic 'Guess my Number' game. I was wondering if anyone can spot any areas for improvement, as it's my first program, I expect ...
2
votes
1answer
38 views

Code style: passing a reference to subroutine

Is the subroutine test1 ugly?/uglier than the others? #!/usr/bin/env perl use warnings; use strict; use 5.10.1; use Data::Dumper; my $ref = { one => 1, two => 2, three => 3 }; sub test1 { ...
2
votes
2answers
44 views

Reading fields idiomatically

This technique is more general than just for config files which is why I'm not using Config::Any in this example. I have a config file with lines like this: userid foo-admin # foo-comment directory ...
0
votes
0answers
27 views

Suggest improvements to Perl remote server for serving Perl code via reflection

I built a custom XML-RPC server in Perl that "supposedly" serves any given Perl code module/class whose structure conforms to some compatible specifications, and the server serves it dynamically at ...
-1
votes
1answer
31 views

Perl script with argument parsing and help [closed]

I want to write a Perl script that parses GNU style long and style command-line options. I also want to provide a nice --help output. I get the impressions that I should use Getopt::Long, which ...
0
votes
1answer
42 views

Perl project review - Word counter

I wrote this perl script that analizes a text and plot out a bar graph of the word occurrences during the text. Since come mainly from Javascript and PHP, i would like to know how bad is this code ...
3
votes
1answer
56 views

Feedback on my Perl wrapper library (written using Moose) for a REST API

I wrote a wrapper library for a REST API (https://semantics3.com) in perl using the Moose library. I would like to gather some feedback on it (mainly on the oop part since I am new to moose), before ...
1
vote
1answer
95 views

Perl CGI script to respond to erroneous Base64 image requests

I often get lines like this in my Apache error log: File does not exist: /path/to/www/data:image/gif;base64,R0lGODlhBgAGAIAOAP/yH5BAEACAEALAAAAAAGGAYAAAIJhB0Xi5vOoFwFADs= Obviously, this is due to ...
2
votes
1answer
101 views

Ls improved, constructive criticism

I have written a script that improves the Linux terminal experience. This script is introduced here: http://hermannn.com/programs/aa/. It basically displays the content of the terminals current ...
1
vote
1answer
53 views

Markdown.pl extending

I'm not used with perl but had the need to add a couple of features, I wish I can adopt a more perl-ish coding. Any help is welcome. This is to add style classes to paragraphs if strarting with !, ...
-1
votes
1answer
439 views

CSV parsing in Perl

I am looking for a Perl (5.8.8) script for CSV parsing that would follow CVS standards. (See Wikipedia or RFC-4180 for details) Sure, code should be fast enough, but more important is that it should ...
3
votes
2answers
202 views

Improving python3 processing speed (against a reference perl script)

In order to create fast map/reduce processor for hadoop, I'm evaluating many languages. I'm learning python so I would like my python processor to go as fast as my perl processor. So, for this ...
0
votes
1answer
81 views

Causes Puzzle Solution: Improvements needed

sub addMember { my ( $self, $newMember ) = @_; my $len = length($newMember->{'_data'}); my $newMemberIndex = push(@{$self->{'_MemberList'}}, $newMember) - 1; ...
3
votes
3answers
210 views

parsing a flat file and removing duplicates

Have some code that I wrote to parse a flat file of IP address and other junk unwanted information. Just wanting to see if there was any way to make shorter or better. #!/usr/bin/perl use strict; ...
0
votes
1answer
151 views

extract href from html

I am building a Perl module which I am attempting to use as few non-core dependencies as possible. Should my following code fail, I would add a dependency on HTML::LinkExtor and be done with it, but I ...
3
votes
1answer
284 views

Simplify regular expression? (Converting Unicode fractions to TeX)

Background I'm converting Unicode text to TeX for typesetting. In the input, I'm allowing simple fractions like ½ and ⅔ using single Unicode characters and complex fractions like ¹²³/₄₅₆ using ...
3
votes
2answers
135 views

perl: need help making my program less clumsy

I'm brand new to perl, and just know there are 100 ways to do this. If you like to teach (or just show off your perl prowess), I love to learn. Basically, I'm looking for a cleaner way to generate ...
2
votes
2answers
59 views

How should I pass settings to a module in Perl that also exports symbols?

In Test::Version I want to add configuration settings that allow one to toggle certain features. I'm thinking about passing an anonymous hash to a custom import like so. use Test::Version 1.2 qw( ...
1
vote
1answer
174 views

Perl script to find all unowned files and directories on Unix - How can I optimize further?

(Originally posted in the Stack Overflow forum) Following my findings and suggestions in my other post How to exclude a list of full directory paths in find command on Solaris, I have decided to ...
5
votes
3answers
149 views

Best way to replace a beginning and end character in Perl using Regular Expression?

I'm wondering if there is a simplier regex I could use in my code to remove the beginning and ending char in a line. Maybe combine some regex's? In this instance, it's a comma at the beginning and ...
4
votes
5answers
190 views

I would like some constructive critisism on my script

I have been working on a script for almost a month now. Can all you great programmers please provide me with some feedback. The script takes in an XML file and uses it to either download or upload ...
0
votes
1answer
84 views

Security concerns with locking files

I'm writing a perl script which reads logs from a file and looks for matches from another file before sending the matches off by email. The problem is, I'm dealing with files which could be changed (a ...
-1
votes
1answer
146 views

I just finished my code is there anyway someone could help me and work it? [closed]

i have this code that i just finished translating from my other code in perl to python. I do not know python very well. Basically the code takes certain inputs and reads a data file which supplies ...
3
votes
2answers
184 views

Ideas on shortening this if-elsif chain with embedded if-elsif

Okay, I'll try and keep this as short as I can. First, I need to keep various options available to the user: if ($c_verb eq 'on') { if ($c_enabling) ##if need eq, add || '' at declaration. ...
2
votes
2answers
137 views

To make a subroutine or not? +General Code tips

I have written this Perl code, and there is still more to add, however I was hoping that I could some opinions on whether it could be written better. Specifically, there is a central if-elsif ...
2
votes
1answer
124 views

Perl: How can I improve these split commands?

Here are the samples from the two text files I loop through: Tagged: 5.4_CD Passive_NNP Processes_NNP of_IN Membrane_NNP Transport_NNP 85_CD We_PRP have_VBP examined_VBN membrane_NN structure_NN ...
2
votes
1answer
257 views

Is this Perl script well written? (fixed)

I'm a beginner/intermediate Perl programmer and would appreciate suggestions on improving my technique. I was reading Mathematics: A Very Short Introduction and it mentioned prime factorization. ...
2
votes
2answers
92 views

Perl: Should I create a function to encapsulate the first set of for loops? If so how?

I am new to Perl so this code is very crude. It almost works, with the exception of sorting by frequency. I think it would be easier and more compact if the first section ( before the close ...
11
votes
5answers
494 views

Is this Perl program well-written?

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 ...
2
votes
1answer
147 views

service build with perl - is it correct

I tried putting a script i saw together, plus used an existing script to make something run as a service. Now I have the following pl script and the init.d / start/stop scripts. They work, but I am ...
2
votes
2answers
155 views

Can I jump like this?

In my nested for loops below, it is sometimes necessary to exit the outer loop and then continue program execution. Since loop labels and other goto-like constructions are heavily discouraged, I'm a ...
6
votes
1answer
484 views

Spherical Voronoi diagram, binary splitting approach (Perl)

Given 5 (currently hardcoded) cities, this code uses Google Maps to split the world into 5 regions, each region being the points closer to a given city than to the other 4. It works ( ...
3
votes
1answer
466 views

Perl DBI Sample with MySQL DDL

I've been experimenting with Perl and MySql and wrote this code for connecting and writing to a database: # MySQL DDL to create database used by code # # CREATE DATABASE sampledb; # # USE ...
3
votes
2answers
238 views

Is calling a function only twice a good use of recursion?

Is this, technically, a recursive function? It only gets called once by itself, but it cleaned up my code quite a bit, I think. Or, does it needlessly complicate the code? sub check_backlog { my ...
6
votes
6answers
277 views

Explicit Function Notation in Perl

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 with no arguments, then you can ...
2
votes
2answers
243 views

Strange error in my Perl script

This is my first Perl script, so far it works fine, except after running for a long time, it begins to throw an odd error: "Use of uninitialzed value at string ne", and it refers to a line in the ...
7
votes
3answers
303 views

Is there a better way to write this very wordy perl code?

There's got to be a better way than this that preserves the logic while sparing me the multitude of lines. Eval? sub has_path { clearerr; my %Graph = gref(shift); my $A = shift; my $B = ...
8
votes
4answers
398 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 ...