perl

How do I use a Perl module from a relative location?

So lets say I have a dir called foo, and in that I have lib and bin. The scripts in bin need to stuff in lib. So naturally I do something like this: #!perl use strict; use warnings; use lib '../lib'; use Foo; # <-- comes from lib But that means I have to be in the bin dir to run the script. Surely there is a better way. What's the...

How do I have mod_perl reload source files on change?

I am using mod_perl for web development. I do not want to restart mod_perl every time I modify a Perl module. I came across solution about Apache::Reload. I install this module from CPAN, modify httpd.conf accordingly & add "use Apache::Reload" at my perl module, as stated in documentation. I tried the reload all module method, & r...

Perl Script Configuration and Relative Path Implementation on both Windows (XP) / Unix (Solaris)

Heylo, I'm experiencing, somewhat of, a conundrum regarding perl script development. I have written a small Perl script using the standard (basic) Perl installation. I have the following setup: C:\MyScript\perl.pl C:\MyScript\configuration\config.ini C:\MyScript\output\output.txt This is the perl.pl source: $config = '/configu...

How can you get the metadata of an image by the Perl module?

I installed the following component by MacPorts: p5-image-info @1.16 (perl, graphics) Extract meta information from image files It says in its website that you can use it by Usage is something like this: use Image::Info qw(image_info); @info = image_info("filename"); $refto_hash_describing_1st_image = $info[0]; $reft...

Perl - How to access and array element that's held within another array

Heylo again, I've been trying to make my program somewhat easier to maintain. I have an array which I declare: my @pizza = ($p1 = "Pizza One", $p2 = "Pizza Two" ); I then go ahead and put this @Pizza array in another array, like so: my @food = (\@pizza); When I attempt to access either $p1 or $p2 via the @food property I get a val...

How can I match /foo but not /foo/ in Perl's Catalyst?

I want to match /foo, but not /foo/ (where foo can be any string) or / I tried a lot of things along these lines: sub match :Path :Regex('^[a-z]+$') sub match :Regex('^[a-z]+$') sub match :Path :Args(1) But I cannot achieve what I need. I don't believe the problem is with my regex, but because I want to handle a path without an argu...

How do I disable autovivification in Perl?

Suppose you have a HUGE application "develoopped" ;) by a big team. Here is a simplified model of the potential disaster that may occur when somebody checks too deep in a data structure. If not possible to disable autovification completely or in scope, how to work around this? Thank you very much :) !!!! use strict; use warnings;use Dat...

Is there a non-relational equivalent of DBI in Perl?

The Perl DBI module lets me connect to many different types of SQL database transparently. Is there an equivalent Perl module for non-relational key-value pair databases? For example, an interface that might let me start developing with a BerkeleyDB (or even just a Perl hash?) but switch to something like memcachedb or CouchDB or even ...

Why doesn't my Perl CGI script compile after I upgrade Perl?

After upgrading Perl, I receive some errors in a Perl CGI script: Unquoted string "type" may clash with future reserved word at convertit.cgi line 183. Can't modify constant item in scalar assignment at convertit.cgi line 183, near ""text/javascript\">flashPreloadFinish ('http://www.myurl.com/mysite.html');\n";" convertit.cgi...

How do I localise variables in another package when I only know their names at runtime?

I need to localise some variables in another package, but I won't know what their names are until they are passed in. My attempts to use local with typeglobs didn't work, so I have fallen back to saving the value of the variable and restoring it manually. Is there a better way? Note, the error checking to see if a variable exists befo...

Remove lines from file

Hey Guys, I am doing some text processing on a unix system. I have access to the command line on this machine and it has Python, Perl and the default text processing progams installed, awk etc. I have a text file that looks like below: 2029754527851451717 2029754527851451717 2029754527851451717 2029754527851451717 202975452785145...

How to go about learning perl

I am a bioinformatics student and am in the process of learning perl. I don't have a strong programming background but would like for that to change. Right now I am in the process of reading/following and coding from this book I want to know is this the best way to go about learning perl? Should I be experimenting with regular expr...

Which Google API search module for Perl should I use?

Which Google API search module for Perl do you recommend? REST::Google::Search or Google::Search Ease of use is important because I only really need to get the top two, maybe three results from the web search. Also, is there a module that one knows of for getting things from wikipedia? Again easy of use is important. ...

How can I atomically replace a file on a webserver so it's latest version is continually available?

I'm working on a project that generates Google Earth KML files and saves the file to a web-accessible directory. It's running on Windows with ActivePerl. (not my preferred platform but it's what I must work with.) The method I'm using for this is: write to temp.kml, use File::Copy to copy temp.kml to real.kml. This occurs once a seco...

How do I search for a string in file with different headings?

I am using perl to search for a specific strings in a file with different sequences listed under different headings. I am able to write script when there is one sequence present i.e one heading but am not able to extrapolate it. suppose I am reqd to search for some string "FSFSD" in a given file then eg: can't search if file has followi...

What's the best way to manipulate and store huge ordered lists or hashes?

I have a a simple ordered list that could contain 1 million or more items. There are only a few actions that are done with this list: lookup in a value exist find the index for a value find value for index add a value get number of items in the list Once a value is added to the list, it never changes. I append items to the list, no i...

How can I use subversion to deploy web applications?

We are a small team of 4 developers working on a web application. We use trac+svn on a shared server for version control and ticketing and we are happy and satisfied with this. The same shared server also hosts our web application. The application itself is a Perl CGI application that uses CGI::Application and a moderate number of standa...

How can I remove linebreaks with a Perl regex?

when I run: perl -e '$x="abc\nxyz\n123"; $x =~ s/\n.*/... multiline.../; printf("str %s\n", $x);' I expect result to be: str abc... multiline... instead I get str abc... multiline... 123 Where am I going wrong? ...

How can I handle Russian text in Perl?

Hi, I'm new to doing anything with any language that isn't english. So far the only I've ever done with programming is take input in the basic english letters + numbers and output it. Now I have to manipulate some text in Russian (especially from the Russian wikipedia page) but I have no clue where to start. I google and google but all I...

Is there a Catalyst tutorial that uses HTML::Template instead of TT?

I've been looking through a couple of Catalyst tutorials and they all tend to use Template Toolkit instead of HTML::Template. I've spent a lot of time with HTML::Template and I like it, and while I can see the power of TT, I don't know it, and I feel like I'd be learning two things at once; plus, because it does its processing in-templa...