Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17







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 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 …
Free Tool: Subnet Calculator
LVL 10
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

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
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 ?
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.


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

Hello ,

I need to write a script that reads the mark & masqueraded packets and for every 1/2 of a second it will ask to backend and reply the same answer to each question that comes from udp.
For ex.
Tsource is a counter strike packet. S.b. is making spoofed traffic of tsource , i want to masquerade this traffic to my perl module with marking packets with the destination ip. My script will see the mark and ask to the backend the answer of Tsource. and will answer this packet same for every half of second .
This samples should be given more like teamspeak TSINIT or other udp apps. Is that possible ?

If i block the tsource packet all the server is locking down , there is no logical solution like droping first packet (because the attacker sending 2 packets to server)  or blocking flood (because a companies all servers getting tsource at least once for giving game information , if i block floods for a number this time game lists are closing) . I need to find a way to build a proxy for this kind of application firewall proxies.
In my previous server I wasn't running mod_perl, but in the new environment I'm setting up I need to.  There are some fundamental differences that I need some help with.

In the current environment, I have a lib folder under the cgi-bin directory.  All of my scripts reference it relatively.  
require "lib/function.lib";

For my packages I just use:
use lib "lib";
use MyPackage;

This works really well for me for a number of reasons.  I have a dev and production environment that are completely identical and completely separate, but living on the same machine.  I can move programs from dev into production at will without having to change anything.  It's made life much easier.

However in mod_perl it doesn't seem to run in the cgi-bin directory but somewhere else entirely.  I'm not sure if it possible to get the same functionality or how to do it.  Any help would be appreciated.
I've an email field of a certain array (say $Fields[0]) that usually contains only a mail of a correct ad desired form, say:
$Fields[0] = foo.eee@desiredMail.com

sometimes this desired mail is mixed with other ones, and sometimes is absent, eg:

$Fields[0] = foo.eee@desiredMail.com --- xyz@notdesired1.com ---- abc@nodesired2.com
$Fields[0] = foo.eee@NOTdesiredMail.com

(please note that "---" is NOT a standard separator, it can varies).

I must check this situation and maintain only the desired addresses.
So I've written the following conditional statement:

if ( $Campi[0] =~ /\@desiredMail.com/) {
		$Campi[0] =~ m/^([-a-z0-9]+)\desiredMail.com$/; #keep only the @desiredMail.com address
		} else {
			$Campi[0] = "lacks mail @desiredMail.com"; #print a standard msg about the absence of @desiredMail.com

Open in new window

The line
$Campi[0] =~ m/^([-a-z0-9]+)\desiredMail.com$/; #keep only the @desiredMail.com address

Open in new window

does not return the desired result: please can you help me?
Thanks a lot,
I have this code

while (<FILE>) {
open FILE, "1.vim" || die "unable to open file:$! \n";

foreach $key (keys %columns) {  #first Hash columns
      print "$key\npattern,count\n";
     foreach $pattern (sort keys %{$columns{$key}}) { #pattern sort
             print "$pattern,$column{$key}{$pattern}\n";      

What code could I add to the end which would enable me just to have the perl script do that without opening the command window, and where do I put that code ?
I have columns of numerical data, with which I have to identify and count which numbers are present in each individual column.

so, I can have between four and twelve columns, but if it is easier just to code for four at the moment, that would be great. There is likely to be between 30 and 70 different numbers.

so if the data looked like this

123 123 165 134
134 123 165 134
165 165 165 165
243 243 245 165
245 165 245 123
234 123 165 123
123 165 165 245
134 123 165 245
165 165 123 245

I need some code which will create an output like this or similar so that I can import it into MS Excel spreadsheet.

col 1

123 2
134 2
165 2
234 1
243 1
245 1

col 2

123 4
134 0
165 4
234 1
243 1
245 0

col 3

123 1
134 0
165 6
234 0
243 0
245 2

col 4

123 2
134 2
165 2
234 0
243 0
245 3

Thankyou in advance
I want to create a vb-ish type program using perl in ubuntu.  My question: is leaning gtk+ the correct path or is there a better way to use my effort?
I have code which generates 6 random numbers in much the same was as the National Lottery does.

It creates one line of six numbers.

What I would like is to create 2000 lines of these numbers. Could someone alter the code in order to do this please ?

Is it possible, with PERL, to create random numbers in a similar way to the UK National Lottery ?

That is, is it possible to choose a first number randomly (from 59) followed by a second number (this time from 58 with the number missing being the first number) and so on until 6 numbers are chosen ?

If so, could a kind PERL expert please help me out with some code for such a thing ?

Thank you
[Webinar] Lessons on Recovering from Petya
LVL 10
[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

I am somewhat in range to creating a script to measure each line of a paragraph by a certain amount of characters, add the <br> tag (line break), create a carriage return and continue with the next word. Below is what I have so far. I included what I want to do in each line as a comment. Please help, thanks.


#!/usr/bin/perl -w

my $indChar = /./g   # any character

def (readLine)
    read line < file.txt;    # read each individual line
    foreach ($indChar);
        $myTally += 1;
        if ($myTally = 100);
            # confirm if next character is a space \s $indChar ? (\s)
                # stop;
            # confirm if next character is a letter \s $indChar ? (\w)
            # next;
I have attached a list of 2047 results for an american lottery. draw-results-1-to-2047.txt

I need to strip out only the lines with the actual draw results and do away with all the other data as per this sample file embed=file 1182640]

I know very little about PERL.
An Application running on linux executes perl scripts in the background which connects to MSSQL database running on Windows Server. In order to connect Linux server to Windows Database server Microsoft ODBC driver needs to be installed so I have installed UnixODBC  version 2.3.0.
So when I'm going to execute the perl script it throws an error (See below)

DBI connect('DRIVER={SQLServerNew};Server=GAALPA1MSGSQL02.itservices.sbc.com;Database=Faxing-Test','M36097',...) failed:

[unixODBC][Driver Manager]Can't open lib 'SQLServerNew' : file not found (SQL-01000) at ./RightFax.pl line 104.

Can you please look into the issues since last two months I'm trying to resolve however no luck.

I need help in perl script where i will be reading data from csv file and loading in to oracle database.
This is my very first experience with perl script.
 Pls help!

in Linux I'm getting below error message

    grep: support for the -P option is not compiled into this --disable-perl-regexp binary
Darwin -bash: use: command not found Why can't I use this module & why is -bash come come up?






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.