I have the following loop to calculate the dates of the current week and print them out. It works, but I am swimming in the amount of date/time possibilities in Perl and want to get your opinion on whether there is a better way. Here's the code I've written:
#!/usr/bin/env perl
use warnings;
use strict;
use DateTime;
# Calculate num...
What is the syntax for the hash value for a Perl object member subroutine reference in a dispatch table?
use lib Alpha;
my $foo = new Alpha::Foo;
$foo->bar();
my %disp_table = ( bar => ??? );
I want ??? to be the code reference for $foo->bar().
...
I am using a Perl module called from a CGI scipt in IIS 6 that is bombing. The identical folder structure on an XP machine (IIS 5.1) works fantastic. If I remove the module loading command at line 9, it will print "about to load" and "ok", but When I try to run
use Language::Guess;
I receive
The specified CGI application
mis...
Which package from CPAN should I use to send mail?
Sometime the timtowtdi approach is very tiring. For me, especially when it comes to package selection.
So all I want is to send email, potentially HTML emails. Between Mail-Sendmail, Mail-Sender, NET-SMTP (by the way - not available in PPM), Mail-SendEasy, and the 80 or so other packag...
I have two Perl one liners:
perl -pe "s/\b$a\b/$b/g if m/param1 /" test
and
perl -pe "s/\b$a\b/$b/g unless /^#/" test
How can I combine theif m/somthing/ and the unless /something/, like:
[root@localhost tmp]# perl -pe "s/\b$a\b/$b/g if m/param1/ unless /^#/" test
syntax error at -e line 1, near "m/param1/ unless"
...
I am trying to create a pie chart with no outline using GD::Graph. Frustratingly I can control the colour of the outline with this:
accentclr => 'black',
So I would expect that I could get rid of the outline completely by doing this:
accentclr => undef,
However, when I do this the outline does disappear but the rest of the ...
In my Perl/Tk script I have opened two windows. After a specific button click I want to close one of them. How can I do that? Here's what I have so far:
$main = new MainWindow;
$sidebar = $main->Frame(-relief => "raised",
-borderwidth => 2)
->pack (-side=>"left" ,
-anchor ...
I'm trying to a good Perl module to use for connecting to a Sybase database.
My Googling has led me to see sybperl as a possible choice, but it hasn't been updated since 2005.
...
Is there some way to replace a string such as @or * or ? or & without needing to put a "\" before it?
Example:
perl -pe 'next if /^#/; s/\@d\&/new_value/ if /param5/' test
In this example I need to replace a @d& with new_value but the old value might contain any character, how do I escape only the characters that need to be escaped?
...
I was wondering what the best practice in Perl is regarding getting - or, more importantly, setting - a global variable of some module by directly accessing $Module::varName in case the module didn't provide getter/setter method for it.
The reason it smells bad to me is the fact that it sort of circumvents encapsulation. Just because I ...
I'm having trouble installing Template module with Strawberry Perl.
cpan Template
yields the following:
Writing Makefile for AppConfig
C:strawberryperlbinperl.exe: not found
dmake.EXE: Error code 255, while making 'blib\lib\.exists'`
I haven't been able to understand either
how to affect the path so dmake will work correctly...
Consider this Perl code
my @a=[[1]];
print $a[0][0];
**output**
ARRAY(0x229e8)
Why does it print an ARRAY instead of 1? I would have expected @a to create an array of size 1 with a reference to a second array containing only one element, 1.
...
I've got a document containing empty lines (\n\n). They can be removed with sed:
echo $'a\n\nb'|sed -e '/^$/d'
But how do I do that with an ordinary regular expression in perl? Anything like the following just shows no result at all.
echo $'a\n\nb'|perl -p -e 's/\n\n/\n/s'
...
If I have a Websphere MQ queue defined on another queue manager in the cluster, is there a way I can open it for writing using the Perl interface? The code below brings back mqrc 2085.
$messageQ = MQSeries::Queue->new
(
QueueManager => $qMgr,
Queue => $queue,
Options ...
I'm writing a System::Wrapper module to abstract away from CORE::system and the qx operator. I have a serial method that attempts to connect command1's output to command2's input. I've made some progress using named pipes, but POSIX::mkfifo is not cross-platform.
Here's part of what I have so far (the run method at the bottom basically ...
What is the smartest way of searching through an array of strings for a matching string in Perl?
One caveat, I would like the search to be case-insensitive
so "aAa" would be in ("aaa","bbb")
...
If I am able to start up Devel::Cover successfully and it starts to collect data in the cover_db directory, can I then kill the process and then after the fact get Devel::Cover or some other utility to process those binary Devel::Cover run files and structure files into the HTML coverage report?
To ask the question another way ... Can...
I am trying to manage numerous arguments that are specified by a user when they execute a command. So far, I have been trying to limit my script design to manage arguments as flags that I can easily manage with Getopt::Long as follows:
GetOptions ("a" => \$a, "b" => \$b);
In this way I can check to see if a or b were specified and the...
I'm using Selenium to unit test my Perl cgi script and all works fine except in one special test case where my cgi script returns XML content to the web browser instead of returning HTML content.
I'm new to Selenium and only pasted in their sample script to get started, but I can't seem to find a Selenium command in any of the documen...
I'm trying to write a piece of code that reads a file line by line and stores each line, up to a certain amount of input data. I want to guard against the end-user being evil and putting something like a gig of data on one line in addition to guarding against sucking in an abnormally large file. Doing $str = <FILE> will still read in a...