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

x

Perl

26K

Solutions

10K

Contributors

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 …
0
Important Lessons on Recovering from Petya
LVL 10
Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Hi,
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 = (
['K','V','H'],
['K','V','H'],
['K','V','H'],
);

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.

Thanks!
Nacht
0
Hi,
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,...)
      = AA-AA-AA-AA-AA-AA , BB-BB-BB-BB-BB-BB , CC-CC-CC-CC-CC-CC-CC

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
0
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:

HORROR
The Shining
The Living Dead
0
I have a list something like bellow

key,pid
AAA,1
BBB,1
CCC,1
DDD,1
EEE,1
FFF,1
AAA,2
BBB,2
CCC,2
XYZ,3
AAA,4
BBB,4

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
3,1
2,3
4,2
1,6

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
XYZ,3,1
AAA,4,2
BBB,4,2

Open in new window


Any ideas how I can achieve this?
0
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

axis2
jax ws
perl
php
0
how do you co,pare if 2 files are the same in perl?
0
Hello

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

	    $udp_dst_ip{$dst_ip}{src}++;
	    $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 : 185.9.159.2
udp_dst_ip : 185.9.159.3
udp_dst_ip : 185.9.159.4
udp_dst_ip : 185.9.159.2


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

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

for ex.

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

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


is there any mechanism on C++ like that ?
0
Hello

We have 2 layered scalars like
$scalar1{scalar2}{scalar3}

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};
					if($yeni>$udp_packet_length_max){
						$udp_packet_length_max=$yeni;
						$udp_packet_length=$key_udp_packet_length;
					}
				}

Open in new window

0
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.  
ie.
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.
0
What does it mean to be "Always On"?
LVL 4
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Hello,
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,
Fabiano
0
I have this code

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

chomp()
@array=split(/\s+);
$columns{'Col1'}{$array[0]}+=1;
$columns{'Col2'}{$array[1]}+=1;
$columns{'Col3'}{$array[2]}+=1;
$columns{'Col4'}{$array[3]}+=1;
}
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 ?
0
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
0
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?
my-computer.png
0
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 ?

Thankyou
random.txt
0
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
0
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;
0
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.
EE-sample-file.txt
0
Darwin -bash: use: command not found Why can't I use this module & why is -bash come come up?
0
New benefit for Premium Members - Upgrade now!
LVL 10
New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Help - Mac Darwin Perl 5.18  -bash: use: command not found
0
I have xlc compiler version 8 and perl 5.10 running on AIX 7.1. I have been able to install DBI.pm module successfully, but now am in need to install DBD::ORACLE module. The oracle version is 12 (64bit)

perl Makefile.PL runs fine for the DBD::ORACLE module, however the "make" command is throwing below error:
I attempted to fix the issue by changing the object mode value, but that end up giving a different type of error.
Can you advise on the solution ?

#make
        rm -f blib/arch/auto/DBD/Oracle/Oracle.so
        LD_RUN_PATH="/u01/app/oracle/product/12.1.0/client_1/lib:/u01/app/oracle/product/12.1.0/client_1/rdbms/lib" ld  -bhalt:4 -G -bI:/usr/opt/perl5/lib/5.10.1
            /aix-thread-multi/CORE/perl.exp -bE:Oracle.exp -bnoentry -lpthreads -lc -lm -L/usr/local/lib Oracle.o  dbdimp.o  oci8.o /lib/crt0_64.o -bI:/usr/lib/iocp.
            exp  -o blib/arch/auto/DBD/Oracle/Oracle.so     -L/u01/app/oracle/product/12.1.0/client_1/lib/ -lclntsh -lclntshcore -lld -lm -ldl -lc -lm -lpthreads -
            lodm
            -lbsd_r -lld -lperfstat -lm -lpthreads
ld: 0711-736 ERROR: Input file /lib/crt0_64.o:
        XCOFF64 object files are not allowed in 32-bit mode.
make: The error code from the last command is 8.

#bootinfo -K
64

#ORACCENV='cc=xlc_r'; export ORACCENV

#export OBJECT_MODE=64
#make
        rm -f blib/arch/auto/DBD/Oracle/Oracle.so
        LD_RUN_PATH="/u01/app/oracle/product/12.1.0/client_1/lib:/u01/app/oracle/product/12.1.0/client_1/rdbms/lib" ld  -bhalt:4 -G …
0
I recently upgraded AIX from 6.1 to 7.1, which resulted in perl getting upgraded from 5.8 to 5.10 as well and in process i no longer have a dbi.pm module under perl 5.10.

