Unfortunately, I'm not familiar with Perl, so asking here. Actually I'm using FCGI with Perl.
I need to 1. accept a POST request -> 2. send it via POST to another url -> 3. get results -> 4. return results to the first POST request (4 steps).
To accept a POST request (step 1) I use the following code (found it somewhere in the Internet...
I have a perl cgi script that's fairly resource intensive (takes about 2 seconds to finish). This is fine as long as only at most 4 or 5 of them are running at the same time and that's usually the case.
The problem is that when a user clicks a link that calls this script, a new process is spawned to handle that connection request, so if...
In the example below the following regex (".*?") was used to remove all dialogue first.
The next step is to remove all remaining sentences starting with a lower case letter.
Only sentences starting with an upper case letter should remain.
Example:
exclaimed Wade. Indeed, below them were villages, of crude huts made of timber
an...
How can I replace the same text in folder names in linux?
Say I have "Photos_Jun", "Photos_July", "Photos_Aug", etc. whats the simplest way I can rename them like "Photos Jun", "Photos July", etc (basically I want to replace the underscore with a space " ". I have about 200 of these folders.
I was looking at solution: http://stackoverf...
I got a headache looking for this:
How do you use s/// in an expression as opposed to an assignment. To clarify what I mean, I'm looking for a perl equivalent of python's re.sub(...) when used in the following context:
newstring = re.sub('ab', 'cd', oldstring)
The only way I know how to do this in perl so far is:
$oldstring =~ s/ab/c...
I'm having trouble using the following code inside my Perl script, any advise is really appreciated, how to correct the syntax?
# If I execute in bash, it's working just fine
bash$ whois google.com | egrep "\w+([._-]\w)*@\w+([._-]\w)*\.\w{2,4}" |awk ' {for (i=1;i<=NF;i++) {if ( $i ~ /[[:alpha:]]@[[:alpha:]]/ ) { print $i}}}'|head -n1...
What is the simplest code in perl to monitor trap from any devices such as UPS, Rectifier, AirCond etc. In example we want to monitor temperature, server room humidity, aircond level etc. Each devices such as UPS, there are SNMP card inside and then we put out trap server IP address. Currently I am using snmptt open software application....
I have index.pl and subs.pl. When I run the program, the user inserts the date of birth and then it is passed to the getage() subroutine in subs.pl, which has many subroutines.
getage() than implicitly calls another subroutine called validate() which validates the date entered by user.
When I run the index.pl and the user enters the dat...
What is the current state of Perl 6, is it production-ready?
Where do we stand right now?
There are many programmers curious about the current progress of Perl 6.
There are also two other topics open on on reddit and http://perlmonks.org/?node_id=835419 about this.
...
Hi,
I know I can do this,
------
open(F,">",\$var);
print F "something cool";
close(F);
print $var;
------
or this,
open(F, "| ./prog1 | ./prog2 > tmp.file");
print F "something cool";
close(F);
but is it possible to combine these? The semantics of what I'd like to do should be clear from the following,
open(F,"|./prog...
I have a wget-like script which downloads a page and then retrieves all the files linked in IMG tags on that page.
Given the URL of the original page and the the link extracted from the IMG tag in that page I need to build the URL for the image file I want to retrieve. Currently I use a function I wrote:
sub build_url {
my ( $base...
I've currenly trying to pull out dates from a file and feed them directly into an array. My regex is working, but I have 6 groups in it, all of which are being added to the array, when I only want the first one.
@dates = (@dates, ($line =~ /((0[1-9]|[12][0-9]|3[01])(\/|\-)(0[1-9]|1[0-2])(\/|\-)([0-9][0-9][0-9][0-9]|[0-9][0-9]))/g ));
...
I have some unicode codepoints (\u5315\u4e03\u58ec\u4e8c\u4e0a\u53b6\u4e4b), which I have to convert into actual characters they represent.
What's the simplest way to do so?
Thank you.
...
Is it possible to continue displaying a CGI script's HTML without waiting for a child process to complete, yet the child process should stay alive when the CGI script is complete.
Here's what I have,
-- Display HTML page
# html page set up... so header/other stuff
#the -c, -h are params are just params
system("perl subproc...
Each of my users has a (possibly) different TZ defined in their .bashrc. I have a Perl script that displays date/time and want it to have it display with their profile time zone.
Does anyone know the best way to do this?
...
I've downloaded the IBM DBI package, including all the packages in my program as specified in the docs. I've cataloged the DB and can connect to it from the command line, but my DBI connect fails:
$dbh = DBI->connect ("dbi:DB2:warehou1", user, pass) or die "Can't connect to sample database: $DBI::errstr";
Can't connect to sample datab...
I've got a strange issue with a server accepting TCP connections. Even though there are normally some processes waiting, at some volume of connections it hangs.
Long version:
The server is written in Perl and binds a $srv socket with the reuse flag and listen == 5. Afterwards, it forks into 10 processes with a loop of $clt=$srv->accept...
Is there a way to load a profile inside Perl?
Like in shell files:
. ~user/.profile
...
What's the best way to do base36 arithmetic in Perl?
To be more specific, I need to be able to do the following:
Operate on positive N-digit numbers in base 36 (e.g. digits are 0-9 A-Z)
N is finite, say 9
Provide basic arithmetic, at the very least the following 3:
Addition (A+B)
Subtraction (A-B)
Whole division, e.g. floor(A/B).
S...
I want to run some commands using the system() command, I do this way:
execute_command_error("trash-put '/home/$filename'");
Where execute_command_error will report if there was an error with whatever system command it ran. I know I could just unlink the file using Perl commands, but I want to delete stuff using trash-put as it's a ty...