I have a small text file that I'd like to read into a scalar variable exactly as it is in the file (preserving line separators and other whitespace).
The equivalent in Python would be something like
buffer = ""
try:
file = open("fileName", 'rU')
try:
buffer += file.read()
finally:
file.close()
except IOErro...
I have an application in Perl that reads in HTML based mark up and converts it to a textual output. One of the things I have encountered is the need to easily convert a HTML table to a fixed font output.
<table border="1">
<tr><td>Hello</td>
<td>World</td>
<tr>
<td>foo</td>
<td>bar</td>
</tr></table>
I am looking f...
I tried this:
test1.pl >output.log 2>&1
but this is the result:
Can't dup STDOUT: Permission denied at C:/Perl/lib/Test/Builder.pm line 1376.
Compilation failed in require at C:/Perl/lib/Test/Builder/Module.pm line 3.
BEGIN failed--compilation aborted at C:/Perl/lib/Test/Builder/Module.pm line 3.
Compilation failed in require at C:/...
Hi!
I am able to extract the images from a PDF file using many Perl modules, but none of them specifies the exact positions of the images being extracted (where the image actually belongs).
Could anyone suggest to me how to extract the images along with their positions?
Thanks in advance.
...
I want to have some work done on the Network front, pinging numerous computers on a LAN and retrieving data about the response time. Which would be the most useful and productive to work with: Perl or Python?
...
Hi,
I'm puzzled with this test script:
#!perl
use strict;
use warnings;
use encoding 'utf8';
use Test::More 'no_plan';
ok('áá' =~ m/á/, 'ok direct match');
my $re = qr{á};
ok('áá' =~ m/$re/, 'ok qr-based match');
like('áá', $re, 'like qr-based match');
The three tests fail, but I was expecting that the use encoding 'utf8' would u...
I'm trying to get my head around i18n with Catalyst. As far as I understood the matter, there are two ways to make translations with Perl: Maketext and Gettext. However, I have a requirement to support gettext's .po format so basically I'm going with gettext.
Now, I've found Catalyst::Plugin::I18n and thus Locale::Maketext::Lexicon, whi...
I have a Perl app that runs some perforce operations, in the end I would like it to upload the results to SharePoint website.
What is the simplest Perl script that can accomplish a task of adding a document to SharePoint?
The script would need to run on Solaris and use as few as possible external libraries as possible (definetely pur...
I am embedding perl in a C++ application that uses Smartheap. Regardless of whether I compile the perl to use its own malloc or the system's I get a bunch of error mem___bad_pointer dialogs. It seems to work fine when I just click "ok" and ignore the errors, but obviously I need to actually solve the problem.
Do I maybe need to compil...
In Perl, the % operator seems to assume integers. For instance:
sub foo {
my $n1 = shift;
my $n2 = shift;
print "perl's mod=" . $n1 % $n2, "\n";
my $res = $n1 / $n2;
my $t = int($res);
print "my div=$t", "\n";
$res = $res - $t;
$res = $res * $n2;
print "my mod=" . $res . "\n\n";
}
foo( 3044.952963...
I'm trying to use Class::DBI with a simple one parent -> may chidren relationships:
Data::Company->table('Companies');
Data::Company->columns(All => qw/CompanyId Name Url/);
Data::Company->has_many(offers => 'Data::Offer'=>'CompanyId'); # =>'CompanyId'
and
Data::Offer->table('Offers');
Data::Offer->columns(All => qw/OfferId CompanyId...
In Perl, I can replicate strings with the 'x' operator:
$str = "x" x 5;
Can I do something similar in Python?
...
Is it possible to define anonymous subroutines in a hash constructor in Perl?
I'm trying to do something like this:
my %array = { one => sub { print "first $_[0]" },
two => sub { print "next $_[0]" },
three => sub { print "last $_[0]" }};
$array{$foo}->('thing');
But it isn't working. The code seem...
Hello,
I followed the example at http://wiki.class-dbi.com/wiki/Overriding_autogenerated_accessors
I want to modify the URL before it is inserted to the database:
package Hosting::Company;
use base 'Class::DBI';
my $class = __PACKAGE__;
$class->table('Companies');
$class->columns(Primary => 'CompanyId');
$class->columns(Others => qw...
Are there any free Perl IDEs out there for Windows that have debugging capabilities, syntax highlighting, and possibly even IntelliSense?
...
As per the title, I'm trying to find a way to programmatically determine the longest portion of similarity between several strings.
Example:
file:///home/gms8994/Music/t.A.T.u./
file:///home/gms8994/Music/nina%20sky/
file:///home/gms8994/Music/A%20Perfect%20Circle/
Ideally, I'd get back file:///home/gms8994/Music/, because that's th...
I have a Perl-based CGI/Fast CGI web service and want to rate-limit clients by IP address to stop aggressive clients causing too much work.
I have looked around for some code and found Algorithm::TokenBucket in CPAN but that is for client requests; it has no persistence and has no per-user config so is not really useful for server-side ...
I recently started using the module MooseX::Declare. I love it for its syntax. It's elegant and neat. Has anyone come across cases where you would want to write many functions (some of them big) inside a class and the class definition running into pages? Is there any workaround to make the class definition to just have the functions decl...
I have been doing some OO Perl programming and I was wondering: which is the best way to perform unit tests?
So far I have been using the Test::Simple module to perform tests, but it feels
insufficient for what I want.
Can you point me to some nice modules for that?
...
hi guys,
i'm currently working on a perl web app LAMP style and recently stumbled upon this death maze of code left by some previous developer. He left so many magic numbers and weird logic that it's gives me a headache everytime i had to go through it.
I'm learning unit testing right now so i want to find some useful tool to refactor t...