perl

File locking with Fcntl: Baffling bug involving 'use' and 'require'.

The following Perl script outputs "SUCCESS" as you'd expect: use Fcntl qw(:DEFAULT :flock); sysopen(LF, "test.txt", O_RDONLY | O_CREAT) or die "SYSOPEN FAIL: $!"; if(flock(LF, LOCK_EX)) { print "SUCCESS.\n"; } else { print "FAIL: $!\n"; } But now, replace that first line with require "testlib.pl"; where testlib.pl contains use Fcn...

Is there a Perl alternative to YSlow?

I'd like to have a tool in Perl to gather useful statistics for page loads (eg, download time/speed, CDN information, headers, dns lookups, compressions) Does anyone know if one exists or if there's a place to learn about how to make one? ...

Parse last imap login time from /var/log/mail.log

I've currently got a bash script that parses /var/log/mail.log to determine the last login time/date of a imap user. I've determined Perl is going to be a lot more efficient and quicker for this task, especially as the logs grow. Given the following example /var/log/mail.log file: Jul 5 06:57:54 mail-04 dovecot: imap-login: Login: use...

strip HTML Tags with perl

Whats the easiest way to strip the HTML tags in perl. I am using a regular expression to parse HTML from a URL which works great but how can I strip the HTML tags off? Here is how I am pulling my HTML #!/usr/bin/perl -w use strict; use warnings; use LWP::Simple; my $now_string = localtime; my $html = get("http://www.spc.noaa.gov/clim...

%EXPORT_TAGS problem

I have a module something like this, in "lib", called Fool.pm, which is based on the source code of CGI.pm (since that was the first module I thought of when I was thinking about exporting tags): package Fool; require Exporter; @ISA = qw(Exporter); @EXPORT_OK = qw/raspberry/; %EXPORT_TAGS = ( ':all' => \@EXPORT_OK, ); 1; and a tes...

Loadable object for Sub::Name

I am trying to use wkhtmltopdf to generate pdfs. I've got a perl script that does the job in Windows. I'm now trying to move it to my production linux box (shared hosting). I can create a pdf on the linux box with wkhtmlpdf but am having issues with the perl script. I'm now getting an error "Can't locate loadable object for module Sub::N...

Telnet connection and problem while sending input to the server

I have written the server program using the select. Then I have connect the client using telnet. The connection also completed successfully. If I have the input length as 6 character including newline, in the server side it display the length as 7 character. How it is possible. Anyone help me urgent? ...

What does "Error: Illegal declaration of subroutine" signify?

I got an error from my Perl module "Error: Illegal declaration of subroutine". What does that mean? I tried googling for it and got the following unhelpful information: There is a new compilation error, Illegal declaration of subroutine, for an obscure case of syntax errors. The code which caused the error is like this (trunca...

perl CGI radio_group: populate values from DB query

Im trying to dynmically generate a table that has a radio button per row whose value is set to the ID field of a SQL table. Im not sure how I can reference this value using CGI radio_group. In my research radio_group uses an associate array, however if I convert the SQL query to an associative array the values wont match up since there ...

Bad file descriptor with XMLRPC::Lite in Perl

I have a call to an XMLRPC implemented in Java which I have verified that runs without exceptions and writes the output. The call in Perl goes like this: my $result = XMLRPC::Lite -> proxy($url) -> call("someMethod", SOAP::Data->type(string => $par1), SOAP::Data->type(string => $par2), ...

Perl video output

What's the best way of making a video as an output of a Perl program? ...

Log4Perl bundling logging from several programs into one log

Is there any Logger on CPAN which allows me to bundle logs from several programs into one file with synchronising parallel logging when two programs run the same time and call log4Perl in parallel. Background is that I use a custom appender which writes Emails and I would like to bundle all emails in a single file as a backup in case the...

Reusing ?'s on a DBI prepare

Is there a way to reuse the ?'s used on a DBI prepare statement. Consider the following code: $sth=$dbh->prepare("INSERT INTO mytable(a,b,c) SELECT ?,B(?),C(?)"); $sth->execute($a,$a,$a); It would be very nice to instead use something like this: #I'm making this up as something I hope exists $sth=$dbh->prepare("INSERT INTO mytable...

Malformed UTF-8 character error in regular expression in Perl

I have 'Malformed UTF-8 character' error when I'm putting some scalar data in XML::Simple or Data::Dumper. There are regular expressions on the lines where the error occurs. Malformed UTF-8 character (fatal) at /usr/share/perl5/XML/Simple.pm line 1690. Malformed UTF-8 character (fatal) at /usr/lib/perl/5.10/Data/Dumper.pm line 682. At...

What's the best way to organize data on my tiny embedded system?

I haven't done much programming for Embedded Systems before, and now I have to create some scripts for something relatively tiny (<60MB RAM, almost all of which is already used by other more critical processes, the processor is less ~ 500MHz). I can't run something that is on all the time, so Firebird is out. I suggested sqllite, but peo...

How do I adjust cperl mode indentation of qw//?

Following on from this question, here's another bugbear. I am getting my @browsers = qw/ Firefox MSIE /; but I want my @browsers = qw/ Firefox MSIE /; What setting in cperl mode in Emacs might I use to achieve that? ...

How to get the running Perl script's path and name (argv[0] in C)

In C / C++ (bash, too?) the first command-line argument, argv[0], is the binary filename (prefixed by an absolute or relative path as invoked by the user). In Perl the first command-line argument $ARGV[0] is the first command-line argument after the path and name of the script. How can a Perl script get the path and name that was used ...

error /usr/local/bin/perl: Argument list too long

Hello guys ive executed this command to delete malwarm from all my websites files and keep backup from each files but after 1 mint from executing got error /usr/local/bin/perl: Argument list too long Can anyone suggest a way to avoid this error , PS ive a huge a mount of files :) perl -e "s/<script.*PaBUTyjaZYg.*script>//g;" -pi.sa...

How to monitor the progress of FTP transfer through perl code?

We have written an utility to automate file transfer through FTP service using Perl. We want to know how we can track the progress of upload? ...

what module do you recommend for xmlrpc in Perl in cgi script?

Hi, I am looking for a module in Perl that I can use to respond on remote procedure call in a serverside script. Which is the best in terms of quality and easy of use? Thank you. From other source, I found RPC::Any::Server::XMLRPC::CGI. (RPC::Any) ...