I recently wrote a script which parsed a text representation of single binary byte month field.
(Don't ask :-{ )
After fiddling with sprintf for a while I gave up and did this;
our %months = qw / x01 1
x02 2
x03 3
x04 4
x05 5
x06 6
x07 7
x08 8
x09 9
x0a 10
...
I've searched the Internet and have found some good solutions for teeing STDOUT to 2 different places. Like to a log file and also to the screen at the same time. Here's one example:
use IO::Tee;
my $log_filename = "log.txt";
my $log_filehandle;
open( $log_filehandle, '>>', $log_filename )
or die("Can't open $log_filename for append...
Is there a faster solution than my actual 'zcat' solution to gunzip files with Perl?
A little benchmark:
#!/usr/bin/perl
use strict;
use warnings;
use Benchmark qw(cmpthese timethese);
use IO::Uncompress::Gunzip qw(gunzip);
my $re = qr/test/;
my $bench = timethese($ARGV[1], {
zcat => sub {
if (defined open(my $FILE, "-|", "zc...
I work with Activestate Perl on Windows and Apache.
I want to run my scripts under mod_perl.
To prevent Apache from caching modules during development I want to use Apache::Reload module.
I have added the following lines to httpd.conf
PerlModule Apache::Reload
PerlInitHandler Apache::Reload
PerlModule Apache2::RequestUtil
Then I rest...
Below is a Perl script whose sole purpose is to receive an HTTP request, and spit out "503 Service Unavailable" and a short message. It works fine, except in many cases, the connection resets, which causes the browser to show an error message. This is on Win32. I have no idea what's wrong with it.
#!/usr/local/bin/perl
use strict;
use ...
I've been Googling and Overflowing for a bit and couldn't find anything usable.
I need a script that monitors a public folder and triggers on new file creation and then moves the files to a private location.
I have a samba shared folder /exam/ple/ on unix mapped to X:\ on windows. On certain actions, txt files are written to the share...
I have a plain perl script that can be run from the command-line via perl -w test.pl. I then have a mod_perl2 script that can be accessed from a web browser. I want to have the latter call the former and send the output to the browser, flushing as it goes.
The mp2 script doesn't have a shebang line, because it's mod_perl, so it doesn't ...
How can I print to a variable with Perl?
I've been working on a program for a while which logs its iterative progress in a highly verbose fashion...
print $loghandle $some_message;
However, I'd like to also selectively print some of the messages to a different file. Naturally, I could sprinkle the code with...
print $loghandle $some...
I have an image file name that consists of four parts:
$Directory (the directory where the image exists)
$Name (for a art site, this is the paintings name reference #)
$File (the images file name minus extension)
$Extension (the images extension)
$example 100020003000.png
Which I desire to be broken down accordingly:
$dir=1000 $...
Do you know if Perl's PDF::API2 module can generate documents with both English and Hebrew text? I have searched for a while and cannot seem to find how to handle right-to-left language text.
Eventually I will want to list English in one column and Hebrew in the other. But I would be happy to have the two texts on different lines for ...
I have program output that looks like this (tab delim):
$ ./mycode somefile
0000000000000000000000000000000000 238671
0000000000000000000000000000000001 0
0000000000000000000000000000000002 0
0000000000000000000000000000000003 0
0000000000000000000000000000000010 0
000000000000000000...
I am facing some glitches using the -browsecmd and -listcmd options of Tk::BrowseEntry widget:
I have three BrowseEntry widgets and each uses the value of the previous one as input for populating its own list. The values are used as arguments to a subroutine that pulls out the list of items in the drop-down list from a flat file databa...
I'm trying to use Test::More to unit test Perl functions that print to the screen.
I understand that this output may interfere with tools such as prove.
How can I capture this output so I can print it with diag(), and also run tests on the output itself?
...
Is there a nice simple way to get the amount of columns using perl and mysql? I generate the sql select code so i dont know how many columns are in there. I do have the column section isolated so a regex solution could be simple?
-edit- for the comment below.
"select " . col . " FROM " #more code
col = "a, b, c, d" #how do i find out i...
Which lesser-known CPAN modules have you found to be real gems?
Please post links to the modules like this
[`Example::Module`][Example::Module]
[Example::Module]: http://search.cpan.org/perldoc/Example::Module
Or post a link to the version control repository.
A short description would be good to include, too.
...
Clarification: I'm pretty much a
Perl/CPAN noob, don't assume I know
too much.
I have a pretty vanilla CPAN because I just rebuild my entire Lenny 5.0.2 VPS - so I pretty much have the default modules installed.
My eventual goal is to setup foswiki on my Apache 2.x based server.
So far I'm reading this guide and it says the fi...
I'm asking this question because I finally solved a problem that I have been trying to find a technique for in a number of cases. I think it's pretty neat so I'm doing a Q-and-A on this.
See, if I could use eval, I would just do this:
eval join( "\n"
, map {
my $v = $valcashe{$_};
sprintf( '$Text:...
my admin has given me sudo rights for
cpan
I also need to install a couple of non-CPAN modules (Atlassian Crowd -> svn connector) to the global PERL5LIB.
I vaguely remember that cpan can install from local sources, without pulling modules from the web.
any pointers? can I do it or should I just have him install those modules manua...
I'm new to Perl. How do you install the Net::SFTP module? I'm running Ubuntu Linux. I believe there's a simple way to do it from the command line, like by calling $ cpan install or something.
...
I am trying to remove/delete the second last character of a Tibetan script, as shown below (character in following example are of English):
$char = "ti.be.tan.|";
So I want to remove the "second last" character "." I tried in following way with my few knowledge of RE:
$char =~ s/.|$/|/g;
$char =~ s/[.|]$/|/g;
$char = tr/.|//d; ...