perl

How to copy all properties of a class to a new subclass in Perl ?

my $t=TT::Pop->new(name => "shadowfax", color => "white"); my $w=TT::Pop::Subs->new($t); How to write TT::Pop::Subs::new() so that I can make $w cantains all the properties from $t ? In other words, I want to initialize a class with its super class. In this case, all properties from $t should be readonly, so copy by ref is acceptable....

Quickest language to make a little 'Connect to a SSL webpage' script

Hi! I just need some advice. I already know how to play with bash, ruby, python and perl and I'd like to know: with which of them would it be faster to make a little script that would connect to a website with SSL and login. I just need to do this script and make a cron job with it. So it must be executable from the console. Thanks. ...

Perl - Too many files error when using DBD Oracle

Can someone advise on why I get errors opening the file in the code below. The errors start about half way through the 9th iteration of 25 threads, and are "Too many open files" errors. The error only happens when running in threads, and only when the DBI connect/disconnect are used. This shouldn't affect the open file count at all shou...

How do I get a reference to a function from within the function?

Possible Duplicate: In Perl, how can a subroutine get a coderef that points to itself? Is there a way to get a reference to a function from within that function without using the name? I've recently found myself repeatedly writing code that smells of an anti-pattern. Data::Dump supports filters but (as of version 1.16) they a...

htaccess correct?

Although I can run test.cgi fine but my perl all doesn't work, is this htaccess correct: AddHandler cgi-script .cgi Options +ExecCGI IndexIgnore * DirectoryIndex myapp.cgi RewriteEngine on RewriteRule ^$ myapp.cgi [L] RewriteRule ^/$ myapp.cgi [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ...

How to run concurrent threads in perl?

The following does not appear to run in concurrent threads as I expected, but rather each process blocks until it is complete: my @arr = (1,2,3,4); foreach (@arr) { threads->new(\&doSomething, $_)->join; } sub doSomething { my $thread = shift; print "thread $thread\n"; sleep(5); } In other words, it appears to be execu...

What does " ~~ " mean in Perl?

In an SO answer daxim states: @array ~~ $scalar is true when $scalar is in @array to which draegtun replies: From 5.10.1+ the order of ~~ is important. Thus it needs to be $scalar ~~ @array How about a small primer on ~~ with link(s) to source(s) including the following specific questions: What is ~~? What is ~~ called? Wh...

What is the easiest method to compare large amounts of similar text?

Hi all, somewhat open ended question here as I am mostly looking for opinions. I am grabbing some data from craigslist for apt ads in my area since I am looking to move. My goal is to be able to compare items to see when something is a duplicate so that I don't spend all day looking at the same 3 ads. The problem is that they change t...

perl fork doesn't work properly when run remotely (via ssh)

I have a perl script, script.pl which, when run, does a fork, the parent process outputs its pid to a file then exits while the child process outputs something to STOUT and then goes into a while loop. $pid = fork(); if ( ! defined $pid ) { die "Failed to fork."; } #Parent process elsif($pid) { if(!open (PID, ">>running_PIDs")...

call matlab in an ssh command from a perl script

Hi i have set up passwordless ssh set up and have perl call ssh -o "BatchMode yes" user@host "runMe.pl arg1 arg2" runMe.pl calls matlab and the function run_online with the given args. nohup matlab -nojvm -nodisplay -r "run_online('$imgfolder/$folder/', '$ARGV[0]$folder', '/homes/rbise/results/mitosis/$ARGV[0]/$folder/')" > out.txt < ...

How to handle SQL query result caching

In a Perl program I cache SQL request result to speed up the program. I see two common way to do that: Create a hash using the query as index to cache result, like suggested here Create a hash with but 2 index, first is the list of used table, second is where clause I today used the 2nd option because it's easier to clean the cache ...

What are the good certifications for Perl developers?

Just want to know, is there any good Perl programming certifications (Perl 5) available which also covers object oriented Perl. ...

Call a java class from perl

Hi folks, I would like to call a java class from perl. I usually use the java class from command line to do some processing like java com.something.some and now, I need to call it from inside a perl script. Could you let me know how I can do it? Thanks,J ...

Basic permission in Bugzilla to separate clients

I'm trying to configure a Bugzilla instance, which will allow my clients to login, and file bugs for their website under development/maintenance. For e.g: I have created 2 products called "TestProject", "TestProject2" and a user called "TestClient". What I'm trying to achieve is when TestClient logs in, he can only see TestProject, Test...

Can a subclass of wx::StaticBoxSizer handle events?

I'm trying to add an event-handler to a subclass of Wx::StaticBoxSizer, but I'm getting the following error: Can't locate object method "Connect" via package "Wx::StaticBoxSizer" at C:/strawberry/perl/site/lib/Wx/Event.pm line 38. Does that mean that Wx::StaticBoxSizer can't handle events? If so, is there another way to structure ...

How many substitutions took place in a Perl s///g?

Well, the title says it all. Small example: perl -e '$s="aaabbcc";$c=()=$s=~/a/g;print"$c\n$s\n"' (m//g) outputs 3 aaabbcc whereas perl -e '$s="aaabbcc";$c=()=$s=~s/a/x/g;print"$c\n$s\n"' (s///g) outputs 1 xxxbbcc I'd like to do both things at once without having to match first: substitute and know the number of substitutions. Obv...

Performance with Perl Strings

I've been running across a lot of Perl code that breaks long strings up this way: my $string = "Hi, I am a very long and chatty string that just won't"; $string .= " quit. I'm going to keep going, and going, and going,"; $string .= " kind of like the Energizer bunny. What are you going to"; $string .= " do about it?"; From my backgr...

Why does it take so long to print "\n" in Perl?

Why does it take so long to print a newline? Is this just my machine, or do others see the same effect? With the newline: #!/usr/bin/perl use strict; use Benchmark; timethis(100000,'main();'); sub main { print "you are the bomb. \n"; } # outputs: # timethis 100000: 8 wallclock secs ( 0.15 usr + 0.45 sys =...

Where can I find a good book on writing curses applications with perl?

I have been in search of a good way to write curses apps. So far I have found Curses::UI and Curses::Toolkit, but none of them are as maleable as I want them to be. Now I'm looking to write my app with just Curses itself, and learn something about it in the process! Are there any good books/tutorials/etc. that would teach me the guts ...

Perl Move Files

I'm using this code for moving files from directories but I need 2 changes to make and would appreciate some help. I want "return unless" the found directory /^_temp\z/s contains cue && toc && accurip && flac files. If one of these extensions is missing go to next directory. And if this condition is true - move files from DIR, '.' dire...