perl

Process optimization for large sets of data

I currently have a project where we are dealing with 30million+ keywords for PPC advertising. We maintain these lists in Oracle. There are times where we need to remove certain keywords from the list. The process includes various match-type policies to determine if the keywords should be removed: EXACT: WHERE keyword = '{term}' CONTAIN...

Modifying PHP files using Perl (possibly using HTML::TreeBuilder)

I am trying to rework many pages across many sites. The pages may contain JavaScript, PHP, or ASP code in addition to HTML. The problem I'm encountering is that the module rewrites things I don't want rewritten. I've managed to handle most of the symbols (e.g., ", >) in HTML tags like script, but they get changed into entities (e.g., &qu...

Perl accessing/changing deep hash by array list

I want to delete an element of a hash(of any depth) which has the first key as $key[0], the second key as $key[1] etc, until @key is finished. For example, if @key=(23,56,78) then i want to manipulate $hash{23}{56}{78}. I don't know beforehand how many elements @key has. I have been trying to use the following: my %the_path; my $temp=...

How could I find files that use certain modules in CPAN?

Some modules on CPAN are excellently documented, others.... not so much, but it's usually easy to discern how to use a module via prior art (e.g modules/tests that used the module you're looking to use). I'm wondering what the best way is to find code that uses the code you're looking to use. example I want to use (maybe?) Dist::Zilla:...

How to sort rows in a text file in Perl?

I have a couple of text files (A.txt and B.txt) which look like this (might have ~10000 rows each) processa,id1=123,id2=5321 processa,id1=432,id2=3721 processa,id1=3,id2=521 processb,id1=9822,id2=521 processa,id1=213,id2=1 processc,id1=822,id2=521 I need to check if every row in file A.txt is present in B.txt as well (B.txt might have...

Writing a test for a Dist::Zilla minting module

It's about time I wrote a functionality test for Dist::Zilla::Plugin::Catalyst. But I realized that I haven't a clue on where to start. I know that I have to have a custom minting profile recognized by my test suite, and that I'm probably going to just test to make sure that all the right files are output with suitable perms. I'm not at ...

Running mysqltuner on Mac OSX

I use Zend Server CE on my Mac running OSX Snow Leopard for my development environment. I need to tune up MySQL and have used mysqltuner.pl in the past on Linux servers to do pre- and post-testing. I downloaded the script and get the following errors when I run it: couldn't find diagnostic data in /System/Library/Perl/5.10.0/pods/pe...

Building 64 bit Perl on Solaris 10: relocation error, value does not fit

I am trying to build 64 bit Perl on Solaris 10: $uname -a SunOS unknown 5.10 Generic_137138-09 i86pc i386 i86pc Current working directory is /local/perl-5.8.8 But it fails with: LD_LIBRARY_PATH=/local/perl-5.8.8:/home/sol64/berkeley-db-4.2.52/lib:/local/gcc-4.1.1-bin/lib/amd64 ./miniperl -Ilib configpm --heavy=lib/Config_hea...

Perl to static executable on linux

I want to create a static executable that will run on a windows machine from a linux machine (ubutu 10.04). Is there anyway of doing so?? thanks, ...

How do I implement my own escape sequence when using split() in perl?

I'm trying to write a parser for the EDI data format, which is just delimited text but where the delimiters are defined at the top of the file. Essentially it's a bunch of splits() based on values I read at the top of my code. The problem is theres also a custom 'escape character' that indicates that I need to ignore the following delim...

How can my previously untainted data become tainted again?

Hi Everyone, I have a bit of a mystery here that I am not quite understanding the root cause of. I am getting an 'Insecure dependency in unlink while running with -T switch' when trying to invoke unlink from a script. That is not the mystery, as I realize that this means Perl is saying I am trying to use tainted data. The mystery is tha...

What is the significance of an underscore in Perl ($_, @_)?

I am new to Perl, and I used them like this $_ foreach (@list) { print "$_\n"; } @_ sub search { my ($no, @list) = @_; } How exactly do these underscore variables work in Perl? What are the other constructs where they are useful? ...

What tools can help build an XS project?

I've recently started learning XS using perlxstut and the tutorial suggests that I create my module using the old h2xs tool to create an ExtUtils::MakeMaker-based project. However for pure Perl projects, h2xs/EUMM has long been disfavoured in favour of Module::Install, Module::Build or Dist::Zilla. Is there a more modern way of creating...

What am I doing wrong in this Perl one-liner?

I have a file that contains a lot of these "/watch?v=VhsnHIUMQGM" and I would like to output the letter code using a perl one-liner. So I try perl -nle 'm/\"\/watch\?v=(.*?)\"/g' filename.txt but it doesn't print anything. What am I doing wrong? ...

How can I install Crypt::SSLeay on a Win 64?

I've got 64-bit Vista with ActiveState Perl "v5.10.0 built for MSWin32-x64-multi-thread" and I'm trying to get the Crypt::SSLeay package installed along with versions of libeay32.dll and ssleay32.dll. I've done this before on a Win32 machine using the 'uwinnipeg' server, but I'm running into issues with my 64-bit system. ppm install ht...

WWW::Mechanize and Cookies

I use WWW::Mechanize::Shell to test stuff. Since I didn't managed to sign in on a web site I want to scrape, I thought I will use the browser cookie (chrome or firefox) for that specific website with the 'cookie' command WWW::Mechanize::Shell has. The question is, Cookies usually stored in a single file, which is not good, how to get a ...

Can I build Perl Script to import into Outlook?

If I have a .bas file on a server is it possible to setup perl script import that file into outlook and build a macro button that connects to it? ...

Explanation of 'global symbol requires explicit package name'

I've been learning Perl and whenever I write a non-trivial script I always get this error message. I always think I have a good understanding of it, but I suppose I don't. Here is a sloppy markov chain example (not tested) with the errors below. The #!/usr/bin/perl -w use strict; sub croak { die "$0: @_: $!\n"; } sub output { my...

Help Setting Up Perl Module Structure

I'm having trouble figuring out how to structure Perl modules in an object oriented way so I can have one parent module with a number of submodules and only the specific submodules that are needed would be loaded by a calling script. For example I want to be able to make method calls like so: use Example::API; my $api = Example::API...

How to handle subroutine redefined errors in Perl

So I have a file that in short has this problem... #!/usr/bin/perl -w package Foo; use strict; use POSIX; ... sub remove { ... } ... and I get a get an error saying the subroutine remove has been redefined. I know the problem, there is a subroutine called remove in POSIX. However, I don't know how to handle it. How is this proble...