perl

How do I recursively set read-only permission using Perl?

I would like $dir and everything underneath it to be read only. How can I set this using Perl? ...

How can I make Eclipse work with `perlbrew`?

I'm using perlbrew to switch between perl versions. I also use Eclipse to write perl scripts. It seems that Eclipse does not recognize the switches between perl versions, and keeps working with the base version installed out of perlbrew. I tried restarting Eclipse but this doen't help. So, How can I make Eclipse work with perlbrew? ...

How do I check if a Perl scalar variable has been initialized?

Is this the best way to check a scalar variable is initialized in Perl using defined? my $var; if (cond) { $var = "string1"; } # Is this the correct way? if (defined $var) { ... } ...

How do I stop Apache from inserting unwanted line breaks in its error log?

My Perl/FastCGI app makes extensive use of "print STDERR" to log all sorts of debugging info to the Apache error log file. I insert frequent line breaks myself, but Apache (or perhaps FastCGI?) still feels the need to insert extra line breaks, usually right in the middle of my nicely formatted output. How can I stop this from happening...

Is there something like `<?php phpinfo(); ?>` in Perl?

Is there something like <?php phpinfo(); ?> in Perl? ...

How do I pass an anonymous subroutines when calling a Perl subroutine?

mysub gets a subroutine reference as its first argument. Can I simply call mysub(sub{some subroutine body here}) ? I.e. define an anonymous subroutine right at the call? Is the syntax OK (is it really a reference to sub that is passed)? ...

How can I make Perl die when reading, but not writing, to non-existing keys in deep hash?

I'm using dynamic multilevel hashes from which I read data but also writes data. A common pitfall for me is accessing non-existing keys (typos, db revisions etc.). I get undefs which propagate to other parts and cause problems. I would like to die whenever I try to read a non-existing key, but still be allowed to add new keys. So the w...

Why does Perl's Math::Combinatorics complain "must use next_permutation of 'frequency' argument not passed to constructor"?

I'm trying to generate unique permutations of an array using Math::Combinatorics. As CPAN page says it can be done using next_string(): use Math::Combinatorics; my @arr = [1,1,1,0,0]; $c = Math::Combinatorics->new( count=>5, data=>[\@arr], frequency=>[3,2] ); while (@permu = $c->next_string()){ print "@permu\n"; } However this cod...

How can I treat many log files as one virtual file in Perl?

I've got multiple access logs in the logs directory, following the naming convention below: access.log.1284642120 access.log.1284687600 access.log.1284843260 Basically, the logs are "rotated" by Apache per day, so they can be sorted in order. I am trying to "read them one after another", so that they can be treated as one log file. ...

How can I remove all font tags that have nothing but whitespace in them, using Perl?

I'm trying to do a match in Perl, using the following regex: s/<font(.*?)>[\t\f ]*<\/font>//gi; What I want it to do is to remove all font tags that don't have anything inside. Unfortunately, it doesn't stop after <font at the first > it will go until the > from before </font>. Any pointers on what is wrong with the regex? my $text...

How can I completely uninstall perlbrew?

I'm lovin' it, but I suspect it causes some problem. I know I can use perlbrew off but I would like to completely remove it. How do I do that? ...

Why won't Eclipse recognize $PERL5LIB?

I followed BioPerl manual: I cloned a fresh copy of bioperl-live under ~/src then added the following line to my ~/.profile (I'm using Ubuntu): export PERL5LIB="$HOME/src/bioperl-live:$PERL5LIB" However,BioPerl modules are not recognized in Eclipse, e.g.: Can't locate Bio/Tools/GFF.pm in @INC (@INC contains: /home/dave/workspace/.m...

How do I solve this BioPerl-related mystery?

I'm using Ubuntu 10.04 and Perl 5.10.1. The BioPerl package has some nice scripts, such as bp_genbank2gff3.pl which converts files from genbank format to GFF3 format. The problem: I get unexpected results when using bp_genbank2gff3.pl: the gene features get "Name=" instead of "locus_tag=" in the last GFF3 column. A dear BioPerl mailing...

How can I searching for different variants of bioinformatics motifs in string, using Perl?

I have a program output with one tandem repeat in different variants. Is it possible to search (in a string) for the motif and to tell the program to find all variants with maximum "3" mismatches/insertions/deletions? ...

How can I install `Thread::Pool` from CPAN?

I'm using cpanm to install Perl modules, but I can't install Thread::Pool for some reason: $ sudo cpanm Thread::Pool fails and the log file says: cpanm (App::cpanminus) 1.0012 on perl 5.010001 built for i486-linux-gnu-thread-multi Work directory is /home/dave/.cpanm/work/1284831891.13606 You have make /usr/bin/make You have LWP 5.834...

How do I use Perl's Google::Search to look for specific URLs?

The Google::Search module, which is based on the AJAX Search API, doesn't seems to work very well, or it is just me? For example, I use firefox to search google for: http://bloggingheads.tv/forum/member.php?u=12129 It brings results. But when I use the module this way: $google_search = Google::Search->Web ( q => "http://bloggingheads...

How do I get the average weather for any given zipcode in Perl?

Is there a Perl module to get the avg. temperature for any given zipcode? For instance, Wikipedia has the Avg. high, avg. low & daily mean temperature for Los Angeles. I'd like to do this in Perl somehow but can't find a module to do this (e.g. type in 10001 and get the avg. temp. for New York). ...

How do I use Perl's `Thread::Pool::Simple`?

I'm using Thread::Pool::Simple for multi-threading. I have a couple of questions which are quite general to multi-threading, I guess: Each of my threads might die if something unexpected hapens. This is totally accepted by me, since it means some of my assertion are wrong and I need to redesign the code. Currently, when any thread dies ...

How can I change the current directory in a thread-safe manner in Perl?

I'm using Thread::Pool::Simple to create a few working threads. Each working thread does some stuff, including a call to chdir followed by an execution of an external Perl script (from the jbrowse genome browser, if it matters). I use capturex to call the external script and die on its failure. I discovered that when I use more then one...

How do I check if a page is Google cached in Perl?

I tried lots of modules, seems like nothing works well. Do you have any idea how to check if a page I supply, for example: http://bloggingheads.tv/forum/member.php?u=12129 Is available on google cache? I'm using Perl. ...