perl

Need help with peak signal detection in Perl

Hi everyone I have some values of intensities from images of yeast colony plates. I need to be able to find the peak values from the intensity values. Below is an example image showing how the values look when graphed. Example of some of the values 5.7 5.3 8.2 16.5 34.2 58.8 **75.4** 75 65.9 62.6 58.6 66.4 71.4 53.5 40.5 26.8 14....

How to efficiently search/replace on a large txt file?

I have a relatively large csv/text data file (33mb) that I need to do a global search and replace the delimiting character on. (The reason is that there doesn't seem to be a way to get SQLServer to escape/handle double quotes in the data during a table export, but that's another story...) I successfully accomplished a Textmate search an...

split: regex to ignore delimiters inside balanced parenthesis

I've got ORDER BY part of the statement and I have to split it at logical parts my $sql_part = <<EOH IF(some_table.some_field <> 3, 1, 0), some_table.other_field, CASE other_table.third_field WHEN IS NULL THEN 2 ELSE 1 END, other_table.third_field EOH and, you know, original string doesn't contain newlines and IF's c...

How can I extract the columns of data with Perl?

I have strings of this kind NAME1 NAME2 DEPTNAME POSITION JONH MILLER ROBERT JIM CS ASST GENERAL MANAGER I want the output to be name1 name2 and position how can i do it using split/regex/trim/etc and without using CPAN modules? ...

Perl recursion help

Hey, I'm trying to write a program that will calculate the dividends of stocks. I did this without a subroutine. Right now, I'm trying to modify it so it can run using a recursive routine. Any help with this? Because I'm not so good at this. Here's the original script + a pathetic attempt. print "A stock xyz's price is now $100. It h...

Java's compareTo() function equivalent in Perl?

What's the the Perl function that achieves the same thing as compareTo() in Java? I know about eq and ne but I want to compare to see if one string is greater than another. ...

How do I make an arbitrary Perl regex wholly non-capturing? (Answer: You Can't)

How can I remove capturing from arbitrarily nested sub-groups in a a Perl regex string? I'd like to nest any regex into an enveloping expression that captures the sub-regex as a whole entity as well as statically known subsequent groups. Do I need to transform the regex string manually into using all non-capturing (?:) groups (and hope...

How do I declare the version number for a Perl module?

I thought I knew how to declare version numbers for modules. But after reading the article "$VERSION Confusion" at Modern Perl Books, a Modern Perl Blog; I'm now more confused than I started. (Ignorance was indeed bliss.) Not that I have hangups about "perfect" code but I'm just really curious why such a trivial matter apparently has no ...

perl code that makes a list of all words that follow a given string in a text file

This is difficult to describe but useful in extracting data in the output I am dealing with (I hope to use this code for a large number of purposes) Here is an example: Say I have a text file with words and some special characters ($, #, !, etc) that reads: blah blah blah add this word to the list: 1234.56 blah blah blah blah b...

Perl - Test::Unit::Lite, how to use multiple folders for test files.

I use Test::Unit::Lite for unit testing in Perl. Now, this module looks for .pm files in t/tlib. However, I have several tests for the project and I would like to separate them in folders like: t/tlib/Unit_Tests/...pm, t/tlib/Functional_Tests/...pm and so on. How can I tell to the unit test module to look for files in subdirectories of ...

Perl pattern matching

Hi All, I have a text file like this this is a junk line this is a junk line2 this is a junk line3 message1 this is first line of text this is second line of text this is third line of text this is fourth line of text this is fifth line of text message1_end the next line I want to start pattern match from message1 onwards and then pri...

How can I redirect 7z-compressed content using LWP::UserAgent as an attachment

I have a perl script which accepts incoming POST and PUT requests from other command line clients, gets the data (gzip) associated with each request and writes out to a seperate file. I want to extend the script by adding redirect functionality. Here is what I'm planning to do * Once the data file is written, forward/redirect the file ...

Perl: Issue command in new cmd.exe

Hi. I want to program in Perl a very basic program but I'm having some questions about how to do it. I'll keep it simple: I want a perl script that when number 1 is pressed a new "cmd.exe" is opened and the "dir" command is executed, and when 2 is pressed a new "cmd.exe" is opened and the command "cd" is executed. The place where I'm ha...

Why does Perl run END and CHECK blocks in LIFO order?

I have no deep or interesting question--I'm just curious why it is so. ...

How do I initialize values in a hash without a loop?

I am trying to figure out a way to initialize a hash without having to go through a loop. I was hoping to use slices for that, but it doesn't seem to produce the expected results. Consider the following code: #!/usr/bin/perl use Data::Dumper; my %hash = (); $hash{currency_symbol} = 'BRL'; $hash{currency_name} = 'Real'; print Dumper(%h...

Subroutines vs scripts in Perl

I'm fairly new to Perl and was wondering what the best practices regarding subroutines are with Perl. Can a subroutine be too big? I'm working on a script right now, and it might need to call another script. Should I just integrate the old script into the new one in the form of a subroutine? I need to pass one argument to the script and...

How would I use a hash slice to initialize a hash stored in a data structure?

In an earlier question I asked how to initialize a Perl hash using slices. It is done like this: my %hash = (); my @fields = ('currency_symbol', 'currency_name'); my @array = ('BRL','Real'); @hash{@fields} = @array; Now let's imagine a more complex hash, and here is how it is initialized: my %hash = (); my $iso = 'BR'; $hash->{$iso}-...

help in parsing

Hi All, I am having a XML file as shown below, <message1> <val1>100</val1> <val2>200</val2> <val3>300</val3> <val4>400</val4> </message1> <message2> <val1>100</val1> <val2>200</val2> <val3>300</val3> <val4>400</val4> </message2> I have to parse the values (val) and i could not use XML::Simple module. The parsing should be started fr...

transfer users between ldap servers

I want to import some users from a tree in one ldap server to another tree in another ldap server, something like all the entries under ou=accounts,ou=dnsmanager,o=mycompany on 10.0.0.1 to ou=users,dc=mycompany,dc=net on 10.0.0.2. I would rather do this in perl but I'm having some problems. For example 10.0.0.1 uses different schema and ...

Web Hosting Issues using my perl script, need help deciding on what language to use to replace perl

I have a website that I am making and I was going to implement a perl script into it. This script goes to another page gets a .csv file and reads in the lines and parses out what I need. The problem I have just ran into is that my hosting server apparently does not allow custom CGI scripts on an MS server. I chose the MS server so I coul...