Some quote to pick from practical mod_perl
"Usually, a single process serves many requests before it exits, so END blocks cannot be used if they are expected to do something at the end of each request's processing."
So, in my a.cgi script :
my $flag = 1;
END {
# Value for $flag is undefined, if this script is run under mod_perl. ...
my $changelog = "/etc/webmin/Pserver_Panel/changelog.cgi";
my $Milestone;
open (PREFS, $changelog);
while (<PREFS>)
{
if ($_ =~ m/^<h1>(.*)[ ]Milestone.*$/g) {
$Milestone=$1;
last;
}
}
close(PREFS);
Here is an example of the data its extracting from:
<h1>1.77 Milestone</h1>
<h3> 6/26/2009 </h3><ul style="margin-t...
The filename passed from an upload form to a Perl CGI (using CGI.pm) script depends on the client machine and may contain client-dependent path separators. Is there a reliable way of parsing the passed parameter to determine the filename (usually the last sub-string following the last path separator).
...
I'm trying to implement a socket server that will run in most shared PHP hosting.
The requirements are that the Socket server can be installed, started and stopped from PHP automatically without the user doing anything. It doesn't matter what language the socket server is written in, as long as it will run on the majority of shared host...
I am using webmin and I am trying to change some settings in a file. I am having problems if the person uses any weird characters that might trip up sed or Perl using the following code:
&execute_command("sed -i 's/^$Pref.*\$/$Pref \"$in{$Pref}\"/g' $DIR/pserver.prefs.cache");
Where execute_command is a webmin function to basically ru...
Hey,
I have a directory full of images that I would like to resize to around 60% of their original size.
How would I go about doing this? Can be in either Python or Perl
Cheers
Eef
...
How can I rename all files on a drive with .wma and .wmv extensions to .txt extension using Perl regardless how deep they are in the directory structure?
...
I've been having to do some basic feed processing. So, get a file via ftp, process it (i.e. get the fields I care about), and then update the local database. And similarly the other direction: get data from db, create file, and upload by ftp. The scripts will be called by cron.
I think the idea would be for each type of feed, define the...
In Perl, how can I create a subdirectory and, at the same time, create parent directories if they do not exist? Like UNIX's mkdir -p command?
...
I'm trying to create a Perl hash from within a C library. Here's what I've got so far:
static void add_string_to_perl_hash ( HV *hv, char * key, char *value ) {
SV *obj = sv_2mortal(newSVpv(value, 0));
hv_store(hv, (const char *)key, strlen (key), obj, 0);
SvREFCNT_inc(obj);
}
SV * do_get_test_hash () {
static char *foo ="foo"...
I'm trying to optimize handling of large datasets using mmap. A dataset is in the gigabyte range. The idea was to mmap the whole file into memory, allowing multiple processes to work on the dataset concurrently (read-only). It isn't working as expected though.
As a simple test I simply mmap the file (using perl's Sys::Mmap module, using...
I am trying to convert the following Perl regex I found in the Video::Filename Perl module to a Python 2.5.4 regex to parse a filename
# Perl > v5.10
re => '^(?:(?<name>.*?)[\/\s._-]*)?(?<openb>\[)?(?<season>\d{1,2})[x\/](?<episode>\d{1,2})(?:-(?:\k<season>x)?(?<endep>\d{1,2}))?(?(<openb>)\])(?:[\s._-]*(?<epname>[^\/]+?))?$',
I would ...
What is the scope of $1 through $9 in Perl? For instance, in this code:
sub bla {
my $x = shift;
$x =~ s/(\d*)/$1 $1/;
return $x;
}
my $y;
# some code that manipulates $y
$y =~ /(\w*)\s+(\w*)/;
my $z = &bla($2);
my $w = $1;
print "$1 $2\n";
What will $1 be? Will it be the first \w* from $x or the first \d* from ...
How can I use Perl regexps to extract all URLs of a specific domain (with possibly variable subdomains) with a specific extension from plain text. I have tried:
my $stuff = 'omg http://fail-o-tron.com/bleh omg omg omg omg omg http://homepage.com/woot.gif dfgdfg http://shomepage.com/woot.gif aaa';
while($stuff =~ m/(http\:\/\/.*?homepage...
I'm using this CGI script.
CGI is working, but I cannot sent emails from this form in CentOS. Please help me? Do I have to set-up anything for it? or MTA?
...
I am using
Server version: Apache/1.3.34 (Debian)
mod_perl - 1.29
By refering to STDIN, STDOUT, and STDERR Streams
#!/usr/bin/perl5
package main;
use strict 'vars';
{
# Our mighty holy legacy code love to print out message in the middle of operation. Shihh....
# Let's quietly redirect those message to /dev/null.
my $nul...
Hello Everybody,
We use an ajax call for sending the data to the server. The server-side programming is done using Perl to save data into the database.
As we have files which are huge in size we want to display a progress bar which tells the user the percent data posted to the server. How can this be achieved using Ajax and Perl?
Tha...
Most probably I'm missing something obvious here, but why do I need to call the search/replace regex twice to have any effect in the following code? If I call it only once, the replacement doesn't take place :-(
use strict;
use warnings;
use LWP::Simple;
my $youtubeCN = get(shift @ARGV);
die("Script tag not found!\n")
unless $youtubeC...
Currently I am using
system("echo $panel_login $panel_password $root_name $root_pass $port $panel_type >> /home/shared/ftp");
What is the easiest way to do the same thing using Perl? IE: a one-liner.
...
I need a class attribute in Moose. Right now I am saying:
#!/usr/bin/perl
use 5.010;
use strict;
use warnings;
use MooseX::Declare;
class User {
has id => (isa => "Str", is => 'ro', builder => '_get_id');
has name => (isa => "Str", is => 'ro');
has balance => (isa => "Num", is => 'rw', default => 0);
#FIXME: ...