perl

How can I use Unicode characters when I write to Perl's format?

Basically I have a database where I get $lastname, $firstname, $rid, $since, $times and $ip from. Using a Perl script, I format the data to send it via e-mail. Since the $lastname and $firstname can contain special chars (for instance ä, ü, ß, é,...) I first decode the strings. my $fullname = decode("utf8", $lastname) . ', ' . decode("...

Why does $dbh->do('VACUUM') fail with Perl's DBD::SQLite?

I want to do VACUUM at a certain time on a SQLite database under Perl, but it always says DBD::SQLite::db do failed: cannot VACUUM from within a transaction So how do I do this? my %attr = ( RaiseError => 0, PrintError => 1, AutoCommit => 0 ); my $dbh = DBI->connect('dbi:SQLite:dbname='.$file'','',\%attr) or die $DBI::errstr;...

Safe Concurrent Write to a File Shared Between a Perl and a PHP script

A Perl script (which I do not control) appends lines to the end of a text file periodically. I need my PHP script (which will run as a cron job) to read the lines from that file, process them, and then remove them from the file. But, it seems like the only way to remove a line from a file with PHP is to read the file into a variable, re...

Why can't I call methods on my Mail::Sender object?

I have this simple part of the program that should send an email to a specified user. But it has an error that says "Can't call method "MailMsg" on an undefined value" if ($sender->MailMsg({smtp => 'mail.myISP.com', from => 'suezy.ourdomainhere.com', to =>'[email protected]', subject => 'this is a test', msg => "testing...

How do I find all modules used in a Perl script and install them?

I have been given a few Perl scripts to deploy. What is the easiest way to find and install all modules used by these scripts? EDIT: From what I can find there are no conditional includes or includes in evals. ...

Perl Net::OAuth problem

I'm trying to use the Net::OAuth module to authorise with the Yammer API and I have the following code snippet, pretty much taken from the Synopsis on CPAN. $Net::OAuth::PROTOCOL_VERSION = Net::OAuth::PROTOCOL_VERSION_1_0A; my $q = new CGI; my $request = Net::OAuth->request("request token")->from_hash($q->Vars, request_...

How can I display the execution status of the command "ssh-copy-id" from Perl?

I have a Perl script which does this: It generates a ssh authentication key on my system and then copies this key to a remote Linux system for passwordless ssh connects. The code is as below: # Generate an rsa key and store it in the given file system("ssh-keygen -t rsa -N '' -f /root/.ssh/id_rsa 1>/dev/null"); # Copy the generated ke...

How do I create an XML template in Perl?

The XML file I need to create is like <file> <state>$state</state> <timestamp>$time</timestamp> <location>$location</location> .... </file> I don't want to use several print to create the needed XML file, what I'm expecting is to have a template, which defines both the structure and format of the XML. Then w...

How can I UPDATE rows returned by a SELECT in a loop?

I have a loop on the rows returned by an SQL SELECT statement, and, after some processing on a row's data, I sometimes want to UPDATE the row's value. The processing in the loop's body is non-trivial, and I can't write it in SQL. When I try to execute the UPDATE for the selected row I get an error (under Perl's DBD::SQLite::st execute ...

How can I solve "world writable" issues with modules uploaded to PAUSE (CPAN) from Win32?

Does anyone one know how not to get the "world writables" fail message from PAUSE when I upload a module to PAUSE? I packed it with make dist on Windows. I haven't got access to a Linux box at work and I need to work it out on Windows. ...

How do I configure WWW::Mechanize to work through a proxy?

I sit behind a proxy and have HTTP and WWW::Mechanize working OK locally. But advice || pointers as to how to get through a proxy please. Regards Ian ...

How can I canonicalize Windows file paths in Perl?

Update: I can make this a simpler problem to solve: I want to figure out what the correct regex would be to substitute any single occurrence of a back slash with two back slashes. I want to turn this: vlc.plugin.path = C:\Program Files\JekyllV0.9.2\\VLC_1.0.0\\plugins into: vlc.plugin.path = C:\\Program Files\\JekyllV0.9.2\\VLC_1....

How can I combine a positive and negative condition in a regex?

I fairly new to regular expressions and need some help. I need to filter some lines using regex in Perl. I am going to pass the regex to another function so it needs to be done in a single line. I want to select only lines that contain "too long"and that don't begin with "SKIPPING" Here are my test strings: SKIPPING this bond sinc...

Why can't webmin can't open files in directories that are not world executable?

I'm using an open source Perl package named "webmin" on several servers. It's mostly Perl on the inside. I found a weird behavior on a new 64-bit server: files were getting created empty. I've traced it down to a "Permission Denied" error in Perl's builtin function open which is pretty unusual, since the application is running as root....

How can I suppress output to stdout and stderr in Log4perl?

I have this sub to initialize my logger: sub initLogfiles{ Log::Log4perl->easy_init($INFO); # We log all debug, info, warn, error and fatal messages. my $userlogappender = Log::Log4perl::Appender->new( "Log::Log4perl::Appender::File", filename => USERLOGFILE, mode => "append", recreate => ...

How can I pass a function to a Perl sub?

How would I write a function that accepts something like the map function does? Example: $func = sub { print $_[0], "hi\n" }; &something($f); sub something { my $func = shift; for ($i = 0; $i < 5; $i++) { $func->($i); } } works fine. but then if I did &something( { print $_[0], "hi\n" } ); it wont work and says ...

Why does my jqGrid script work fine with PHP but fail with Perl?

Here is client Side code: jQuery(document).ready(function(){ jQuery("#list").jqGrid({ url:'example.php', datatype: 'xml', mtype: 'GET', colNames:['Inv No','Date', 'Amount','Tax','Total','Notes'], colModel :[ {name:'invid', index:'invid', width:55}, {name:'invdate', index:'invdate', width:90}, {...

What is the most cross-platform way to execute a Perl script from Ant?

What is the most cross platform way to execute a pPerl script from ant? Windows does not like the Perl script as the executable. Is there any way other than just running Perl using an OS specific executable and passing the Perl script in as an argument? ...

How are nested capturing groups numbered in regular expressions?

Is there a defined behavior for how regular expressions should handle the capturing behavior of nested parentheses? More specifically, can you reasonably expect that different engines will capture the outer parentheses in the first position, and nested parentheses in subsequent positions? Consider the following PHP code (using PCRE reg...

How can I insert a variables name from a string in Perl?

I am trying to insert a variable $font1 below. The variable $font1 is the name of the font e.g. arial. I really want it to return $arial (or whatever $font is) as a variable. When $arial is called, it gets the arial.ttf from a folder on my server via get_fonts.pl. I have tried everything \$$font '"$font"' and every possible variation ...