Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win







Perl is a high-level, general-purpose, interpreted, dynamic programming languages with over 25 years of development. Perl 5 runs on over 100 platforms from portables to mainframes and is suitable for both rapid prototyping and large-scale development projects.  Perl gained widespread popularity as a Common Gateway Interface (CGI) scripting language, in part due to its regular expression and string parsing abilities. In addition to CGI, Perl is used for graphics programming, system administration, network programming, finance, bioinformatics, and other applications.

Share tech news, updates, or what's on your mind.

Sign up to Post


I am using the Sort function in the Win32::OLE package for Perl.
I would like to sort all my columns based on the first 4 columns (sort by: col1 then col2... col4)
For now I am able to sort by the 3 first columns but when I try to do on 4 I get an error in GetIDsOfNames for "Sort" at MyFile.pl

Here's my code:

my $SortOrd1 = $SheetC->Range("A2");
my $SortOrd2 = $SheetC->Range("B2");
my $SortOrd3 = $SheetC->Range("C2");
my $SortOrd4 = $SheetC->Range("D2");

my $Range = "A" . ($dcmRowA+2) . ":" . chr($LastColC+64) . ($LastRowC);
my $Selection = $SheetC->Range($Range);
my %hash = (Key1 => $SortOrd1, Order1 => xlAscending, Key2 => $SortOrd2, Order2 => xlAscending,  Key3 => $SortOrd3, Order3 => xlAscending, Key4 => $SortOrd4, Order4 => xlAscending);

Open in new window

again, if I remove the Key4 => $SortOrd4, Order4 => xlAscending) the code works fine, but I need to sort according to the first 4 columns

Would you know why I get this error with 4 criterias but not 3?

Thanks in advance
Have a good day :)

Industry Leaders: We Want Your Opinion!
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

i do this perl script:

#! /usr/local/bin/perl
use File::Compare;         #Module de comparaison des fichier
if (compare($fichier_1, $fichier_2) == 0)
  printf("%s et %s ont le même contenu",$fichier_1,$fichier_2);
   printf("%s et %s sont différents",$fichier_1,$fichier_2);

now i wish fic1 and fic like the argument for execution ( compare.pl  fic1 fic2); and
-Check that there are 2 parameters by looking at the length of @argv
-Print an error message if it is not.
-open both files, display an error message if a file does not exist.
and compare the two lists line by line and display a message if a difference
is detected.
If there was no difference indicate that the files are similar.


I have string(s)  that may or may not contain coma separated 2 character code values
I need to test if parts of the list has 2, 3 or many characters long

and return a string of coma separated 2 code values  via look up tables

I've come up with this (Untested) code but I'm thinking there could be a cleaner way?

BTW the "string" is a column in a database that  needs updating

