Is there a better way of doing data validation in Perl than regex?
I have Perl code that does string and numeric data validation using complex regex, and this makes code difficult to read and follow, for everyone.
...
My code used to work fine, and now it's breaking. A reduction of the problem is the following: I want to split a source string (from a database, but that's not important) at a separator. The separator is not fixed, but user provided, in a string. I used to do that:
@results = split($splitString, $sourceStr);
But this breaks when the u...
Hi all,
I'm calling a .net webservice from Linux using Perl (5.8.7).
I'm using the SOAP::Lite library.
The basic proof of concept worked fine and now I'm trying it in the real world where I have to call the webservice many times. Now it looks like the web service call opens a file but does not release the file descriptor. The default m...
In Perl, I'm accustomed to passing arrays to and from subs
sub abc {
foreach my $x (@_) { print $x; }
return (0, 1, 2);
}
How can I achieve similar behavior with SWIG'ed functions?
SWIG'ing this:
std::vector<int> print_list(std::vector<int> l)
{
std::vector<int>::iterator iter;
for(iter=l.begin(); iter!=l.end(); iter++) {
...
I'm trying to understand the following piece of code:
sub foo {
...
if ( $@ ) {
...
die $@;
}
}
...
Does anybody had success parsing *.idx and *.dat files with ruby or perl? I have an old application, without the source code and i want to parse files generated by this legacy code.
Any direction?
...
I am looking for a good way to manage the access to an external FTP server from various programs on a single server.
Currently I am working with a lock file, so that only one process can use the ftp server at a time. What would be a good way to allow 2-3 parallel processes to access the ftp server simultaneously. Unfortunately the provi...
I have a set of HTML reports that each contain two DIV elements with specific IDs that I need to strip out and compile into an overall summary report (again, an HTML file).
My initial thoughts are that this is an ideal job for a Perl script, however we have no up-to-date in-house Perl skills (we're a .NET C# shop).
Thoughts and suggest...
Having more or less converted a lot of old Tk scripts over to Tkx I'm stuck for an port for the following function which repositions the window passed in as a parameter in the centre of the screen. I used to call this just before calling MainLoop, by which point Tk had obviously decided on the reqwidth and reqheight values.
sub CenterWi...
When I try to read an XML file with XML::Simple, sometimes I get this error message:
Couldn't create file parser context for file ...
After some googling, it seems to be a problem with libxml-libxml-perl and is supposed to be fixed in the version I use (1.59-2).
Any ideas?
Edit: (code)
sub Read
{
my ($file, $no_option) = @_;
...
What are some good Perl modules to process files based on configurations?
Basically I am working on taking data files, split them into columns, remove some rows based on some columns, remove unnecessary columns, compare them to baseline (writes where changes have occured) and save a csv of the data and the comments as metadata.
Sample...
I have an ASCII log file with some content I would like to extract. I've never taken time to learn Perl properly, but I figure this is a good tool for this task.
The file is structured like this:
...
... some garbage
...
... garbage START
what i want is
on different
lines
END
...
... more garbage ...
next one START
more stuff I...
I'm currently in a project which develops using a framework developed by another department as the base. We are currently introducing quality standards (at last, yay!) in our department, but it's currently impossible to introduce those to the other department. As a consequence, we are working against a constant moving target without eith...
I'm kinda new to Module::Build, so maybe I did something wrong. Am I the only one who gets warnings when I change my dispatch from "test" to "testcover"? Is there a bug in Devel::Cover? Is there a bug in Module::Build? I probably just did something wrong.
I'm using ActiveState Perl v5.10.0 with Module::Build version 0.31012 and Dev...
I am unit testing a component that requires user input. How do I tell Test::More to use some input that I predefined so that I don't need to enter it manually?
This is what I have now:
use strict;
use warnings;
use Test::More;
use TestClass;
*STDIN = "1\n";
foreach my $file (@files)
{
#this constructor asks for user input...
I'm working my way up towards creating a script that will create image galleries for me.
When I run what I have it tells me
No such file or directory at photographycreate line 16.
------------
(program exited with code: 2)
Here is the code that I've gotten so far.
#!/etc/perl -w
#CHANGE THIS
$filecategory = "cooking";
$filenumber...
I have been asked to automate a particular task at work today which takes up a lot of our time! The following is what needs to be done and I would appreciate any help on how I can do this (Implementation Advice) within the realms of my knowledge, if possible.
Problem
I have a PowerPoint document (.ppt). I would like to extract text fro...
I want to do, in Perl, the equivalent of the following Ruby code:
class Foo
MY_CONST = {
'foo' => 'bar',
'baz' => {
'innerbar' => 'bleh'
},
}
def some_method
a = MY_CONST[ 'foo' ]
end
end
# In some other file which uses Foo...
b = Foo::MY_CONST[ 'baz' ][ 'innerbar' ]
That is, I just want to declare a ...
I am using following code to create and send email through CGI perl. The images get attached properly, but the css files do not.
my $msg = new MIME::Lite(
From => $from,
To => $to_list,
Subject => "My subject",
Type => 'text/html', # 'multipart/mixed'
Data => $body
);
$msg->attach(Typ...
In this earlier Stackoverflow question and especially brian d foy's "How a Script Becomes a Module" I've read about how to set up code so that it can be run as either a script or a module, using this technique:
package SomeModule;
__PACKAGE__->run(@ARGV) unless caller();
sub run {
# Do stuff here if you are running the file as
...