perl

How do I access List template of C++ program from Perl using SWIG?

I want to access a template List of C++ program from a Perl script and use those values. Example code: typedef list < Struct1 * > sturct1_list; struct Struct2 { int i; struct1_list List1; } struct Struct1 { int j; } I used one swig generated api and did the following: $myList = Struct2_struct1List_get print "Referenc...

How can I extract substrings from a string in Perl?

Hi, Consider the following strings: 1) Scheme ID: abc-456-hu5t10 (High priority) * 2) Scheme ID: frt-78f-hj542w (Balanced) 3) Scheme ID: 23f-f974-nm54w (super formula run) * and so on in the above format - the parts in bold are changes across the strings. ==> Imagine I've many strings of format Shown above. I want to pick 3 su...

How do I create a CSV file using Perl?

Hi, I want to create a CSV file using Perl and write some data to it. Is there any way to do that? Thank You ...

Why is my .zip file corrupted after an HTTP file upload?

I'm trying to use a CGI script to accept and save a file from a program that is using an HTTP POST to send a zip file. In the MIME section of the HTTP header it looks something like this: Content-Disposition: form-data; name="el_upload_file_0"; filename="BugReport.zip";\r\n Content-Type: application/octet-stream\r\n\r\n In my CGI cod...

Perl recursion techniques?

I need a bit of help with is this code. I know the sections that should be recursive, or at least I think I do but am not sure how to implement it. I am trying to implement a path finding program from an alignment matrix that will find multiple routes back to the zero value. For example if you excute my code and insert CGCA as the first ...

Anonymous methods/functions: a fundamental feature or a violation of OO principles?

Is the recent movement towards anonymous methods/functions by mainstream languages like perl and C# something important, or a weird feature that violates OO principles? Are recent libraries like the most recent version of Intel's Thread Building Blocks and Microsofts PPL and Linq that depend on such things a good thing, or not? Are lan...

How can I process a multi line string one line at a time in perl with use strict in place?

I'm trying to figure out the proper PBP approved way to process a multi line string one line at a time. Many Perl coders suggest treating the multi line string as a filehandle, which works fine unless you have "use strict" in your script. Then you get a warning from the compiler about not being able to use a string as a symbol while st...

How can my Perl script know it is running under Win64?

How can I have my Perl script detect it's running on a 64-bit Windows machine, even if it's a 32-bit perl? ...

How can I configure a Catalyst application for different servers?

I am planning a Catalyst application, that will be deployed over a number of servers. It will be used internally by support staff to control aspects of an operational system that runs on those servers. The application will run much in the same way on each server, save for a limited amount of site specific behaviours. Some actions will o...

How can I get content using XML::Twig?

My aim is that start_tag_handler (see below) get the apps/title content when it finds an apps/title tag (see sample XML below). And end_tag_handler gets the apps/logs content when it finds an apps/logs tag. But instead this code returns null and exits. This is the Perl code for parsing (using XML::Twig)###: #!/usr/local/bin/perl ...

Is there a line length limit for text files created from Perl?

While writing a Perl script, I got a requirement to write the user names with comma separation in only one line of the file. That's why I would like to know is there any restriction on the maximum size of the line in the .txt file. ...

Why is this A0 character appearing in my HTML::Element output?

I'm parsing an HTML document with a couple Perl modules: HTML::TreeBuilder and HTML::Element. For some reason whenever the content of a tag is just &nbsp;, which is to be expected, it gets returned by HTML::Element as a strange character I've never seen before: I can't copy the character so can't Google it, couldn't find it in charact...

How can I define constants in a separate file in Perl?

I have a bunch of Perl files which take in some filename constants. I would like to define these in a separate file - something like a header file in C. What's the best/most standard way of doing this in Perl? ...

Why does my Perl program complain about needing explicit package names?

I have a module Routines.pm: package Routines; use strict; use Exporter; sub load_shortest_path_matrices { my %predecessor_matrix = shift; my %shortestpath_matrix = shift; ... } From another script I call the the sub in the module, passing in arguments which happen to have the same name: use Routines; use strict; my %predeces...

Why doesn't XML::Twig call my end_tag_handler?

I try to call subroutine for each tag, but the end_tag_handlers is never invoked. My aim is a this sequence: ---sequence--- when <auto> call \&loading. when <apps><title> call \&kicks. when <apps><logs> call \&bye. when <apps> call \&app. when <apps><title> call \&kicks. when <apps><logs> call \&bye. when <apps> call \&app. when </au...

How can I automatically update Perl modules' $VERSION with Git?

Let's say, a team of programmers is doing a web application in Perl and uses git to host their code. Now they have a small problem with versioning their modules: Perl::Critic and PBP both recommend a RCS-backed $VERSION variable in code git explicitly recommends against using replaceable revision numbers in code (with good reasoning) ...

How do I extract single characters or enclosed groupings from a string in Perl?

I would like to split the string: "Hello[You]All" to the following array: H,e,l,l,o,[You],A,l,l I tried to do it with split: my $str = "Hello[You]All"; my @list = split(/(\[.*?\]|.)/, $str); foreach (@list) { print "->$_\n"; } Since I tried something that split is not supposed to do, it gave me the following array: ,H,,e,...

What are good options for Windows GUI toolkits for a Perl program?

I am considering doing some automation of tasks on my Windows desktop (e.g. sorting through large collections of music/text/photo files, etc...). Seeing how my main area of developer expertise is Perl on Unix, I'd prefer to stick to Perl for coding the business logic of whatever I need done, just for the sake of development efficiency....

How do I get DBIx::Class to collate with UTF-8?

Hi folks, I am trying to implement a web search functionality on a MySQL database using DBIx::Class::Resultset. I have it working apart from one problem: when searching for 'ü' the search is performed by MySQL as 'u' (in other words without the umlaut). The same is done for the other 'extended ASCII' characters. The table and the connec...

Setting Access permissions on Semaphore?

I am assuming that once a semaphore is created by a process, it will be accessible by any process/user. Is it possible to put access restrictions on a particular semaphore so that it can be accessible by only certain processes/users or only certain processes can release the semaphore. I see some problems if we make a semaphore accessibl...