I don't think there is mixed content (Either 2 character or 3 / multiple character  but not both)
my @sample=(
"Know word, other know words",
"XX ,YY ,ZZ"

foreach my $line (@sample){
 my @bits= split(',',$line),
 foreach my $bit (@bits){
    $bit =~ s/[^\s+|\s+$]//g; # remove any white space from start or end
   if( length ($bit) == 2){
        print "all is good with $bit\n";
   elsif( length ($bit) == 3){
        print "Not so good with $bit\n";
        ## Code to convert $bit to 2 digit  via look up table 1
        print "all is not so good with $bit\n";
        ## Code to convert $bit to 2 digit  via look up table 2

Open in new window


I have come code that is erroring.

on v5.8.8 built for MSWin32-x86-multi-thread

C:\Users\ce6ph8\AMFAM\Mass_Create>perl cetan_mass_create_xml.pl -c input_file.csv -o test_1016
Backslash found where operator expected at cetan_mass_create_xml.pl line 309, near "($PREDNAME,$SUCCNAME) = split(/\"
  (Might be a runaway multi-line // string starting on line 307)
        (Missing operator before \?)
String found where operator expected at cetan_mass_create_xml.pl line 321, near "print TEMPFILE ""
  (Might be a runaway multi-line "" string starting on line 315)
        (Missing semicolon on previous line?)
syntax error at cetan_mass_create_xml.pl line 309, near "($PREDNAME,$SUCCNAME) = split(/\"
syntax error at cetan_mass_create_xml.pl line 329, near "} elsif"
syntax error at cetan_mass_create_xml.pl line 334, near "}"
Execution of cetan_mass_create_xml.pl aborted due to compilation errors.

I believe the line in question is

    my $iter = each_array(\@PREDLIST, \@SUCCLIST);
    while (my @values = $iter->()) {
        $AA =  join ',', map $_ // '', @values;                            # line 309
        ($PREDNAME,$SUCCNAME) = split(/\,/, $AA);

The code works fine on Perl higher level of perl but can't install a new version.

In the mapping I do not know what the // and '' does too?

Is there a different code I could use.


I have a large configuration file that contains lines like:

device pool pool-name-1 address address
device pool pool-name-2 address address
lines of data
device server server-name-1 pool-name-1
lines of data
device server server-name-2 pool-name-2
lines of data

. . . and I need to match the server lines with the pool-name lines like:

server-name-1, pool-name-1,,
server-name-2, pool-name-2,,

In other words, there are two line pairs  throughout the file that need to be represented as a single line.

I have tried to read the file into a hash, reading "pool" and "server" lines into an array . . . but I get lost from there. Can someone offer a suggestion about how to get started?

I need some fancy way to look in my file named "ocr-delete-records-pass-3.csv" in  that file there is a column B I need to match on my other file  "global-TXT-Records-ALL.csv" and spit out a new file called "text-remove.csv" I also need to preserve the format in the first file "ocr-delete-records-pass-3.csv" when the new output is produced.

In short I have a list of names in ocr-delete-records-pass-3.csv which I need it to look in  the master "global-TXT-Records-ALL.csv"  file for a match on the TXT record in column D from the "global-TXT-Records-ALL.csv" file.

If this can be done please advice

Thank you !
I would like to replace the HTML in an old CGI Perl script, so that it follows the Bootstrap framework.

I would like to know where and how to link to the CSS file from inside the actual script, and not from a template.

Thanks for your help!

I need to replace and & but if there is a & or " do not replace the &
Not sure how to do this.



I have a cgi perl script that does not respond to screen size.

I am an html designer and would like to change the html inside the scripts to make them responsive.

Are there any general guidelines I should follow? Any do's and don'ts? For example, where and how to link to a css file, things like that.

Furthermore, is this worth my time, or is it much better to get a programmer?

Thanks for your help,

say for example I have data like "check something=0", I wanted to display full sting before "=". I tried using "($strCombLine =~ m/(\S*)=/g)" but it is only displaying "something" but not "check something" ....I want output to display as "check something" full string.

Quick help is appreciated.
Free Tool: ZipGrep
LVL 10
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Hello Team,

Require a shell/perl script with below steps.
1) When disk space reaches 75%, trigger a cron job and move the old .arc files to another location.
2) Clean up the files in a folder by keeping only 8 hours of data available and it should be run every 15 mins.

Hi All,

I'm getting below error when trying to run the make script for the DBD::ORACLE module. Can someone please help on this.

I_VERSION=\"\" -DORA_OCI_102 Oracle.c
"Oracle.h", line 37.10: 1506-296 (S) #include file <oci.h> not found.
"Oracle.h", line 39.10: 1506-296 (S) #include file <ocidfn.h> not found.
"Oracle.h", line 40.10: 1506-296 (S) #include file <orid.h> not found.
"Oracle.h", line 41.10: 1506-296 (S) #include file <ori.h> not found.
"dbdimp.h", line 23.9: 1506-046 (S) Syntax error.
"dbdimp.h", line 41.9: 1506-046 (S) Syntax error.
"dbdimp.h", line 93.9: 1506-046 (S) Syntax error.
"dbdimp.h", line 175.9: 1506-046 (S) Syntax error.
make: The error code from the last command is 1.

trying to remove any year from a file name

where A year is 4 numbers will be a space or a dot 19|20 \d\d  the same space or a dot

use strict;
use warnings;
use File::Copy;
use File::Basename;
use File::Path qw(make_path remove_tree);
my $Ext = "\.mp4|\.mkv|\.avi|\.mpg";

while ( my $line = <DATA> ){
  if($line =~ m/[$Ext]$/){
      print "line $line\n";
      my $old = $line;
      if(-e "$old"){
          my $new = $old;
          if($new=~s{\w[19|20]\d\d\w}{FooBar}){  ##  not matching 
              print "new $new\n";
               print "old $old\n";



Path\To\My file 2012\S01\The.Best.TV.Show.2012.S01E01.720p.mkv
Path\To\My file 2012\S01\The.Best.TV.Show.2012.S01E02.720p.mp4
Path\To\My file 2012\S01\The.Best.TV.Show.2012.S01E03.720p.mpg
Path\To\My file 2012\S01\The.Best.TV.Show.2012.S01E04.720p.avi
Path\To\My file 2012\S01\The.Best.TV.Show.2012.jpg

Open in new window

Hi All,

We have recently upgraded our Aix OS from 6.1 to 7.1, along with the Os the perl fileset got upgraded to 5.10.1 from 5.8.8, now we are getting the below issue.

Can't locate DBI.pm in @INC (@INC contains: /usr/opt/perl5/lib/5.10.1/aix-thread-multi /usr/opt/perl5/lib/5.10.1 /usr/opt/perl5/lib/site_perl/5.10.1/aix-thread-multi /usr/opt/perl5/lib/site_perl/5.10.1 /usr/opt/perl5/lib/site_perl/5.8.8 /usr/opt/perl5/lib/site_perl .) at /dispatch.pl line 3.
BEGIN failed--compilation aborted at /dispatch.pl line 3.

Can someone please help me to resolve the issue.

I'm thinking to reinstall the older version of perl i.e., 5.8.8, but I'm not sure if it works or not. And I couldn't even find if the 5.8.8 is still compatible with the Aix 7.1 TL 4 SP4. Thanks.

I probably experiment what is the result of a version change from ... perl "version 2" to version 5.10. Help welcome !

1. For 14 years I run a Windows (to have a totally separate/protected back-office) C program to generate a perl hash file script named whois.in. Nothing has changed.

2. I download and execute that script through "perl whois.in" on a Centos server to produce a binary "whois.db" file.

3. That binary whois.db file is accessed hundreds of times a day by a perl cgi scrip (which runs my web site). This script has been unmodified. Everything was perfect. And I foregot my perl experience.
The code of the access routine is in annexe 1.

Bluntly (a few days ago, killing my business) :
- the cgi script has started failing accessing the daily whois.db files.
- HOWEVER it can continue access the old whois.db file produced before the problem occured.

1) I suspect this results from a change of my dedicated Centos server machine toward a new hardware. The hosting provider has updated the language versions. Now 5.10.

2) I made some cleaning in whois.in file as I noted that "perl whois.in" failed for not-7bit ascii characters. I updated strawberry on my Windows machine and did some cleaning the "perl whois.in" script. Now whois.db binaries produced by "perl whois.in" both on the CentOS and on the Windows machine are of the same size BUT differ (according to diff on CentOS ; FC on Windows start showing differences …
My  7th grader has a probability problem I am trying to write a small script for.

"If you have a spinner with three letters on on (K,V and H) and you spin it three times, list all possible outcomes."
The number of outcomes is 27. I won't list them all here, but it's along the lines of KKK, KVH, VHK, VVK, etc... you get the idea. We have them all listed out already and the HW problem is solved.

I was thinking a small perl script would be fun to write to calculate this. But it's harder then I anticipated. I created an AOA but I can't figure out how to loop through it to get every combo.

I tried a nested for loop but that's not working.

@letters = (

for ($i=0; $i<3; $i++){

        for ($j=0; $j<3; $j++){
        print "i=$i, j=$j\n";
        print $letters[$i][$j];
print "\n";

I am posting this in Python also as I could do it in python if I can get the logic right.

Our client uses a program that is written in Perl.   We are only experiencing this on one Windows 7 Pro x64 machine.  When end user selects print button from application they don't get a print dialog pop up box.   Tech support for the software showed us that an .html file is being created in c:\users\%username%\appdata\temp which to them proves that this is an issue with Windows and not their software and aren't willing to look any further into the problem.  When i double click on the .html file that gets created it opens the .html file and we get a print dialog box at that point.  The end user doesn't report any other printing issues, prints fine from Word, Chrome, etc.  
Anyone have any idea why this would be occurring?
I've tried a new user profile, disabling AV, disabling all startup items/services.    We have other Windows 7 x64 machines without this issue.
i need ideas (or a script) how to search all MAC Addresses of a windows system and pass these as parameter to an external program...with PERL.

script should do the following:
1. get all MAC-Adresses (LAN1, LAN2, WLAN,...)

2. start external programm and pass every MAC (one after another) ... possible within a loop
extProg.exe AA-AA-AA-AA-AA-AA
extProg.exe BB-BB-BB-BB-BB-BB
extProg.exe CC-CC-CC-CC-CC-CC-CC
I need a quick script that will recurse through my movie directory and print a pretty movie guide from the movies file names minus their   extensions under each sub-directory found. Oh and ignore .srt and .ass subtitles in the printout. Example:

The Shining
The Living Dead
Concerto's Cloud Advisory Services
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

I have a list something like bellow


Open in new window

I need to know the count of each duplicate pid and order numerically so

the output could look like this
pid,Pid Count

Open in new window

I thought about using a hash but as you can see the key's are not unique

Eventually I'm going to need only the pid's that have only 1 or 2 key's  like this

key,pid,Pid Count

Open in new window

Any ideas how I can achieve this?
i been trying to get the upsi to work with visual studio. could i use another language to use there web service and viusal studio the choiese are

jax ws
how do you co,pare if 2 files are the same in perl?
I have a perl app that is currently connected to a MYSQL Database, but we would like to migrate the app to a sql server database. A page in the app executes two queries, the 1st is the primary and the second  gets its filter value from the 1st. The problem i'm having is, only the last row from the 1st query being executed in the second query. For instance if the 1st query returns the following
CrsNo   |Customer  | Response
723         Bill                  Urgent
724         Ken                 Urgent
725         Bob                 Urgent

The second query should query the database for each customer number that the first query provided, however, the only query that is executed is CrsNo 725. I have confirmed this with the sql profiler. The odd thing is the same code works fine with MYSql, I only run into this issue with sql server. Below is PERL Code and sql queries.
################## First Query

my $str = "select  distinct q.CRSNo,q.CustomerName,q.ResponseAction,
                           from crs.tbl_customer q
                         where q.CustomerName = '$cname' order by q.CRSNo";
my $temp1 = $dbh->prepare("$str");

while (my @aray = $temp1->fetchrow_array)
($crsno,$crscust,$response) = @aray;

################Second Query
$str2 = "select q.DepartmentInitial,q.ReviewStatusName
                                       from crs.tbl_department as q
                                       where q.CRSNo ='$crsno'  order by q.DepartmentNo";

$#dpt = -1;
      $#dptresp = -1;
      $temp2 = $dbh->prepare("$str2");


we normally develop softwares on perl , we need a code structure like that for C++

	    $udp_src_ip{$dst_ip}{$src_ip }{src}++;
	    $udp_src_port{$dst_ip}{$src_port }{src}++;
	    $udp_dst_port{$dst_ip}{$dest_port }{src}++;
	    $udp_tos{$dst_ip}{ $tos }{src}++;
	    $udp_ttl{$dst_ip}{ ($ttl) }{src}++;
	    $udp_packet_length{$dst_ip}{ $packet_length}{src}++;
	    $udp_data{$dst_ip}{$full_data }{src}++;

Open in new window

udp_dst_ip is an hash table when ever i add sth in it , it add one to souce count
for ex.

udp_dst_ip :
udp_dst_ip :
udp_dst_ip :
udp_dst_ip :

that returns -> $udp_dst_ip{}{src} -> 2

and this are double layered hash tables :   $udp_src_ip{$dst_ip}{$ttl }{src}++;  

for ex.

udp_dst_ip :  & ttl : 115
udp_dst_ip :  & ttl : 116
udp_dst_ip :  & ttl : 117
udp_dst_ip :  & ttl : 115
udp_dst_ip :  & ttl : 115

and this time  $udp_src_ip{ }{115}{src} returns 3

is there any mechanism on C++ like that ?

We have 2 layered scalars like

values sth like that

bbb -> 15
bbb -> 17
bbb -> 14
bbb -> 15
ccc -> 16
ccc -> 16
ccc -> 14
ccc -> 13
ccc -> 16

We need to find that the maximum counts like that

bbb -> 15   (2 times)
ccc -> 16 (3 times)

should some body help us to deal with that , we are now using sth. like this but it is very slow :

	    $udp_packet_length{%udp_dst_ip}{ sprintf("0x%X", trim($packet_length))}{src}++;

				my $udp_packet_length_max=0;
				foreach $key_udp_packet_length (keys %{$udp_packet_length{$key_udp_dst_ip}} ){
					my $yeni = $udp_packet_length{$key_udp_dst_ip}{$key_udp_packet_length}{src};

Open in new window







Perl is a high-level, general-purpose, interpreted, dynamic programming languages with over 25 years of development. Perl 5 runs on over 100 platforms from portables to mainframes and is suitable for both rapid prototyping and large-scale development projects.  Perl gained widespread popularity as a Common Gateway Interface (CGI) scripting language, in part due to its regular expression and string parsing abilities. In addition to CGI, Perl is used for graphics programming, system administration, network programming, finance, bioinformatics, and other applications.