If I have a script that is a wrapper for another program (e.g., a daemonizer wrapper or a wrapper for mathematica), it is sometimes useful to trap signals in the wrapper program and pass them along to the subprogram.
For example, here's some Perl code to deal with the INT (interrupt) signal so that if you do ctrl-C after launching the wr...
I would like to know which pattern can I use in sed to make changes in the first line of huge files (~2 GB). The preference for sed is only because I assume it must be faster than a Python or Perl script.
The files have the following structure:
field 1, field 2, ... field n
data
and, given the likelihood of having spaces in the ident...
I come from Asp.Net background and recently got assigned to a Perl web project for maintenance and enhancement. I just know that this project uses some stuff like Catalyst, Mason, Alzabo etc.
There is plenty of time for me to learn. I need some good guidance on where to start.
I'm looking for some good online resources (even webcasts)...
It used to be considered beneficial to include the 'o' modifier at the end of Perl regular expressions. The current Perl documentation does not even seem to list it, certainly not at the modifiers section of perlre.
Does it provide any benefit now?
It is still accepted, for reasons of backwards compatibility if nothing else.
As not...
How do you write a module for Perl? In Python you can use:
# module.py
def helloworld(name):
print "Hello, %s" % name
# main.py
import module
module.helloworld("Jim")
...
In the question "Is returning a whole array from a Perl subroutine inefficient" two people recommend against optimizing if there is no need for it. As a general rule, optimizing can add complexity, and if it's not needed, simple is better. But in this specific case, returning an array versus an array ref, I don't see that there's any a...
The following script stores all the files and directories in the array @file_list.
How do I only filter only files with the .lt6 extension and none other than that?
opendir (CURRDIR, $localdir);
@file_list = grep !/^\.\.?$/, readdir CURRDIR;
print STDOUT "Found Files: @file_list\n";
cheers
...
Hello,
I need some help understanding the following Perl code snippet. I have the following two questions.
1.
What does local *PIPER mean? Even though I've done some Perl programming before the local * syntax is new to me. Is it a pointer?
2.
What is the purpose of
curl http://www.somesite.net/cgi-bin/updateuser.cgi? -d "userid=$use...
I have a huge number of files to sort all named in some terrible convention.
Here are some examples:
(4)_mr__mcloughlin____.txt
12__sir_john_farr____.txt
(b)mr__chope____.txt
dame_elaine_kellett-bowman____.txt
dr__blackburn______.txt
These names are supposed to be a different person (speaker) each. Someone in another IT department ...
Hi! I'm doing a lot of insert queries, and I think it would be best to write a subroutine for it. Something like insertRow($table, @stuff_to_insert). But how can I make the subroutine dynamic when it comes to the @stuff_to_insert, which can be anything from 1-5 arguments?
...
I decided to learn Perl after realizing that most of my bash scripts were getting rather unwieldy in their current form and would become a maintenance nightmare if I continued down that path. A friend showed me a couple of examples using regular expressions and in-built modules in Perl and I was hooked instantly. To that effect I borrowe...
I've grown accustomed to using IPython to try things out whilst learning Python, and now I have to learn Perl for a new job.
Is there anything out there like IPython for Perl? In particular, I'm interested in completion and access to help.
...
Setting the DBIC_TRACE environment variable to true:
BEGIN { $ENV{DBIC_TRACE} = 1 }
generates very helpful output, especially showing the SQL query that is being executed, but the SQL query is all on one line.
Is there a way to push it through some kinda "sql tidy" routine to format it better, perhaps breaking it up over multiple lin...
There are quite a number of modules on CPAN relating to the creation and manipulation of .pdf files, and I'm hoping this community can save me some time going down blind alleys.
I am looking to create .pdf files from scratch, with only simple formatting such as bold/italic and left/right/center justify. Being able to use a template fil...
Perl's system() starts a process, but breaks the parent/child relationship?
test.pl:
use POSIX;
system("./test.sh &");
my $pid = `ps -C test.sh -o pid=`;
print "pid: -$pid-\n";
waitpid($pid, 0);
test.sh:
while true
do
sleep 1
done
When I run test.pl, it finds and prints a correct pid of test.sh. But waitpid() returns -1 an...
Hi!
I'm writing a subroutine for DBI updates, and are having some trouble figuring out how to add placeholder and stuff...
I have this:
sub row_update {
my $table = shift;
my %updates = @_;
my $placeholders = ...
$dbh->do("UPDATE $table SET (foo) WHERE (bar)") etc...
}
Any ideas?
I just want a simple update function where...
If I wrote something in plperlu, when would that module be reloaded? Every time the function ran? The first time it ran? Does the Perl DLL get unloaded if it hasn't been used in a while, and then after that it'd be another module reload?
...
I need to create a Zip archive after filtering the list of files I want to include. Preferably I'd like the module to work in both Windows and Linux.
Since I need to filter the list of files, I don't really want to to use an external program. I'd rather not introduce external dependencies either so I can compile the script into a singl...
I don't want to use sendmail to send an email but would prefer to use SMTP. How can I use Perl to send an email to my GMAIL account?
...
I'm archiving a directory. This directory has a file that is being written by another process. When I tar this using Linux tar/Perl Tar module, in the archive the entry for the file is there but the contents are null.
Before tarring the files are...
-rw-r--r-- 1 irraju dba 28 Feb 18 02:22 a
-rw-r--r-- 1 irraju dba 25 Feb 18 02:23 b
...