perl

How can I find out where a Perl module is installed?

How do get the path of a installed Perl module by name, e.g. Time::HiRes? I want this just because I have to run my perl script on different nodes of a SGE Grid Engine system. Sometimes, even run as other username. I can use CPAN.pm to install packages for myself, but it is not so easy to install for other users without chmod 666 on fo...

How can I extract start and end codon from DNA sequences in Perl?

I have a code below that try to identify the position of start and end codon of the given DNA sequences. We define start codon as a ATG sequence and end codon as TGA,TAA,TAG sequences. The problem I have is that the code below works only for first two sequences (DM208659 and AF038953) but not the rest. What's wrong with my approach be...

Why don't I get all the data when with my non-blocking Perl socket?

I'm using Perl sockets in AIX 5.3, Perl version 5.8.2 I have a server written in Perl sockets. There is a option called "Blocking", which can be set to 0 or 1. When I use Blocking => 0 and run the server and client send data (5000 bytes), I am able to recieve only 2902 bytes in one call. When I use Blocking => 1, I am able to recieve al...

How do I install the dependencies I need for MySQL::Slurp?

I am trying to install the mysqlslurp utility found in MySQL::Slurp. I found that it requires Moose and therefore I installed that package too. But I am still not able to use the mysqlslurp command. I get an error: Can't locate Moose.pm in @INC (@INC contains: /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi ..... BEGIN fa...

How can I maintain the order of keys I add to a Perl hash?

how to maintain the order of actual list after counting its occurence using hash... in the following program... eg.. <DATA> are a b e a c d a c d b etc.... Using hash... i counted the occurence of each element. and what i want is: a 3 b 2 e 1 c 2 d 2 but the following program shows me otherwise... my (%count, $line, @array...

How do I process the data submitted from HTML Form?

I have written code to create a form to select multiple values. Below are some lines of my code to create a form to select multiple values. my $parser = Text::CSV->new(); open($csv_fh, '<', $csv_file) or die $!; my @headers = $parser->column_names( $parser->getline($csv_fh) ); print <<"EOF"; <FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>...

How do I use the Math::Business::MACD module?

I have data in the form of text for example these are the data values 8.44, 8.9, 7.7, 9.3 ,3.4, 6.66 etc , with the module Math::Business::MACD how to calculate slow fast trigger values using the above data? Could any one guide me? ...

How can I sync two directories with Perl?

I have a folder called "Lib" in my drive it contains many files inside and I have a problem that this "Lib" folder is there in many other places in the drive. My Perl script has to copy the contents from folder "Lib" which are latest updated and paste it in the folder "d:\perl\Latest_copy_of_Lib" For example, I have a Lib folders in d...

What's a good Perl regex to untaint an absolute path?

Well, I tried and failed so, here I am again. I need to match my abs path pattern. /public_html/mystuff/10000001/001/10/01.cnt I am in taint mode etc.. #!/usr/bin/perl -Tw use CGI::Carp qw(fatalsToBrowser); use strict; use warnings; $ENV{PATH} = "bin:/usr/bin"; delete ($ENV{qw(IFS CDPATH BASH_ENV ENV)}); I need to open the same...

Why would you want to export symbols in Perl?

It seems strange to me that Perl would allow a package to export symbols into another package's namespace. The exporting package doesn't know if the using package already defined a symbol by the same name, and it certainly can't guarantee that it's the only package exporting a symbol by that name. A very common problem caused by this is...

How can I take queries from one file, search another, and output to a third, in Perl?

Edit: My original title has been sort of changed. I suspect the current title does not reveal my original purpose: let perl automatically use the contents of one file as the source of search keywords to search another file and then output the matches to a third file. This means without this kind of automation, I would have to manually ty...

How can Perl share global variables in parallel processing?

use Parallel::ForkManager; use LWP::Simple; my $pm=new Parallel::ForkManager(10); our $a =0; @LINK=( 10,203, 20, 20 ,20 ,10 ,101 ,01 ,10 ) ; for my $link (@LINK) { $pm->start and next; my $lo = ($link * 120.22 )*12121.2121212121212121*( 12121212.1212121+ $link); $a = $a+ $lo ; print $a."\n" ; $pm->finis...

Conversion from Perl to Java

I want to convert the code by Giuseppe Maxia for DBIx::SQLCrosstab to Java. I have done the bulk of the conversion, however I am stuck at these in the code listed below in DBIx::SQLCrosstab::Format. Some pointers on the listed code will be helpful. # find initial columns without sublevels my @header_columns =(); #@header_columns = map ...

How can I read a directory in Perl with one statement?

I'm writing a script that looks for certain files in a directory and processes them. I keep on writing the following: opendir DIR, $dir; @files = readdir DIR; closedir DIR; While I could (and in fact should) wrap this in a function, I was wondering if there's a more elegant way to do this? ...

Can I run a Perl script from stdin?

Suppose I have a Perl script, namely mytest.pl. Can I run it by something like cat mytest.pl | perl -e? The reason I want to do this is that I have a encrypted perl script and I can decrypt it in my c program and I want to run it in my c program. I don't want to write the decrypted script back to harddisk due to secruity concerns, so I ...

Fast algorithm to check membership of a pair of numbers in large (x,y) coordinates in Perl

I have a list of sorted coordinates (let's call it xycord.txt) that looks like this: chr1 10003486 10043713 chr1 10003507 10043106 chr2 10003486 10043713 chr2 10003507 10043162 chr2 10003532 10042759 In reality the this file is very2 large with 10^7 lines. What I want to do is given a...

How can Perl split a line on whitespace except when the whitespace is in doublequotes?

I have the following string: StartProgram 1 ""C:\Program Files\ABC\ABC XYZ"" CleanProgramTimeout 1 30 I need a regular expression to split this line but ignore spaces in double quotes in Perl. The following is what I tried but it does not work. (".*?"|\S+) ...

How can I extract the substring in the last set of parentheses using Perl?

I am using Perl to parse out sizes in a string. What is the regex that I could use to accomplish this: Example Data: Sleepwell Mattress (Twin) Magic Nite (Flip Free design) Mattress (Full XL) Result: Twin Full XL I know that I need to start at the end of the string and parse out the first set of parenthesis just no...

Is the Perl .plx filename extension ever used in real-life?

ActiveState Perl installs an IIS script mapping for the extension .plx. Is this actually used in real life or just something specific to ActiveState? ...

What is the easiest way in pure Perl to stream from another HTTP resource?

What is the easiest way (without opening a shell to curl and reading from stdin) in Perl to stream from another HTTP resource? I'm assuming here that the HTTP resource I'm reading from is a potentially infinite stream (or just really, really long) ...