perl

Good IDE or syntax highlighting editor for Mason?

Can anyone recommend some good IDEs or editors for Mason? At this point I'm just using VIM but it would be nice to have an editor that supports syntax highlighting as well as general syntax checking. There are plenty that support Perl of course, but when it comes to files with Mason and Perl intertwined the editors tend to get confus...

Why is it not possible to create a practical Perl to Python source code converter?

(This question was reworded; please, give it a second chance before deleting it again!) It would be nice if there existed a program that automatically transforms Perl code to Python code, making the resultant Python program as readable and maintainable as the original one, let alone working the same way. The most obvious solution would...

how to truncate a string using regular expression in perl

I have the following string in a file and want to truncate the string to no more than 6 char. how to do that using regular expression in perl? the original file is: cat shortstring.in: <value>[email protected]</value> <value>[email protected]</value> I want to get file as: cat shortstring.out <value>1234@g</value> ...

The good, the bad, and the ugly of lexical $_ in Perl 5.10+

Starting in Perl 5.10, it is now possible to lexically scope the context variable $_, either explicitly as my $_; or in a given / when construct. Has anyone found good uses of the lexical $_? Does it make any constructs simpler / safer / faster? What about situations that it makes more complicated? Has the lexical $_ introduced any b...

Client HTTP Post to external sites

Is there any web language that allows the client itself to create HTTP posts to external sites. I know that JavaScript does this with XMLHttpRequest, but it does not allow cross-domain posting, unless the recipient domain wants to allow the sending domain. I want to post data to an external site (that I don't control) and have the requ...

Can't install Crypt::OpenPGP through Perl CPAN

I am trying to install the Crypt::OpenPGP module via Perl CPAN with no luck. The errors I am receiving are: Failed Test Stat Wstat Total Fail Failed List of Failed ------------------------------------------------------------------------------- t/07-digest.t 1 256 15 1 6.67% 15 Failed 1/14 test scripts, 92.86% okay. 1/2...

in perl. how does hash store data in memory

I have a big xml file and parsing it consumes a lot of memory. since I believe most of it is due to a lot of user name in the file. I changed the length of each user name from ~28 Bytes to 10 bytes. and run again. but it still takes almost the same amount of memory. the xml file is so far parsed with SAX and during handling, the result i...

Can anyone explain the different Perl Cache implementations?

Hi all: There's a bunch of different Cache implementations in CPAN. I'm using Cache::File (because it is installed on my operating system) but I also see references to File::Cache, Cache:FileCache, Cache::Cache, and so on. Many appear to be implementations of "the cache interface" which appears to be either module "Cache" or "Cache::Ca...

How do you name a class/package/module like...

How would you name a package who's sole purpose was to extend another module so you could apply roles to it? I need a package that extends (sub classes) Template::Context with Moose So I can then create roles and traits to apply to it, but I don't know what to name this package (class). Any advice? ...

What is the Difference between .pm(perl module) and .pl(perl script) file?

Difference between .pm(perl module) and .pl(perl script) file? Plz also tell me why we return 1 from file. if return 2 or anything else, its not generating any error, so why we return 1 from Perl module?? ...

How to get the type of the reference

Is there any function available in perl to check the reference type. my $ref=\@array; Here I need to get the reference type as array by the function. ...

How do I access a parse tree created by XML::Parser?

I have a array reference which has some number of array references inside it. The nested array references also contains the array references. (This is the tree style of XML::Parser.) my $Filename = "sample.xml"; my $Parser = new XML::Parser( Style => 'tree' ); my $Tree = $Parser->parsefile( $Filename ); Here the $Tree is the array ...

About using an array of functions in Perl...

We are trying to build an API to support commit() and rollback() automatically, so that we don't have to bother with it anymore. By researching, we have found that using eval {} is the way to go. For eval {} to know what to do, I have thought of giving the API an array of functions, which it can execute with a foreach without the API ha...

Perl XML Parsing

Hi, I am using XML::Simple to parse a XML file. The output is a hash.(using Data::Dumper) Sample code , XML file are given below with output. Perl code: use XML::Simple; use Data::Dumper; $xml = new XML::Simple; $data = $xml->XMLin("spam.xml"); print Dumper($data); XML file contents (input to parser):: <Attach_request> <Pro...

Extract last K characters from a string in Perl

I have a string that looks like this my $str1 = "ACGGATATTGA"; my $str2 = "alex"; What I want to do is to extract last three characters from each of that. $out1 = "TGA"; $out2 = "lex"; How can I do it in Perl? ...

monitoring an exe applicaion launching

I need to monitor an console exe application which don't have any stdin from the user it only print some info to the screen i used a POE:Wheel for this task Below are my code: use POE qw( Wheel::Run); POE::Session->create( inline_states => { _start => sub { my ($heap) = $_[HEAP]; my $run ...

I have to extract a word in perl...using regular expression

The word starts with -D(It may be d also) Followed with..IT may contain spaces or do on not caontain After that its Followed by a $ Then the series is{rajna_NAME} To be brief -d ${ranjana_wdgf_NAME}or -D${Tom_task_NAME} i want to extract ranjana_wdgf Tom_task My doubt is if($word =~m/^-D(\$)\|(\w*NAME)\b/) Whats wrong: Please pr...

When does a global variable get its value assigned?

I encountered some strange behavior which hints that I do not understand some basic things about Perl script execution and initialization order. The following example: #!/usr/bin/env perl use strict; use warnings; print &get_keys(), "\n"; use vars qw/%hello/; # same effect with 'my %hello = (...);' %hello = ( a => 1, b => 2 ); sub ...

Perl: How to create objects on the fly?

My goal is to be able to use $obj like this: print $obj->hello() . $obj->{foo}; And I would like to create an object inline, maybe using something like this: my $obj = ( foo => 1, hello => sub { return 'world' } ); but when I try to use $obj as an object, I get an error saying that $obj has not been blessed. Is there some b...

How to find the file exists in Perl

For ex : #!/usr/bin/perl my @arr = ('/usr/test/test.*.con'); my $result = FileExists(\@arr); print $result ; sub FileExists { my $param = shift; foreach my $file (@{$param}) { print $file ; if (-e $file) { return 1; } } return 0; } It returns 0. But I want to find all wild charact...