I am writing an application to allow users to schedule one-time long-running tasks from a web application (Linux/Apache/CGI::Application). To do this I use the the Schedule::At module which is the Perl interface to the "at" command. Since the scheduled tasks are not repeating, I am not considering "cron". I have two issues with "at" thou...
Hi All,
The following code produces pretty much what I want, but the scrollable pane on the left doesn't scroll. I am using ActivePerl 5.8.9 Build 825:
The code is:
use Tk;
use Tk::Pane;
use Tk::LabFrame;
# create the application window
my $MW = MainWindow->new ( -background => "GREY" );
# set the x/y size for the window
$MW->geomet...
In Perl, what is the difference between ' and " ?
For example, I have 2 variables like below:
$var1 = '\(';
$var2 = "\(";
$res1 = ($matchStr =~ m/$var1/);
$res2 = ($matchStr =~ m/$var2/);
The $res2 statement complains that "Unmatched ( before HERE mark in regex m".
...
I'm using the Statistics::Descriptive library in Perl to calculate frequency distributions and coming up against a floating point rounding error problem.
I pass in two values, 0.205 and 0.205, (taken from other numbers and sprintf'd to those) to the stats module and ask it to calculate the frequency distribution but it's getting stuck i...
Hello,
I have a function that is doing some calculations and then passes some properties into another subroutine like so:
sub get_result {
my $id = 1;
my %diet = ( result => 28,
verdict => 'EAT MORE FRUIT DUDE...'
);
my %iq = ( result => 193,
verdict => 'Profess...
I have a CSV file that was extracted from a ticketing system (I have no direct DB access to) and need to append a couple of columns to this from another database before creating reports off of it in Excel.
I'm using Perl to pull data out of the other database and would like to just append the additional columns to the end of each line a...
I'd like to know if it's possible to execute more than one SQL statement within a single execute() or do() call using DBD::Oracle via Perl DBI. Example:
# Multiple SQL statements in a single query, separated by a ";"
$sql = 'UPDATE foo SET bar = 123; DELETE FROM foo WHERE baz = 456';
$sth = $dbh->prepare($sql);
$sth->execute;
# ...or...
I just noticed CGI::Simple while looking something up for the CGI.pm module. Should I be using CGI::Simple instead? What will it offer me over CGI.pm, which I've used for eight years? I see that CGI::Simple doesn't do HTML generation; what should I be using for that? And will it integrate with CGI::Simple by allowing me to make form ...
In Perl, is it possible to determine if a script is being executed within another script (presumably via system or qx)?
$ cat foo.pl
print "foo";
print "\n" if not $in_qx; # or the like.
I realize this is not applicable if the script was being run via exec.
I know for certain that system runs the process as a fork and I know fork c...
I am trying to come up with a regular expression in Perl matching multiple patterns and returning all of them like preg_match_all in PHP does.
Here's what I have:
$str = 'testdatastring';
if($str =~ /(test|data|string)/) {
print "its found index location: $0 $-[0]-$+[0]\n";
print "its found index location: $1 $-[1]-$+[1...
Background
Below is a typical piece of Perl code (sample.pl for the sake of discussion) that grabs submitted form data using CGI, passes the form data to DBI which will then retrieve the required rows from MySQL and then hands the results over to Template Toolkit to render into a HTML document for display.
Code listing for sample.pl :
...
Hi,
I'm working with the Parse::RecDescent parser in Perl, and I seem to have the most terrible time getting information from it. The information readily available online does not seem to have non-trivial examples.
Here is the code:
event_function: object_list ':' event_list ';'
<defer:
{ #item is a special character w...
Anybody care to translate this into obfuscated perl? It's written in Python taken from: here
def r(a):i=a.find('0');~i or exit(a);[m
in[(i-j)%9*(i/9^j/9)*(i/27^j/27|i%9/3^j%9/3)or a[j]for
j in range(81)]or r(a[:i]+m+a[i+1:])for m in'%d'%5**18]
from sys import*;r(argv[1])
I realize it's just for fun :)
...
I am writing a Bulk Mail scheduler controlled from a Perl/CGI Application and would like to learn abut "good" ways to fork a CGI program to run a separate task? Should one do it at all? Or is it better to suffer the overhead of running a separate job-queue engine like Gearman or TheSchwartz as has been suggested recently. Does the answer...
Hi there,
Longtime user/browswer, first time question-asker.
I'm writing a Perl script that will go through a number of HTML files, search them line-by-line for instances of "color:" or "background-color:" (the CSS tags) and print the entire line when it comes across one of these instances. This is fairly straightforward.
Now I'll ad...
I'm being forced (by engineering policy) to use Getopt::Euclid to parse
arguments to my Perl program. I have three arguments, foo, bar and blah.
It is legitimate to have none of these and use other arguments instead.
If foo is present than exactly one of bar or blah should be present,
and if either bar or blah are present, than foo mu...
Is there a way to precompile a regex in Perl? I have one that I use many times in a program and it does not change between uses.
...
Hello,
I asked a question earlier today regarding using Perl to search in a CSS document. I have since refined my requirements a little bit, and have a better idea of what I am trying to do.
The document I am searching through is actually an .html doc with CSS as a style in the <head>, if that makes sense.
Basically, what I need to d...
I am working on a preprocessor that is analyzing a DSL. My goal is to remove the comments.
The block comment facility is demarcated by %% before and after. I do not have to worry about %% being in strings, by the definition of the language.
I am using this s/// regex. Unfortunately, it seems to match everything and wipe it out:
#Remove...
So I'm working on a server where I can't install any modules whatsoever. Yes this makes my job difficult.
To complete the rest of my script I need to do something that I had thought would be fairly straightforward but it seems to be anything but.
I'm trying to open an .html file as one big long string. This is what I've got:
ope...