I have been unable to find binary version for dbi.pm for perl 5.10 so i am trying to compile it but running into an issue with it.
I am using steps of running perl Makefile.PL, make, make test, make install to compile.
I am able to successfully run perl Makefile.PL from the dbi.pm directory that i saved in /tmp from cpan.org, but when i run the "make" command, i get following error.

Skip blib/lib/DBI/ProfileData.pm (unchanged)
        xlc_r -q32 -c    -D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE -qmaxmem=-1 -qnoansialias -DUSE_NATIVE_DLOPEN -DNEED_PTHREAD_INIT -qlanglvl=extended -I/usr/local/include -q32 -D_LARGE_FILES -qlonglong -O    -DVERSION=\"1.636\"  -DXS_VERSION=\"1.636\"  "-I/usr/opt/perl5/lib/5.10.1/aix-thread-multi/CORE"   Perl.c
/bin/sh: xlc_r:  not found
make: The error code from the last command is 127.

I do have xlc compiler installed.
  vac.C                      8.0.0.0  COMMITTED  IBM XL C Compiler
  vac.C                      8.0.0.0  COMMITTED  IBM XL C Compiler
  vacpp.cmp.core             8.0.0.0  COMMITTED  IBM XL C/C++ Compiler
  vacpp.cmp.core             8.0.0.0  COMMITTED  IBM XL C/C++ Compiler
  xlC.aix61.rte             12.1.0.3  COMMITTED  IBM XL C++ Runtime for AIX 6.1

/usr/vacpp/bin/xlC -qversion
IBM XL C/C++ Enterprise Edition V8.0 for AIX
Version: …
0
Hello

I have list of data

345 654 345 432 236
345 654 345 432 236
345 654 345 432 236
654 345 345 432 236
654 345 345 432 236
654 345 345 432 236
710 654 345 345 436
710 654 345 345 432
710 654 345 345 433
710 654 345 345 433
710 654 345 345 433

through which I need to find repeat entries row on row, over about one million rows.

Manually I have to take the first row and check for a repeat of any of the values of that row with the next row. If there are any repeat values, then I have to mark down how many. Then I move onto the next row and repeat the process.

I then have to tally how many rows had whatever number of repeated values.

so the out put would look like

4
4
4
0
2
2
3
3
4
4
(for each row)

total

0 values were repeated on 1 rows
2  values were repeated on 2 rows
3   values were repeated on 3 rows
4   values were repeated on 5 rows

Could someone help me for code with this, output to a VIM file please ?
0
** I know very little about perl

Could someone help me please, with code which will count how many rows of data that start with the same number.

for example, my data list is about 1 million rows

345 654 345 432 236
345 654 345 432 236
345 654 345 432 236
654 345 345 432 236
654 345 345 432 236
654 345 345 432 236
710 654 345 345 436
710 654 345 345 432
710 654 345 345 433
710 654 345 345 433
710 654 345 345 433

I need to count how many rows are present by the first number, so referring to the above set

345   3
654   3
710   5

With the out put to a file

The numbers vary a fair bit.

Thankyou
0
Hi Experts,

Im trying to convert a series of scripts that we use internally to a vb.net applicaiton with a GUI that can be passed on to the BAU teams. Unfortunately my knowledg around encryption is pretty non existant.

Would anyone be so kind as to explain to me how to convert the below perl to VB.NET? Or at least point me in the correct direction as far as namespaces etc are concerned?

use DBI;
use strict;
use warnings;
use Crypt::CBC;
use MIME::Base64;
use Encode;
use Digest::MD5 qw(md5_hex);
use warnings;


my $encrypted = <FILE>;

my $iv  = '0000000000000000';
my $utf_decoded = encode_utf8($iv);
my $key = "854EE3617FDDA2D3";


#create Cipher based on AES
my $cipher = Crypt::CBC->new(
				-key => $key,
				-literal_key => 1,
				-iv => pack('H32',$utf_decoded),
				-header => 'none',
				-padding => 'standard',
				-blocksize => 16,
				-keysize => 16,
               -cipher => "OpenSSL::AES"
);

my @dec = decode_base64($encrypted);
my $count = 0;

foreach my $entry (@dec) {
	my $temp = $cipher->decrypt($entry);
	$temp =~ s/[\x0D]//g; 
	$count++;
	print "$temp";
}

exit();

Open in new window



Here is what i have so far.... not going so great.

Public Function AES_Decrypt(ByVal input As String)

Dim KeyStr As String = "854EE3617FDDA2D3"
        Dim IVstr As String = "0000000000000000"
        

        Dim IV(15) As Byte
        For I = 0 To 15
            IV(I) = IVstr.Substring(I, 1)
        Next

        Dim AES As New RijndaelManaged
        Dim Hash_AES 

Open in new window

0

Perl

26K

Solutions

10K

Contributors

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.