This question is somewhat related to What’s the simplest way to make a HTTP GET request in Perl?.
Before making the request via LWP::Simple I have a hash of query string components that I need to serialize/escape. What's the best way to encode the query string? It should take into account spaces and all the characters that need to be es...
I'm trying to monkey-patch (duck-punch :-) a LWP::UserAgent instance, like so:
sub _user_agent_get_basic_credentials_patch {
return ($username, $password);
}
my $agent = LWP::UserAgent->new();
$agent->get_basic_credentials = _user_agent_get_basic_credentials_patch;
This isn't the right syntax -- it yields:
Can't modify non-lval...
I need a generic transliteration or substitution regex that will map extended latin characters to similar looking ASCII characters, and all other extended characters to '' (empty string) so that...
é becomes e
ê becomes e
á becomes a
ç becomes c
Ď becomes D
and so on, but things like ‡ or Ω or ‰ just get striped away.
...
Perl
print 2 % -18;
-->
-16
Tcl
puts [expr {2 % -18}]
-->
-16
but VBScript
wscript.echo 2 mod -18
-->
2
Why the difference?
...
Yes, the problem is with a library I'm using, and no, I cannot modify it. I need a workaround.
Basically, I'm dealing with a badly written Perl library, that exits with 'die' when a certain error condition is encountered reading a file. I call this routine from a program which is looping through thousands of files, a handful of which ar...
I am working on a little Perl module and for some reason I had the test driver script that was using my new module call one of the functions that I thought would be private, and it was successful. I was surprised, so I started searching google and I couldn't really find any documentation on how to make private functions in Perl modules....
Is it possible to send an Email with only cc or bcc recipients using Mail::Sender? When I try to send an Email without a "to" address, I get the expected return code:
-8 = argument $to empty
...
I’m trying to figure out how to iterate over an array of subroutine refs.
What’s wrong with this syntax?
use strict;
use warnings;
sub yell { print "Ahh!\n"; }
sub kick { print "Boot!\n"; }
sub scream { print "Eeek!\n"; }
my @routines = (\&yell, \&kick, \&scream);
foreach my $routine_ref (@routines) {
my &routine = &{$routine_ref};...
I was glancing through some code I had written in my Perl class and I noticed this.
my ($string) = @_;
my @stringarray = split(//, $string);
I am wondering two things:
The first line where the variable is in parenthesis, this is something you do when declaring more than one variable and if I removed them it would still work right?
Th...
A medical office that I do work for uses MIS that does not have ODBC. There is an export function, however, and it seems to dump it into a "export.DB" file. In Windows, that is traditionally a Paradox database; however, in snooping around the directory architecture, it looks like there's a portable Sybase server. Is there any way to a...
I have a basic Apache 2.2.9 setup under fedora core 8. I would like to set my own HTTP headers to come out (HTTP Forbidden / 403).
If I name the file nph-foo.pl, it works. If I name the file foo.pl, it fails and I get a server error, type 500.
According to all web references I've found, the nph-filename convention was no longer necess...
The Apache module mod_autoindex generates "directory indexes" that show users a crude hyperlinked list of the files and directories inside a directory (when there is no index.html or other DirectoryIndex file).
I have a directory on an Apache webserver where I want to provide an automatic directory listing, including the full filenames,...
I have a page written in Perl by someone else. I don't know Perl, so I wrote a PHP file that right now just links from the Perl page. What I'd like to do is embed the PHP file in the Perl file if the perl page has been passed a certain variable. If I were using PHP for both I could just do
if ($_GET['sidebar']) include "embedded.php";
...
I am running into the
DBD::mysql::st execute failed: Got a packet bigger than 'max_allowed_packet' bytes
error when trying to make a large insert using Perl & MySQL. I know that increasing the max_allowed_packet setting in my.cnf could fix this, but is it possible to tell DBI (or DBD::mysql, since my app really only needs to work wi...
There are several ways to do this, but I'm not sure which one of them is the best.
Here's what I can think of:
Look for the process using pgrep.
Have the script lock itself using flock, and then check if it is locked each time it runs.
Create a pid file in /var/run/program_name.pid and check for existence, and compare pids if needed.
...
I have two dates (parsed using str2time). How can I tell if one is after the other?
...
I am writing a perl script that manipulates password protected zip files. Consequently I need to store & retrieve passwords to do this. I have three options for storing the password:
Store in plain text. Before you jump in, I have pretty much ruled out this option.
Use a simple password munger to prevent casual/accidental access (even ...
I'm coming to learn Perl from a Python background where the following hash-to-string conversion is built in to the language:
>>> d = {'a': 1, 'b': 2, 'c': 3}
>>> str(d)
"{'a': 1, 'c': 3, 'b': 2}"
Is there a builtin and/or module that has a subroutine with output along the lines of:
"('a' => 1, 'b' => 2, 'c' => 3)"
Strangely, a web ...
I'm doing some research on online Graphing packages for different languages and would like to know what current up-to-date graphing packages there are for Perl which are worth investigating
Minimum desired capabilities should include the kind which Google offers through its API
A brief synopsis of the key benefits of the recommended pa...
I've got a polymorphic array of objects which implement two (informal) interfaces. I want to be able to differentiate them with reflection along the lines of:
if (hasattr(obj, 'some_method')) {
# `some_method` is only implemented by one interface.
# Now I can use the appropriate dispatch semantics.
} else {
# This must be th...