perl

Perl cgi script left running when client closes webpage mid-download

Hi I have a perl script (Cgi / Apache / Windows) which executes some programs on the computer, and formats the output for the web. The script takes about 4-5 minutes to completely run. My problem is that when someone cancels page load (or closes the web browser) while the script is running, the perl process in the server will keep runni...

how to pass an array to a perl cgi script with a HTML form?

In a HTML form, if we give names to input boxes with [], like this <input name="foo[]" type="text" /> <input name="foo[]" type="text" /> In PHP, we can obtain values of these input boxes in an array, with $_POST['foo']. How to do the similar in Perl? I use CGI.pm ...

How to convert WEP key to ASCII passphrase?

Does anyone have a hex->ascii method to reverse the WEP encryption? I have my WEP key (eg F2:E8:54:22:F3), but can't remember my passphrase. I'm not too concerned with the accuracy of the passphrase. I found this site, which has a Linux program that seems to work with values of keys generated by this site (supposedly the same WEP enc...

`use` package scope: how to make it cross files?

In scriptA.pl, there is use DBI In scriptB.pl, there is require "scriptA.pl" But we still cannot use DBI package in scriptB.pl Any way to handle this except repeating use DBI in scriptB.pl? ...

Probabilistic selection from a set

Suppose I want to randomly select a number n between 0 and 30, where the distribution is arbitrary, and not uniform. Each number has a corresponding weight P(n): P(0) = 5, P(1) = 1, P(2) = 30, P(3) = 25, and so on and so forth. How do I do a random selection from this set, such that the probability of selecting a number is proportional t...

Direct STDERR when opening pipe in perl

I am using open( my $command_out, "-|", $command_string ) to execute a command and process its output on the fly (not having to wait for the command to finish first, as in system()). I noticed that when I call some R scripts this way, some of R messages are printed to the screen (e.g. Loading required package: ...). I guess this is bec...

How can Install multiple Perl versions without them tripping over each other's XS modules?

I would like to install several different versions of perl in my home directory. I tried using App::perlbrew, but XS modules from one version were causing segfaults in the other version. Is there any way to install multiple versions of perl and have them automatically keep their XS modules separate? ...

perl + how to declares array

hi all the following script (test.pl) append $insert[1] text between $first_line[1] and $second_line[1] on myfile.txt file and send output to output.txt but if I declare the array as my $first_line[1]=")"; my $second_line[1]="NIC Hr_Nic ("; my $insert[1]="hello world line 2 line3 " I get sy...

Pass variables around the around method modifier

Is it possible to pass variables between multiple calls to the around MethodModier? example (that doesn't work but hopefully conveys what I want to do) sub mysub { ... }; around 'mysub' => sub { my $orig = shift; my $self = shift; my $value = get_value; $self->orig(@_); }; around 'mysub' => sub { my $orig = shift; ...

perl + setting legal parameter without spaces

hi all question: how to remove spaces after the numbers if exists? from the parameter? parameter can include any text my test.pl #!/usr/bin/perl $parameter[1]='123 456 573 763 integer' ; print $parameter[1]; ./test.pl > out.pl more out.pl 123[space] ...

Can I order order method modifiers loaded as part of traits?

This is a follow up to a previous question. if I have multiple plugins/traits with around modifiers, is it possible to ensure a certain execution order (seeing as how I can't be sure which will actually get loaded)? or can I really only control that in code I write and with documentation? Example: I have 3 Roles each with an around and ...

accessing a Moose Array

Having trouble figuring out the syntax (which I'm sure is obvious and I'm stupid) for pushing to a Moose array. This is a continuation of this question. it seems to me that I need to more than a simple value for my specific case. Trying to implement it using a Moose-ish way (maybe that's wrong?) but I'm obviously not doing it right. use...

Perl and Environment Variables

Some of the environmnet variables which we use in Unix are as below (just an example): VAR1=variable1 VAR2=variable2 VAR3=variable3 # and so on Now, I have a perl script (let's call it test.pl) which reads a tab delimited text file (let's call it test.txt) and pushes the contents of it columnwise in separate arays. The first column of...

How do I format email outputs in Perl?

I am very new to writing in Perl. I have a checkout pl which sends an email to the buyer with details of their order. How do I format in Perl to display the order in a "pretty" format such as tables, coloured background images etc like in an html page??? This is the section of code I would like to format into something more attractiv...

Perl to Php Translation

may you convert this Perl code to PHP code ? use HTTP::Request::Common qw(POST); use LWP::UserAgent; $ua = new LWP::UserAgent(agent => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.5) Gecko/20060719 Firefox/1.5.0.5'); $ua -> timeout(0.5); my $req = POST 'http://forums.shooshtime.com/', [ vb_login_username => 'mehdi' , vb_lo...

perl + inserting text

hi all the following script text.pl (described below) define to append the $insert text between $first_line and $second_line in the file - myfile.txt While: $first_line=A $second_line=B $insert = "hello world" for example before test.pl running A B After I run test.pl we get: A hello world B the problem: but if there line s...

Using Perl to move commas from end of line to begining of line

I've inherited a few dozen sql scripts that look like this: select column_a, column_b, column_c from my_table To format them so they match the rest of our sql library, I'd like to change them to look like this: select column_a ,column_b ,column_c from my_table where the commas start at the beginning ...

Dependency problem of Perl CPAN modules

I tried to install SOAP::WSDL on Ubuntu 8.04 Server through CPAN but got the following error message: cpan> install SOAP::WSDL Running install for module SOAP::WSDL Running make for M/MK/MKUTTER/SOAP-WSDL-2.00.10.tar.gz Checksum for /root/.cpan/sources/authors/id/M/MK/MKUTTER/SOAP-WSDL-2.00.10.tar.gz ok SOAP-WSDL-2.00.10/ SOAP-WSDL-2.00...

How to check if today is a weekend in bash?

How to check if today is a weekend using bash or even perl? I want to prevent certain programs to run on a weekend. Thanks ...

Clean up CREATE TABLE column layout

I've got a series of sql scripts that look like this: CREATE TABLE table_one ( column_one int not null, column_two varchar(100) not null, column_three_four_five int, column_six decimal(16,4) null, PRIMARY KEY ( column_one, column_three_four_five) ); I'd like to clean up the layout t...