perl

What am I doing wrong with this Inline module test?

UPDATE: appologies for the wrong place I chose to put stuff. I didn't notice those adds @Sinan mentioned at all probably they had been blocked by my browser. Anyway I've deleted the links now. and thank you guys :) In my [previous post][1], @daotoad mentioned an Inline module. Now I'm playing around with it. Well, actually except for Pe...

Edit>copy/paste implementation with perl / tk

I'm using Perl/Tk to build the GUI for an application. I plan on adding an edit menu to it with standard cut, copy, and paste options. Right here is where I realized that I've never actually interacted with the clipboard using perl. Can anyone give me a link to information about messing with clipboard in perl? Is there a perl module for...

Sum two graphs, when the second RRD file is started only now

I don't know how to explain my problem.... but I have two RRD files: a.rrd b.rrd I'm trying to sum both of the files and STACK them up in the graph. like: my $bla = RRDs::graph "-", "--title","Test", "--imgformat=PNG", "--width=680", "--height=200", "DEF:Default0_=a.rrd:default:AVERAGE", "DEF:Real0_=a.rrd:re...

How to install a module for two perl-installations simultaneously?

Supposing I have one perl in /usr/bin (which came along with my os-distribution) and another one (build form the source) in /usr/local/bin – is there a simple way to make a module available to both perl-installations with only one cpan; install module-name? ...

Perl: Access a hashref sorted by value

I'm writing a script that'll read through my ftpd logs and generate a hash as follows: $stats = \{ 'user1' => { 'files' => 281, 'size' => '3724251021' }, 'user2' => { 'files' => 555, 'size' => '738585...

Unexpected result using POSIX ceil() in Perl

I can't for the life of me figure out why the following produces the result it does. use POSIX; my $g = 6.65; my $t = $g * 4; my $r = $t - $g; my $n = $r / $g; my $c = ceil($n); print "$c ($n)\n"; Sigil-tastic, I know — sorry. I've solved this for my app as follows: use POSIX; my $g = 6.65; my $t = $g * 4; my $r = $t - $g; my $n = $...

Separating configuration data and script logic in Perl scripts

I find the following anti-pattern repeated in my Perl scripts: the script contains some machine/setup specific settings which I store in-line as constants in the script whereas the rest of the script is general in nature: #!/usr/bin/perl use strict; use warnings; # machine specific settings at the start of the script. my $SETTING_1 = ...

Why am I getting a syntax error when I pass a coderef to this prototyped Perl subroutine?

This is the code: sub function($&) { my $param1 = shift; my $code = shift; # do something with $param1 and $code } If I try to call it like this: function("whatever") { print "i'm inside the coderef\n"; } I get Not enough arguments for MyPackage::function at x.pl line 5, near ""whatever" { ". How can I call it witho...

Is it worth learning Perl 6?

I have the opportunity to take a two day class on Perl 6 with the Rakudo Compiler. I don't want to start a religious war, but is it worth my time? Is there any reason to believe that Perl 6 will be practical in the real world within the next two years? Does anyone currently use it effectively? Update I took the class and learned a lot...

Perl class variable usage

I am trying to understand how to use instance variable in Perl OO - more specifically in conjunction with external resources. Let me explain: We have a DLL that exposes some functionality that I'd like to expose through a Perl API. I use Win32::OLE to get access to this DLL. So my constructor is simple: package MY_CLASS; use Win32::OLE...

Perl: if ( element in list )

I'm looking for presence of an element in a list. In Python there is an in keyword and I would do something like: if element in list: doTask Is there something equivalent in Perl without having to manually iterate through the entire list? ...

Installing Epic (Eclipse Plugin) in Pulse Explorer

I'm trying to install EPIC using the Pulse Explorer for Eclipse (as I'm rather fond of sharing profiles :). When I go to install the plugin under my account, I get asked for a login into http://e-p-i-c.sf.net. However, the Epic's team documentation doesn't mention anything about a login. Here's what I've done: Gone into Pulse and cre...

Simple Perl string Problem

I know this might be very easy to some,, I have a simple string like this @¨0­+639172523299 (with characters before a mobile number). My question is, how do i remove all the characters before the plus(+)? What i know is to remove a known character as follows: $number =~ tr/://d; (if i want to remove a colon) But here, I want all chara...

Perl - Removing unwanted elements from an arrayref

I'm writing a script that parses the "pure-ftpwho -s" command to get a list of the current transfers. But when a user disconnects from the FTP and reconnects back and resumes a transfer, the file shows up twice. I want to remove the ghosted one with Perl. After parsing, here is what the arrayref looks like (dumped with Data::Dumper) $VA...

Perl DBI Error Msg: Can't call method "selectcol_arrayref" on an undefined value

my $dblinks = ''; $dblinks = $dbh->selectcol_arrayref("select db_link from db_links where ticket=\'LOW\'"); my $success = 0; for my $dblink (@$dblinks) { $success = eval { my ($ret) = $dbh->selectrow_array("select 1 from " . $dbh->quote_identifier($dblink, 'SYSIBM', "SYSDUMMY1") ); $ret; }; if ($success) { &Loggi...

Secure encrypted database design

I have a web based (perl/MySQL) CRM system, and I need a section for HR to add details about disciplinary actions and salary. All this information that we store in the database needs to be encrypted so that we developers can't see it. I was thinking about using AES encryption, but what do I use as the key? If I use the HR Manager's pas...

Perl - How do I escape/encode special characters

I'm writing a script for IRC and sometimes I might need to use a color. Normally I do it this way my $C = chr(3); $C is the control code used for color but I've seen some other script that escapes it something like "\x\v...". How do I get the correct encoded version of that? I tried Data::Dumper but I didn't find it. I hope this quest...

How should I distribute a pre-built perl module, and what version of perl do I build for?

This is probably a multi-part question. Background: we have a native (c++) library that is part of our application and we have managed to use SWIG to generate a perl wrapper for this library. We'd now like to distribute this perl module as part of our application. My first question - how should I distribute this module? Is there a sta...

Perl - access user32.dll using Win32::OLE on 64-bit windows

I am using Perl 64-bit on 64-bit windows. Win32::API does not compile on 64-bit windows and I want to use user32.dll on a 64-bit Windows. Is there any way to use user32.dll using Win32::OLE or something similar? ...

How do I use composite key user ids with Catalyst::Plugin:: Authentication::DBI?

What is the most effective to way to make Catalyst::Plugin::Authentication work if the user uesrid is qualified by a domain (i.e. composite key)? Does it support this functionality? I'm looking specifically at using Catalyst::Plugin::Authentication::DBI but I'm not opposed to forking, patching, recreating it if it doesn't have the curre...