perl

Matching lines across multiple csv files and merging a particular field

I have about 20 CSV's that all look like this: "[email]","[fname]","[lname]","[prefix]","[suffix]","[fax]","[phone]","[business]","[address1]","[address2]","[city]","[state]","[zip]","[setdate]","[email_type]","[start_code]" What I've been told I need to produce is the exact same thing, but with each file now containing the start_code...

Should I choose ActivePerl or Strawberry Perl for Windows?

I'm totally new to Perl but I'd like to try it out. I read about two rival distributions available for Windows platform (I guess there's just Perl on other OSes :). Wikipedia says that Strawberry comes with additional dev tools to compile CPAN modules if necessary. Sounds pretty good to me. It also says that ActivePerl has a lot of pr...

decode a string into different variables using PERL one liner

Hi, I've the following strings which I would like to decode into different variables depending on the string examples {"response":{"report":"fail","brand":"1.0","fail":{"message":"Invalid Number"}}} {"response":{"report" : "pass", "brand" : "1.0", "payment" :{"paymentId":"4CA008DAAA41EC19C754EF"}}} {"response":{"report":"fail","bra...

Accessing the Catalyst object $c from MyApp.pm

I'm using the Assets plugin in my Catalyst app, and I would like some javascript and css files included in the assets of every page. My first thought is call $c->assets->include('file.js') from MyApp/lib/MyApp.pm where I do setup and config, but I don't know how to get a hold of $c there. My next idea involves using the WRAPPER stu...

Splitting a string with multiple white spaces with perl?

I am trying to split a string with multiple white spaces. I only want to split where there are 2 or more white spaces. I have tried multiple things and I keep getting the same output which is that it splits after every letter. Here is the last thing I tried @cellMessage = split(s/ {2,}//g, $message); foreach(@cellMessage...

Calling 'scalar' on the results of the range operator (..) in Perl

So, I believe this has something to do with the difference between arrays and lists, but I don't understand what's going on here. Can anyone explain how and why Perl treats an expression like (1..4) differently than (1, 2, 3, 4) and @{[1..4]}? $ perl -de1 Loading DB routines from perl5db.pl version 1.31 Editor support available. Enter...

Learning Perl - Which version?

I've been thinking about learning Perl. Should I learn Perl5 or start with Perl6? ...

perl how to regex parts of data instead of entire string and then print out a csv file

I have a working perl script that grabs the data I need and displays them to STDOUT, but now I need to change it to generate a data file (csv, tab dellimited, any delimiter file). The regular expression is filtering the data that I need, but I don't want the entire string, just snippets of the output. I'm assuming I would need to store ...

How can I create a Crypt::RSA object from modulus, exponent, and private exponent?

I'm trying to port the following php functionality over to perl: public function loadKey($mod, $exp, $type = 'public') { $rsa = new Crypt_RSA(); $rsa->signatureMode = CRYPT_RSA_SIGNATURE_PKCS1; $rsa->setHash('sha256'); $rsa->modulus = new Math_BigInteger(Magicsig::base64_url_decode($mod), 256); $rsa->k = strlen($rsa-...

Error while starting Apache

I am getting following error while starting apache. Can't locate /usr/sbin/webmux.pl in @INC (@INC contains: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /...

JSON GUI creator/editor

Hi, I'm using text files in JSON format as input to my java/perl programs. I would like to allow novice users to generate such JSON files themselves, following some template. Is there some GUI that allows easy, step-by-step creation of a JSON file? It should allow filling in fields with text, choosing file locations etc. Also note the...

How do I splice a scalar variable?

$ab = "asljdhashdklasjkl ;dajs;ld"; I want the first 10 characters from $ab. Can the splice function be used? ...

Perl - Class::Struct Deferencing array

use Class::Struct; struct (TimingStruct => { _timingSense => '$', _timingType => '$', _relatedPin => '$', _whenCond => '$' }); struct (OutPinStruct => { _outPinName => '$', _outFunction => '$', _timingarray => '@', #_timingarc => 'TimingStruct' });...

Haskell in SPOJ: "Wrong answer" in problem, but correct in my computer

Hi I've been submitting solutions to the COINS problem in SPOJ today. I've got accepted the Fortran and the Perl solutions, but I'm having "Wrong answer" in the Haskell solution. I thought that perhaps my code was faulty at some point, but the results for 200K numbers (100K in the upper limit and 100K in the lower one) are exactly as pe...

Parameters passing style in Perl

I see people using two styles for passing named parameters in Perl: use strict; use warnings; use Data::Dumper; sub foo { print Dumper @_; } sub bar { print Dumper @_; } foo( A => 'a', B => 'b' ); bar( { A => 'a', B => 'b' } ); What are the advantages in using foo() style instead of bar() style? ...

Parsing XML files with regular expressions (Perl)

Hi, I am using regular expression to parse XML file (though regexp is not recommended for xml parsing, but i have to use regexp, no other go). My doubt is how to skip commented lines in XML file, while parsing using Perl. I want Perl to parse XML file, while skipping commented lines. Can anyone help me, please. Thanks Senthil . ...

How can I use NYTProf in a library

I'm wondering if Devel::NYTProf can be used as a library in another library. I'd like to do something like the following around 'somesub' => sub { my $orig = shift; my $self = shift; start-timing; $self->$orig(@_); end-timing; print '$time'; } but from it's documentation I'm unable to determine if it can be use...

perl: use string as piece of code

Hello, I would like to use a string (e.g. read from a file) as a piece of code in my perl program. For example, I read a string (e.g. $str="1..100,171,398..1000") then I would like to print all the numbers in the range represented by the string. Thanks, Dave ...

perl backticks: use bash instead of sh

Hi, I noticed that when I use backticks in perl the commands are executed using sh, not bash, giving me some problems. How can I change that behavior so perl will use bash? PS. The command that I'm trying to run is: paste filename <(cut -d \" \" -f 2 filename2 | grep -v mean) >> filename3 ...

How do I write a Microsoft Word/Office Open XML document using Perl?

I have written a Perl script that reads some data and generates an OpenOffice Writer/OpenDocument file for that data. Can I also construct a Microsoft Word/Office Open XML document? ...