perl

Why doesn't the match operator match anything?

I'm trying to parse this HTML block: <div class="v120WrapperInner"><a href="/redirect?q=http%3A%2F%2Fwww.google.com%2Faclk%3Fsa%3DL%26ai%3DCKJh--O7tSsCVIKeyoQTwiYmRA5SnrIsB1szYhg2d2J_EAhABIJ7rxQ4oA1CLk676B2DJntmGyKOQGcgBAaoEFk_Qyu5ipY7edN5ETLuchKUCHbY4SA#0%26num%3D1%26sig%3DAGiWqtwtAf8NslosN7AuHb7qC7RviHVg7A%26q%3Dhttp%3A%2F%2Fwww.youtu...

How do I get the COM object from a HWND in Win32::OLE?

In Perl, if I have HWND of a window object, how can I get access to that COM object using that handle? I looked at Win32::OLE but the closest I got was the GetActiveObject method, which expects a class. ...

How do I use Win32::SqlServer to connect remotely?

I have been unable to make a successful connection to my SQL Server (2005) using Win32::SqlServer. The server is located on another machine. I am using the latest version of ActivePerl and the module. Using an ADO.NET provider (in C#), I can make a successful connection with the connection string: Data Source=1.2.3.4,1553;Initial Cata...

Can I generate Excel files with native Excel charts on Linux?

Is there a way to generate Excel spreadsheets with Perl on Linux so that I can open the spreadsheet on Windows and it creates native Excel graphics? I know that there are libs to draw graphics but all libs I know simply insert a picture to the Excel which looks weird when I open the spreadsheet on Windows. So I wondering is there a way t...

Eclipse/EPIC source formatter sometimes works sometime does not. why?

I have EPIC installed for Eclipse to be used for perl development. EPIC used perltidy for souce formatting. The problem I am facing is this - When I select a bunch of code and press CTRL+SHIFT+F the selected code gets formatted according to the preferences saved. However, sometimes this does happen even though the select code is not corr...

How can I ensure my program finds the perl interpreter on different platforms?

My Perl script runs under several OS's, including unix and Win32. On every OS there is unique Perl setup, whereby the perl interpreter is located under different directories. Is there a way to specify the interpreter on the shebang line like: #!which perl ...

How can I extract the matches from the Perl match operator into variables?

If I have a match operator, how do I save the parts of the strings captured in the parentheses in variables instead of using $1, $2, and so on? ... = m/stuff (.*) stuff/; What goes on the left? ...

How can I parse a mathematical function from user input in Perl?

I wrote a tool for polar functions. It lists values from an input range like that: 0 Grad: (0 RAD|1 RES) 20 Grad: (0.349065850398866 RAD|1.3639702342662 RES) 40 Grad: (0.698131700797732 RAD|1.83909963117728 RES) 60 Grad: (1.0471975511966 RAD|2.73205080756888 RES) 80 Grad: (1.39626340159546 RAD|6.67128181961771 RES) 100 Grad: ...

DBIx::Class result classes and actual tables

I'm studying DBIx classes and I'm a bit confused since my interaction with a database so far has been plain SQL queries in PHP code. Anyway, as I understand it, the class operates with the schema defined in the result classes instead of interacting directly with the database. The schema can be either be built manually via the various ....

Why doesn't Perl support the normal [] operator to index a string?

Why doesn't Perl support the normal [] operator to index a string? Almost all major programming languages support this operator,esp the other two 'P': python and php.Moreover,I do think it should be easy to implementate this little syntax.Also,as the philosophy of the perl programming language -- as lazy as we could,so why do we bother t...

How can I convert an XML document from Latin-1 to UTF-8 in Perl?

We at the company want to convert all the sites we are hosting from Latin-1 to UTF-8. After a ot of googling, we have our Perl script almost complete. The only thing that is missing now are the XML files. What is the best way to convert XML from Latin-1 to UTF-8 and is it useful? I am asking because we are unsure about it since most en...

What is a better way to stream audio with Perl CGI?

Stackoverflow: For a cs assigment I am using the following code to stream audio. However, now I would like to add the ability to stream files successively, as in a playlist, how can I modify my code to accommodate this? I would like to have a text file of filenames that my script passes through sequentially streaming each. Is this ...

Finding a Perl memory leak

SOLVED see Edit 2 Hello, I've been writing a Perl program to handle automatic upgrading of local (proprietary) programs (for the company I work for). Basically, it runs via cron, and unfortunately has a memory leak (or something similar). The problem is that the leak only happens when I'm not looking (aka when run via cron, not via c...

Consume AMF methods without Flash

I have to call an existing AMF Method in a PHP (or Perl) Script and read its results. Is it possible to use amfphp to invoke it instead of serving AMFs? or use other tool? Am I trapped to use Flash? Thank you ...

Perl syntax error

See also SO 1664677 I get this error 2: Syntax error: "(" unexpected when I run this script -- all help is very appreciated #!/usr/bin/perl use Digest::MD5 qw(md5_hex); printf "Usage : keygen.pl e-mail key-id\ne-mail : the one you provided\nkey-id : provided by hcf/hsfconfig\n"; $pad = pack("H2048", "00000000963007772c610eeeba510...

Is there a way to force $c->uri_for in Catalyst to generate a URI that begins with https?

I've written a web application using Catalyst that has a lot of forms and needs to run over https. There are no hard-coded URLs, everything uses $c->uri_for or $c->req->uri. Everything worked great in the development environment using the dev server running over http. Today, when I went ahead and deployed the application, I noticed a pr...

How can I reclaim memory from perl?

Which is the way that I can reclaim memory back from my Perl script and/or to prevent perl from memory management pooling? ...

Is $1 or $& faster for replacing a matched string using s/// in Perl?

Which one of these is cheaper? $_ = 'abc123def'; s/\d+/$&*2/e; say; s/(\d+)/$1*2/e; say; ...

How can I use mysql bit from using DBIx

Hi, I am trying to access a mysql bit field in my catalyst app. Here is the table info: SQL: create table foo{ ... mybitField bit(1) NOT NULL default b'0' } My mapped table: ... mybitField { data_type => "BIT", default_value => "b'0'", is_nullable => 0, size => undef, } ... Now in my controller, I do a simple...

Regular expression to match unique words in files

To prefix unique words with "UNIQUE:" inside a file I've tried to use a perl regex command like: perl -e 'undef $/;while($_=<>){s/^(((?!\b\3\b).)*)\b(\w+)\b(((?!\b\3\b).)*)$/\1UNIQUE:\3\4/gs;print $_;}' demo On a demo file containing: watermelon banana apple pear pineapple orange mango strawberry cherry kiwi pineapple lemon cranberry...