perl

How can I implement Web Services in Perl?

How to implement Web Services in Perl? ...

How do I import environment settings into my Perl program?

I have a script whose content simply exports a variable in linux. export LD_LIBRARY_PATH=.... I want to run this script in my Perl script so whoever is running my Perl script will have their LD_LIBRARY_PATH set. Can i just do this in the beginning of my Perl script: #!/usr/bin/perl -w system(". /myfolder1/myfolder2/myScript.sh"); ...

How can I extract values from the XML::Simple's data structure?

I'm trying to figure out how to parse the <current></current> values from the first 2 (37% and 61.8F) in this XML. I can't figure it out since it seems that they have the same field names and are all under 'sensor'... any help would be appreciated... Code in Perl: #!/usr/bin/perl use XML::Simple; use Data::Dumper; use LWP::Simple; $...

How do I override perl's compilation flags when building modules?

When building a Perl module ExtUtils::MakeMaker uses the flags defined in Config.pm (see perldoc Config) for values such as ccflags and ldflags. How do I override theses values (short of editing the Makefile.PL)? perl Makefile.PL ldflags=<options> does not seem to work. Context: I am trying to compile Term::Readline::Gnu on OS X 10....

How can I speed up my Perl regex matching?

I want to capture several text using the following regex: $text_normal = qr{^(\/F\d+) FF (.*?) SCF SF (.*?) MV (\(.*?)SH$}; A sample of the string is like below: my $text = '/F12345 FF FF this is SCF SF really MV (important stuff SH'; Can that be rewritten to speed up the matching? ...

warnings::warn and FATAL categories in Perl

I must be understanding the warnings documentation wrong. The way I read it, this code: use warnings; use warnings FATAL => 'all'; warnings::warn('numeric', 'blarg'); print "finished\n"; Should print the 'blarg' warning and die since I've asked for all warnings to be fatal. However, when I run the code I get: $> /opt/local/bin/perl...

perl.exe cannot be called by ProcessStartInfo

Hello: I am trying to get the following code to work so I can call a perl script from my c# program. I am developing using visual stdio 2008 on xp service pack3. myProcess = new Process(); ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("perl.exe"); myProcessStartInfo.Arguments = @"C:\Documents and Sett...

Excluding code sections from EPIC/tidyperl source formatting.

I in a large codebase of an application written in perl there is a lot of HTML and JS written inline in the perl file. $html_str = qq^ <A LOT OF HTML> ^; All the code development in done using Eclipse IDE and EPIC plugin. For ease of merging/diffs et al, I am looking for a way to tell the EPIC source formatter not to apply formatting...

How do I load XML::XML2JSON?

The XML2JSON package is not getting loaded when I execute my program. I'm getting the following error: Can't locate object method "new" via package "XML::XML2JSON" (perhaps you forgot to load "XML::XML2JSON"?) at jsontoxml.pl line 6. ...

How can I autoincrement a Perl hash value?

Database Data: Passport_No Bank statement_no Credit_id 4126897 HSBC 2948608 0 4126897 HSBC 2948609 1 4126858 HSBC 2948591 0 4126858 barclays 2948595 0 4126858 barclays 2948596 1 4126858 barclays 2948597 2 The credit id is ba...

How can I continuously read from the serial port in a Perl Win32::GUI program?

I would like to use the Win32::SerialPort module under Windows XP to read a text string from a COM port. There is a scale attached to the serial port which continuously sends the current measured weight. Since I'm also using Win32::GUI I need a way to read that non-blocking. What's the best way to do this? Should I use Lookfor or stream...

How can I control the formatting of Data::Dumper's output?

I am using Data::Dumper::Dumper() method. The output is good, but can be made little compact and more good looking. How I can control it? What are the better alternatives? ...

In Perl, how can I do a non-blocking system call?

In Perl, without using the Thread library, what is the simplest way to spawn off a system call so that it is non-blocking? Can you do this while avoiding fork() as well? EDIT Clarification. I want to avoid an explicit and messy call to fork. ...

How can I index a bunch of files in Perl?

I'm trying to clean up a database by first finding unreferenced objects. I have extracted all the database objects into a list, and all the ddl code into files, I also have all the Java source code for the project. Basically what I want to do (preferably in Perl as it's the scripting language that I'm most familiar with) is to somehow i...

How can I sum each column of my data in Perl?

Hi I have a file with following data: 1==0==2 5==3==2 7==1==0 how to add the numerical value column wise. I need to summarize and print it like 1==0==2 5==3==2 7==1==0 13==4==4 * summation column wise (This is what I want to calculate using perl) I guess you have misunderstood my question. I have edited my question again by ......

How do I do a non-blocking IPC read on Windows?

I have a Perl script that uses an external tool (cleartool) to gather information about a list of files. I want to use IPC to avoid spawning a new process for each file: use IPC::Open2; my ($cin, $cout); my $child = open2($cout, $cin, 'cleartool'); Commands that return single-lines work well. e.g. print $cin "describe -short $file\n"...

How do I archive a set of files using Perl on Win32 while retaining file paths?

PROBLEM FOUND. I'm leaving the question here, though, in case others run into the same problem I ran into. It looks like I encountered a bug or a weird feature in WinZip 11. When I double click the test2.zip file to see its contents, WinZip tells me the path to the data file is "allcapsname" in lower case, but when WinZip extracts the ...

How can I remove external links from HTML using Perl?

I am trying to remove external links from an HTML document but keep the anchors but I'm not having much luck. The following regex $html =~ s/<a href=".+?\.htm">(.+?)<\/a>/$1/sig; will match the beginning of an anchor tag and the end of an external link tag e.g. <a HREF="#FN1" name="01">1</a> some other html <a href="155.htm">No. 155 ...

Should I use inheritance or composition?

I would like to keep this one short. I build a HouseA that has two rooms, say BedRoom and StudyRoom, both deriving from a base class called Room. BedRoom and StudyRoom have a same parent called House. Also, any room in a house can access any other rooms only through the parent. If BedRoom has to access any attribute of StudyRoom, it has ...

Why does my non-greedy Perl regex still match too much?

Say, I have a line that contains the following string: "$tom" said blah blah blash. "$dick" said "blah blah blah". "$harry" said blah blah blah. and I want to extract "$dick" said "blah blah blah" I have the following code: my ($term) = /(".+?" said ".+?")/g; print $term; But it gives me more than I need: "$tom" said blah ...