perl

What did Perl's $* variable used to do?

I have some code from http://www.hyllander.org/node/23 that uses $* ("dollar asterisk" or "dollar star"), but my version of perl reports: $* is no longer supported at migrate.pl line 284. Do you know what were the side-effects of doing $*=1 Did that somehow affect functions like split or tokenizers or regular expressions? ...

Convert Perl script to Python: dedupe 2 files based on hash keys

I am new to Python and would like to know if someone would kindly convert an example of a fairly simple Perl script to Python? The script takes 2 files and outputs only unique lines from the second file by comparing hash keys. It also outputs duplicate lines to a file. I have found that this method of deduping is extremely fast with Pe...

How do I retrieve the terminal width in Perl?

I want to output a progress bar, but how do I retrieve the terminal width in Perl? A core Perl solution would be preferred, since I don't have access to a compiler, just an already installed 5.8.2 Perl. ...

How can I filter a large file into two separate files?

I've got a huge file (500 MB) that is organized like this: <link type="1-1" xtargets="1;1"> <s1>bunch of text here</s1> <s2>some more here</s2> </link> <link type="1-1" xtargets="1;1"> <s1>bunch of text here</s1> <s2>some more here</s2> </link> <link type="1-1" xtargets="1;1"> <s1>bunch of text here</s1> <s2>some...

How can I make Perl's File::Find faster?

I have a folder named Lib and I am using the File::Find module to search that folder in whole dir say, D:\. It's taking a long time to search, say even 5 mins if the drive has a lot of subdirectories. How can I search that Lib faster so it will be done in seconds? My code looks like this: find( \&Lib_files, $dir); sub Lib_files...

Need help with "pack" for perl and php

Hello! I've the task to convert a crypt function someone made in perl into php code. Everything works okay except this: Perl: $wert = Encode::encode( "utf8", $wert ); $len=length $wert; $pad = ($len % 16)?"0".chr(16 - ($len % 16)):"10"; $fuell = pack( "H*", $pad x (16 - $len % 16)); PHP: $wert = utf8_encode($wert); $len = mb_strlen...

What concerns should I have if I use Smart::Comments in development code?

I understand that Smart::Comments should not be used in production code, since it is a source filter. However, I have been using Smart::Comments in my development code and then commenting out the "use" line before sending the code to production. Given that I'm going to use it in my development code, what I should specifically be conce...

How do I traverse a remote (ftp) directory tree with Perl?

Before I reinvent the wheel, is there any module like File::Find that works via ftp? ...

Why are Perl source filters bad and when is it OK to use them?

It is "common knowledge" that source filters are bad and should not be used in production code. When answering a a similar, but more specific question I couldn't find any good references that explain clearly why filters are bad and when they can be safely used. I think now is time to create one. Why are source filters bad? When is it...

How can I intercept keyboard events with Perl?

Is there any way on Perl to identify if a keyboard event is triggered on Win32 before the key itself reach its GUI application ? ...

How do I create a sash in Perl Tkx?

Does anyone know how to create a sash object in Perl Tkx? I am using ActivePerl and Perl 5.10. ...

How can I open() and close() STDERR in Perl?

Greetings , I can close the STDERR in perl using; close(STDERR) and after executing some logic , I want to open it back again. How can I do it? I tried open(STDERR,">&STDERR"); and didn't work. Thanks in advance. ...

Is implementing SOAP clients in Perl using meta-programming sensible?

I'm currently dealing with a code base which contains several dozens of classes generated with SOAP::WSDL. However, having worked with Moose I now think that generating those classes at runtime at meta level (i.e. not to files on disk but directly to objects) might be a better idea (completely excluding performance reasons at this point)...

How can I modify fields in a CSV file with Perl?

Hi, I have a csv file with following sample data. o-option(alphabetical) v-value(numerical) number1,o1,v1,o2,v2,o3,v3,o4,v4,o5,v5,o6,v6 number2,o1,v11,o2,v22,o3,v33,o44,v44,o5,v55,o6,v66 and so on.... Required output. NUM,o1,o2,o3,o4,o44,o5,o6 number1,v1,v2,v3,v4,,v5,v6 number2,v11,v22,v33,,v44,v55,v66 and so on... In this data...

How do I call another Perl CGI script within a CGI script?

I have a Perl CGI script that creates a login screen, i.e. user name and password. I want, after successful login, the user to be redirected to the next action within the application (another Perl CGI script). What is the command to redirect one CGI script or to an HTML page? ...

Scheduling scripts at a different timezone

There are some programs/scripts that need to be run at specific times in a timezone different from the system timezone. A la crontab in Perl, but one that honors a timezone and DST rules in a region different from that in which the system is configured. Here is the use case : I will create an excel sheet with the time in PT in column B...

How do I set cookies using Perl CGI?

I have tried without success setting cookies using Perl CGI. My code looks like this: $qry = new CGI $cookie = $qry->cookie(-name=>'SERVER_COOKIE', -value=>'USER_NAME', -path=>'/'), $qry->header(-cookie=>$cookie) The page does not throw any error, but no cookie gets set! I am using Fire...

How can I sum large hexadecimal values in Perl?

I'm iterating over a set of 32-bit hexadecimal strings ("DEADBEEF", "12345678", etc..) and I'm trying to sum them together to form a 32-bit checksum. Assume that the variable $temp is loaded with some hexadecimal string in the example below. my $temp; my $checksum; for (...) { #assume $temp is loaded with a new hex string here ...

C# Client - Perl server - File Path Case Sensitivity

We have a C# .Net client application that sends some commands via REST over HTTP. The server is on a Linux machine written in Perl. These commands contain file paths located on the server that can be entered by the user. Since the users are on windows, we'd like for them to be case-insensitive, but this is giving us some issues in loc...

How do I design a Perl cookie initialization login screen?

Guys, Based on this question I asked earlier on setting up cookies in Perl, I successfully got an answer and way to do this but am now faced with a new interesting challenge. In Perl CGI scripts, it demands you setup a cookie on the header statement which ought to be the first statement in your script. To clarify, you need to have a CGI...