I'm trying to create a loose word wrapping system via a regex in Perl. What I would like is about every 70 characters or so to check for the next whitespace occurrence and replace that space with a newline, and then do this for the whole string. The string I'm operating on may already have newlines in it already, but the amount of text b...
I have a string I read from a configuration file. Structure of the string is as follows;
(long_string)long_string(long_string)
Any item in brackets, including the brackets themselves, are optional. I have the following regular expression matching the whole string but I could not figure out how to make some parts of the regular express...
So, OK, the job runs in cron: it fetches compressed files and processes them. If the files are corrupted, it deletes them. Sometimes they are bad on the remote server, in which case they will be downloaded and deleted each time.
My cron logs extensively to STDOUT (directed to logfile in .crontab), using STDERR only for things that cause...
Hi,
So I'm quite new to programming in general, so this may be a stupid question, but I am specifically trying to use regexes to strip a CSS tag. Basically I have this:
.style1 {
font-size: 24px;
font-weight: bold;
color: #FFEFA1;
}
and I want it to look like this:
.style1:color:#FFEFA1
I want to maintain the s...
I want to use a constant in my TT template. In HTML::Mason (my previous templating engine of choice) I could do:
<%once>
use MyApp::Constants qw(CONSTANT);
</%once>
How can I do this in Template Toolkit? As mentioned in the title this is a Catalyst app so I was thinking I could put the constants in the stash but that seems a bit awkwa...
How can I check if IP numbers are in the same subnet with Perl? Do I use NetAddr::IP?
Thanks.
...
My problem is that I have a bunch of file names without the version appended (version keeps changing everytime). The file names are in a file in a particular sequence and I need to get the latest version from a folder and then sequentially install the same. The logic would be:
scan a file with contents
read a line from the file
using t...
My original script is as follows:
my $cmd = "dir";
open (H, "$cmd |");
my @result = <H>;
close (H);
print STDERR @result,"\n";
This scripts works fine. If I add following line to the script, it fails to work:
$ENV{"LD_LIBRARY_PATH"} = "/opt/VRTSsfmh/lib";
$ENV{PATH}="/usr/bin:/bin:/sbin:/usr/sbin";
delete @ENV{'IFS', 'CDPATH', 'ENV',...
I want to parse XML files using xPaths. After getting a node I may need to perform xPath searches on their parent nodes. My current code using XML::XPath is:
my $xp = XML::XPath->new(filename => $XMLPath);
# get all foo or foos node with a name
my $Foo = $xp->find('//foo[name] | //foos[name]');
if (!$Foo->isa('XML::XPath::NodeSet') ||...
How can I find the standard site_perl (non-arch specific) location? Is it safe to just loop over @INC and find the path ending with "site_perl", or is there a standard way to do this?
The reason for trying to find this, is I have a very large project built up from hundreds of individual modules, all with their own Makefile.PL files (pre...
I have the following regex to try to reduce groups of newlines:
s/(\n|\r\n|\n\r)(\n|\r\n|\n\r)(\n|\r\n|\n\r)+/\n\n/gmi;
It started out as:
s/\n\n(\n)+/\n\n/gmi
I am looking to reduce the number of newlines that are continuous to a maximum of two in a row (just trying to do some cleanup on some files that I am importing for an inter...
Hi,
is there an easy way to timeout an SQL statement so that it will fail instead of waiting (e.g. deliver an empty result set or an error message or whatever else) so I can let a job's ressource reservation fail and give another one a chance? I'm looking for some DBI option I've overlooked so far; sending SIGALRMs to myself to commit su...
I have two disks, one an ad-hoc backup disk, which is a mess with duplicates everywhere and another disk in my laptop which is an equal mess. I need to backup unique files and delete duplicates. So, I need to do the following:
Find all non-zero size files
Calculate the MD5 digest of all files
Find files with duplicate file names
Separa...
Before you ask, "Why are you using that old version of Perl?", it is out of my hands. I have to use the tools available to me for this project. My question is does anyone know if it is possible, and if so what the syntax looks like to use gridRowconfigure as follows:
$main_window->gridRowconfigure(1, -weight => 1, -minsize => 171, -pa...
I have a list of filenames. I have to create a file for each of those names, write lines to the various files (in no particular order), then close them.
How can I do that in perl? I envision something like the following code (which will not work in that form and give syntax errors):
my @names = qw(foo.txt bar.txt baz.txt);
my @handles...
What are the popular, contemporary uses for Perl?
Edit
I should have been more specific. I was wondering more on the large scale (popular) what people are using Perl for rather than what it could be used for on the individual level.
...
One of my colleagues recently interviewed some candidates for a job and one said they had very good Perl experience.
Since my colleague didn't know Perl, he asked me for a critique of some code written (off-site) by that potential hire, so I had a look and told him my concerns (the main one was that it originally had no comments and it'...
I'd like to limit the memory usage for my Perl script, running on a Linux system. I've been trying to use BSD::Resource's setrlimit, but have been having problems. I'd appreciate any pointers. Thank you.
...
Hi guys,
I am very new to Perl and i am learning on the fly while i try to automate some projects for work. So far its has been a lot of fun.
I am working on generating a report for a customer. I can get this report from a web page i can access.
First i will need to fill a form with my user name, password and choose a server from a dro...
Recently I had a problem using (pipe |-) when I wanted to communicate between two processes.
Basically, the child process couldn't process STDIN as fast as it was filled up by parent. This caused parent to wait until STDIN was free and made it run slow.
How big can STDIN be and is it possible to modify it. If yes, what is the best prac...