perl

What Perl regex can match CamelCase words?

I am searching the following words in .todo files: ZshTabCompletionBackward MacTerminalIterm I made the following regex [A-Z]{1}[a-z]*[A-Z]{1}[a-z]* However, it is not enough, since it finds only the following type of words ZshTab In pseudo code, I am trying to make the following regex ([A-Z]{1}[a-z]*[A-Z]{1}[a-z]*){1-9} Ho...

Why does Spreadsheet::XLSX::Utility2007's xls2csv round off to two decimal places?

I am writing a Perl/Tk script which displays Excel worksheets using the ss2tk example script from the Spreadsheet::Read module. It does not round off two decimal places but the function from Spreadsheet::XLSX::Utility2007 does round off to two decimal places. Why? I'm trying to use that second function as a feature of my program to offer...

How can I search patterns in Screen with a Perl regex?

I have a process which gives me continuously output in Screen. I want to search CamelCase words by the following Perl's regex in the output such that I can monitor actively the outputs. /\b([a-z]*[A-Z][a-z]*){2,}\b/ ...

How can I get multiple memories from a Perl regex match?

The purpose of the regex search is to determine all template class instances from C++ header files. The class instances can be formarted such as: CMyClass<int> myClassInstance; CMyClass2< int, int > myClass2Instacen; The search is performed by loading the entire file into a string: open(FILE, $file); $string = join('',<FILE>); close...

Why are the number of pages in a Word document different in Perl and Word VBA?

I have a (set of) Word document(s) for which I'm trying to get various properties (number of pages, author, etc) using Win32::OLE in Perl: print $MSWord->Documents->Open($name)-> BuiltInDocumentProperties->{"Number of pages"}->value . " \n"; This returns 4 pages. But the actual number of pages in the document is 9. The number of pages...

Best way to prevent output of a duplicate item in Perl in realtime during a loop

I see a lot of 'related' questions showing up, but none I looked at answer this specific scenario. During a while/for loop that parses a result set generated from a SQL select statement, what is the best way to prevent the next line from being outputted if the line before it contains the same field data (whether it be the 1st field or t...

Is there a Perl script to implement C++ Class get/set member functions?

Hi, I was reading this morning the book The Pragmatic Programmer Chapter 3 on Basic Tools every programmer should have and they mentioned Code Generation Tools. They mentioned one Perl script for C++ programs which helped automate the process of implementing the get/set() member functions for private data members. Does anyone know abou...

Why won't Perl/Tk wipe my spreadsheet?

[cross posted again to Mahalo answers] My Perl/Tk script has an initial spreadsheet like grid displayed using the Tk::TableMatrix::Spreadsheet modules. My spreadsheet is programatically called $ss. This initial grid is wiped before the display of the first spreadsheet, with $ss->pack('forget'); The script as it is now also adds $mw-...

How can I calculate the number of days between two dates in Perl?

Heylo, I want to calculate (using the default Perl installation only) the number of days between two dates. The format of both the dates are like so 04-MAY-09. (DD-MMM-YY) I couldn't find any tutorials that discussed that date format. Should I be building a custom date checker for this format? Further reading of the Date::Calc on CPAN ...

How can I iterate over multiple lists at the same time in Perl?

I need to create a text file (aptest.s) that Ican use to read into another program. I am using Perl because I have a large list to work from. My code is as follows (which does not give the desired output - shown after code and actual output). Any help would be appreciated. #!/usr/bin/perl -w chdir("D://projects//SW Model ODME"); @link =...

How do I calculate a p-value if I have the t-statistic and d.f. (in Perl)?

Hi everyone, I have written a Perl script that performs many one-sample t-tests. I get thousands of t-statistics with their degrees of freedom (df). I need to upgrade the script to also return their p-values (there are too many to look them up manually in a table). Is there some kind of formula I can use for this with the t-statistic an...

How can I extract fonts from a PDF file with Perl?

Is there a script to extract the embedded fonts from a PDF file? ...

How can I use Ajax, perl and JSON easy together?

I am trying to make a webpage with Ajax. Example: I create a Perl/CGU file that triggers a simple post; File: ..test.cgi?name=Thomas Text back: Your name is Thomas! I create a html file that can use the post, but then the page have to reload. I use text input and a button. How can I use Ajax, Perl and JSON easy together? This is h...

How can I collate and summarize records from a file with Perl?

Hello all, I have a text file in the following format: 211B1 CUSTOMER|UPDATE| 211B2 CUSTOMER|UPDATE| 211B3 CUSTOMER|UPDATE| 211B4 CUSTOMER|UPDATE| 211B5 CUSTOMER|UPDATE| 567FR CUSTOMER|DELETE| 647GI CUSTOMER|DELETE| I want a script that processes the text file and reports the following: "UPDATE" for column CUSTOMER found...

When should I use Perl CGI instead of PHP (or vice versa)?

For hobby purposes, I have a shared space on a hosting server that is providing, as many of them are, both PHP and Perl CGI. I have read on several places that CGI scripts are obsolete now, I think mainly for performance issues (like http://stackoverflow.com/questions/313083/is-php-or-vanilla-perl-cgi-faster). But since I just started ...

Why doesn't Win32::ODBC find the ODBC.dll under Perl 5.10 and Cygwin?

I'm trying to use Perl ODBC to connect to a Microsoft SQL server. My problem is that Perl 5.10.0 is having a problem using the Win32 ODBC driver. If I run a Perl shell and execute this one line, I get errors. use Win32::ODBC; Can't load '/usr/lib/perl5/vendor_perl/5.10/i686-cygwin/auto/Win32/ODBC/ODBC.dll' for module Win32::ODBC: No ...

Is there a Perl IMAP module with TLS support?

I'm writing a Perl script to connect to an IMAP server that requires TLS over port 143. The server does not support connecting over SSL. Thus far, the Perl IMAP modules I have found support only SSL, not TLS. Are there any Perl IMAP modules that provide TLS support? Thus far I have looked at: Net::IMAP Net::IMAP::Simple Net::IMAP::Clie...

What's the best way to extract Excel cell comments using Perl or Ruby?

I've been parsing Excel documents in Perl successfully with Spreadhsheet::ParseExcel (as recommended in http://stackoverflow.com/questions/429193), but I can't figure out how to extract cell comments. Any ideas? A solution in Perl or Ruby would be ideal. ...

How do I extract the domain out of an URL?

How do I extract the domain out of an URL? Is there a Perl Module? I could not find any. ...

How can I sort Perl hashes whose values are array references?

Hey I was just wondering if there is a cool "one liner" that would sort my hash holding array references. So I have a bunch of key/values in my hash something like: $DataBase{$key} = \@value; However I would like to sort the hash by the array[0] element. Then loop through 'em. I had this to begin with: foreach my $key (sort {$DataBa...