perl

How do you list all locally installed CPAN modules?

Hi I'm beginner for perl. Do you now How to list local installed CPAN modules? like pear list in PHP. ...

Is there a parser for the output from Perl's Text::Table?

Suppose I have a bunch of tables created with Text::Table. Does there exist a parser to convert them back to Perl data structures, or do I have to write my own? ...

How do I resolve a "print() on closed filehandle" error in Perl?

I am getting this error while executing my Perl script. Please, tell me how to rectify this error in Perl. print() on closed filehandle MYFILE This is the code that is giving the error: sub return_error { $DATA= "Sorry this page is corrently being updated...<p>"; $DATA.= "<A href=\"javascript:history.go(-1)\"> Back </A>"; ...

Why isn't my Perl program reaping children processes after fork?

I have been trying to write a bare-bones ping scanner using Perl for internal use. Since it scans a 24-bit CIDR network the script takes too long to run if it runs in a single thread. I have tried adding fork functionality to speed up the process but my first attempt was taking pretty much the same time since there was only one child pro...

How do I make a Catalyst action that matches a single file in the root directory?

Hello! I have trouble creating a Catalyst action that would match a single file in the root directory. I would like to match URLs that look like this: http://foo:3000/about.html I have written the following action in the root controller: sub static :Path :Args(1) { my ($self, $c, $file) = @_; … } But the action does not ma...

Help with algorithm to dynamically update text display.

First, some backstory: I'm making what may amount to be a "roguelike" game so i can exersize some interesting ideas i've got floating around in my head. The gameplay isn't going to be a dungeon crawl, but in any case, the display is going to be done in a similar fasion, with simple ascii characters. Being that this is a self exercise,...

How can I append instead of replace text during a search-and-replace with Perl?

I am trying to do search-and-replace using a regex in Perl. The text I am searching for is: <space>Number<space>NumberNumberNumber and I want to replace it with: <space>Number<space>NumberNumberNumberI I have the following regex which works in finding the string: \s[0-9]\s[0-9[0-9][0-9] But what do I do about replacing the s...

How can I use a C++ class from Perl?

I have a set of classes written in C++. What would be best way to call them from a Perl script? Thanks. ...

Search for hash in an array by value

Hello, I have a function which extracts Excel data into an array of hashes like so: sub set_exceldata { my $excel_file_or = '.\Excel\ORDERS.csv'; if (-e $excel_file_or) { open (EXCEL_OR, $excel_file_or) || die("\n can't open $excel_file_or: $!\n"); while () { chomp; ...

Perl: Loop through a file and substitute

Hi! I simply wanna read in a logfile, do a search and replace, and then write out the changes to that same logfile. What's the best practice way of doing this in Perl? ...

Writing a starter program which aborts hanging programs

I have a script which needs to periodically start programs out of a array with program names via Perl on Linux. The problem is that from time to time one of the programs takes too long/hangs and needs to be aborted. Currently I am starting the program using qx/$cmd/ in a seperate thread which reads from a shared start queue. The main t...

Is there a portable Perl?

Is there a portable Perl along the lines of portable Python? Something I could use (while learning the stuff) from my thumb drive? Oh, and I'm talking about Window XP. ...

What's an easy way to print a multi-line string without variable substitution in Perl?

I have a Perl program that reads in a bunch of data, munges it, and then outputs several different file formats. I'd like to make Perl be one of those formats (in the form of a .pm package) and allow people to use the munged data within their own Perl scripts. Printing out the data is easy using Data::Dump::pp. I'd also like to print s...

Construction of regexpression for search and edit.

Hi, I am trying to construct a regular expression to search and replace a file. The following is the script. #!use/bin/perl use strict; use warnings; my $line = $ARGV[0]; my $find = "[^a-zA-Z0-9]+seqfile[^a-zA-Z0-9]+=[^a-zA-Z0-9]+[a-z]+.."; my $replace = "done"; open (FILE, ">>/home/user/Desktop/test") || die "cant open file \n"; ...

Python 2.6 subprocess.call() appears to be invoking setgid behavior triggering Perl's taint checks. How can I resolve?

I've got some strange behavioral differences between Python's subprocess.call() and os.system() that appears to be related to setgid. The difference is causing Perl's taint checks to be invoked when subprocess.call() is used, which creates problems because I do not have the ability to modify all the Perl scripts that would need untaint c...

Why does my Perl script delete the contents of whole file when I try to edit the file?

I am running the following code to open a file (test) and edit(search and replace) it. Program seems to open the file but instead of replacing it deletes everything in the file. I am not sure why that is happening. Can anyone help me out here? #!use/bin/perl use strict; use warnings; my $line = $ARGV[0]; my $find = '\s{6}seqfile\s=\si...

How can I activate an Excel add-in from Perl or the command line?

(Please forgive my ignorance on Excel add-ins, and feel free to correct my teminology where appropriate.) I have an Excel add-in that is used regularly. This add-in inserts a toolbar with a number of buttons. I want to automate the task of opening a spreadsheet in Excel and then "clicking" one of those buttons. In other words, I want...

Regex: Need help with greedy quantifier

I'm doing a simple search-and-replace in Perl, but I need some help. These are lines in a file: 1001(seperator could be "anything")john-1001(seperator could be "anything")mark 1001(seperator could be "anything")mark-1001(seperator could be "anything")john I wanna assign a new userID for john, like 2001. So this is the result I want:...

How to input different file names in string that needs to be replaced?

I am trying to read a directory which consists of hundreds of files. For every file in the directory, I am supposed to access(edit) an another file and replace a particular string 'information=filename' in that file by file names 'information=' present in '/home/test/test_these_files' directory. This is followed by executing the file '/h...

Change context of return of map?

I'm trying to parse a JSON string into an array reference: my $str = '[[2],[1]]'; my $data = map { $_->[0] } @{decode_json( $str )}; but this makes it a scalar. I can do: my $str = '[[2],[1]]'; my @data = map { $_->[0] } @{decode_json( $str )}; my $data = \@data; but it's not as short as I like. any help? ...