perl

What is $1 in Perl?

What is the $1? Is that the match found for (\d+)? $line =~ /^(\d+)\s/; next if(!defined($1) ) ; $paperAnnot{$1} = $line; ...

How can I extract DNA sequence using a Perl script from UCSC if I have their coordinates?

How can I extract DNA sequence using a Perl script from genome browser (UCSC), if I have their coordinates? ...

Where does $_ come from in this Perl foreach loop?

I found this in Mail::IMAPClient. Where does the $_ in $SEARCH_KEYS{ uc($_) } come from? sub _quote_search { my ( $self, @args ) = @_; my @ret; foreach my $v (@args) { if ( ref($v) eq "SCALAR" ) { push( @ret, $$v ); } elsif ( exists $SEARCH_KEYS{ uc($_) } ) { push( @ret, $v ); ...

Can I redirect to a PHP page from a Perl CGI script?

I am working with a site that uses an outside source to work with payment transactions, one of the prerequisites is that on success a CGI script is called. What I am wanting to know is it possible to do a redirect to a PHP page with the CGI script and have the PHP detect that it has been loaded via a Perl redirect, I currently have this...

What does for (;;) mean in Perl?

Hello! I was looking though a fellow developers code when I saw this .. for (;;){ .... .... .... } I have never seen ";;" used in a loop. What does this do exactly? ...

How can I send XML data from Perl CGI script?

I have no experience with CGI scripts or any web development. I'm developing a client app and just want to have a small CGI script to send and retrieve XML data to test out my client. Right now I'm doing a HTTP GET to get the XML files I need. Now I'm changing my client to do POST with request containing XML data and expecting XML back....

Perl - Create date range looking at 3 fields

I have 3 Columns of data: Item | CreateDate | Version | ABC | 1/1/2010 | X | ABC | 3/15/2010 | XB | BBB | 2/15/2010 | X | BBB | 6/15/2010 | X | How might I populate two additional columns of data named Version Start & Version End that would calculate the start date of the version and ...

How can I get WWW-Mechanize to login to Wells Fargo's website?

I am trying to use Perl's WWW::Mechanize to login to my bank and pull transaction information. After logging in through a browser to my bank (Wells Fargo), it briefly displays a temporary web page saying something along the lines of "please wait while we verify your identity". After a few seconds it proceeds to the bank's webpage where I...

Can a Perl subroutine return data but keep processing?

Is there any way to have a subroutine send data back while still processing? For instance (this example used simply to illustrate) - a subroutine reads a file. While it is reading through the file, if some condition is met, then "return" that line and keep processing. I know there are those that will answer - why would you want to do tha...

How can I convert SQL comments with -- to # using Perl?

UPDATE: This is what works! fgrep -ircl --include=*.sql -- -- * I have various SQL files with '--' comments and we migrated to the latest version of MySQL and it hates these comments. I want to replace -- with #. I am looking for a recursive, inplace replace one-liner. This is what I have: perl -p -i -e 's/--/# /g'` ``fgrep -- -- ...

How can I convert a file to an HTML table using Perl?

I am trying to write a simple Perl CGI script that: runs a CLI script reads the resulting .out file and converts the data in the file to an HTML table. Here is some sample data from the .out file: 10.255.202.1 2472327594 1720341 10.255.202.21 2161941840 1484352 10.255.200.0 1642646268 1163742 10.255.200.96 1489876452...

Why do I get a "Bad Gateway" error with my Perl CGI program on IIS?

I'm trying to run sample Perl script on Windows 7 and I configured IIS 7 to allow ActivePerl to run but I'm getting this error: HTTP Error 502.2 - Bad Gateway The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are "Hello World. ". Module CgiModule Notification Execut...

How can I get node coordinates from a graph, using Perl?

Ok, I have a flowchart definition (basically, array of nodes and edges for each node). Now I want to calculate coordinates for every task in the flow, preferably hierarchycal style. I need something like Graph::Easy::Layout but I have no idea how to get nodes coordinates: I render nodes myself and I only want to retrieve box coordinate...

Is there a better tool than postcat for viewing postfix mail queue files?

So I got a call early this morning about a client needing to see what email they have waiting to be delivered sitting in our secondary mail server. Their link for the main server had (still is) been down for two days and they needed to see their email. So I wrote up a quick Perl script to use mailq in combination with postcat to dump e...

Should I convert overlong UTF-8 strings to their shortest normal form?

I've just been reworking my Encoding::FixLatin Perl module to handle overlong UTF-8 byte sequences and convert them to the shortest normal form. My question is quite simply "is this a bad idea"? A number of sources (including this RFC) suggest that any over-long UTF-8 should be treated as an error and rejected. They caution against "n...

How can I output a UTF-8 encoded XML file with unix line-endings from ActivePerl on Windows?

I'm running ActivePerl 5.8.8 on WinXP. I'd like to output an XML file as UTF-8 with UNIX line endings. I've looked at the perldoc for binmode, but am unsure of the exact syntax (if I'm not barking up the wrong tree). The following doesn't do it (forgive my Perl - it's a learning process!): sub SaveFile { my($FileName, $Contents) = ...

Why do I get an error when I try to load a font file with Perl's Imager::Font?

use strict; use Imager; use Imager::Font; my $img = Imager->new(); my $file = "D:\\table.png"; $img->open(file=>$file) or die $img->errstr(); # Create smaller version my $thumb = $img->scale(scalefactor=>1.2); my $black = Imager::Color->new( 0, 0, 0 ); my $format; # Autostretch individual channels $thumb->filt...

Why do I get "Error 6060" when I try to use DBD::Advantage with a 64-bit perl on Linux?

I realize that I am attempting to go beyond the "supported" behavior of the manf's released drivers for Perl, after all they have only released it in package with x86 .so's. However, since I cannot use their package with x64 Perl on a RHEL 5.4 x86_64 box, and maintaining a seperate install of x86 Perl just for this one package, I have m...

So, I have this jquery bit that adds a row to a table the way I need it to, but it's UGLY

I have a table that looks like this: <table name="exercises" id="workout-table"> <tr> <th>Name</th> <th>Reps/Intervals</th> <th>Sets</th> <th>Weight/Distance/Time</th> </tr> [%- i=0 %] [% WHILE i<=10 %] <tr class="workout-rows"> <td><input type="text" name="workout[exercise][[% i %]][name]" /></td> <td><input type="text" name="workou...

Does the foreach statement iterate in order or it might be random order?

I was wondering if the foreach statement in Perl iterates the items in an array in consistent order? That is, do I get different results if I use foreach multiple times on the same array or list? ...