perl

Setting up a Many-to-Many relation of a table with itself with DBIx::Class

I am porting an application from Class::DBI to DBIx::Class and need help. I have a table T with a primary key tid and another table ChildT that relates a row of T to multiple (child) rows of T itself. How can I setup the relations between T and ChildT so that I can find all children of an instance of T. Here are the stripped down version...

Finding Nodes With Only Incoming Edges and Only Outgoing Edges in a Graph Via Perl

I have the following graph my %connections=(36=>[31,22],31=>[30],30=>[20],22=>[20,8],20=>[1],8=>[5],5=>[2],2=>[1,20]); Is there any existing algorithm that let us find node with only outgoing edges and only incoming edges. Hence given the above graph, it would yield: $node_only_incoming_edge = [36]; $node_only_outgoing_edge = [1]; ...

Perl - capture system() error

I am converting some jpg images to png w/ imagemagick & have the following in perl: system("convert $jpg $png"); print "$?\n"; Is there a way to capture the actual errors from imagemagick (rather than just whether or not it executed successfully as I have in the code above)? note: I use imagemagick solely as an example....this is mor...

How should I compare Perl references?

I want to check if two references point to the same object. It seems I can simply use if ($ref1 == $ref2) { # cheap numeric compare of references print "refs 1 and 2 refer to the same thing\n"; } as mentioned in perlref, but I vaguely remember seeing the use of some function for the same purpose. Is there any reason I shouldn't u...

Moose::Role - easy way to augment application of the role?

I have a Moose::Role that I would like to call some extra subs on the class when that role is applied to the class. Is there an easy way to modify what happens when the role is applied, without having to dig too much into Moose::Meta::Role type coding? Ideally, I'd just like to after 'apply' => ... to add the extra stuff. Edit: I'm s...

Why do I have to explicitly add perl before the script for getops to run properly?

When i run my script like so: C:\>perl script.pl -f file It works fine. But, if I just do: C:\>script.pl -f file then I don't get any errors but getopts doesn't assign anything to $opt_f This works just fine on perl 5.8 Windows XP, but it doesn't work on perl 5.12 on Windows 7. There aren't any other versions of perl installed (its...

perl removing stop words from a big file

Hello everyone, I have a billion word corpus which I have collected in a scalar. I have a .regex file that contains all the stop words that I want to eliminate from my data (text). I dont know how to use this .regex file so I have made an array and stored all the stop words of the .regex file in my stop word array. To remove the stop...

Async queries with DBD::Pg fail with: Cannot execute until previous async query has finished

Hello, I'm using CentOS 5.5 Linux (same as Redhat 5.5) with stock perl v5.8.8 and have installed DBD-Pg-2.17.1 via CPAN shell and I'm using postgresql-server-8.4.5-1PGDG.rhel5 and friends. I have prepared a simple test case demonstrating my problem - it is listed at the bottom. My code works ok, when I remove {pg_async => PG_ASYNC} M...