Perl

25K

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 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
On Demand Webinar: Networking for the Cloud Era
LVL 9
On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

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 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
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
Free Tool: Site Down Detector
LVL 9
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Im runinnig a linux server
although my qmail queu was very quite I was listed in more than 10 blacklist sites for sending spams. then from my tcpdump I saw that there is hundreds of perl processes owned by apache  user making thousands of smtp connection. however I could not locate this perl script.
is there a way to find the full path of what this perl is runinnig?
0
I have a file with a character that translates into 272 when I do:
od -xc

The character looks like an A with a caret on top with a degree sign to the right. I am attaching an image of the character as well. I have tried sed, perl and tr and none of them are working.

For example:
sed -e 's/'$(echo "272")'/ /g' input_file > output_file

This does not work.

Any suggestions?
Image.jpg
0
I am new to perl and need some help in doing the following:

I have the following:
#P 0.725 22.425
#P 17.275 22.175
#P 17.275 1.575
#P 0.725 1.575

I need to add a leading zero for numbers that are less than two digits before the DOT  and add trailing zeros to the number to add a total of six digits after the DOT. Output should look like the following:

#P 00.7250 22.4250
#P 17.2750 22.1750
#P 17.2750 01.5750
#P 00.7250 01.575 0
Thanks for helping
0
I need an example of Perl using sqlite3 for a database in Memory and then writing it to disk afterwards. Later reading it from disk to convert it to in memory
0
"Search Time": "2017-05-08 15:03:20.561",

my $t = Time::Piece->strptime($searchTime, "%Y-%m-%d %H:%M:%S");

I get an error saying
garbage at end of string in strptime: .124 at C:/Perl64/lib/Time/Piece.pm line 481

I am using ActivePerl in Windows. There are packages that I could not install like Time-modules. Actually, I am having so many issues with new packages to install. I need a solution that might not require specific packages as I can get stuck.

perl -v

This is perl 5, version 24, subversion 1 (v5.24.1) built for MSWin32-x64-multi-thread
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2017, Larry Wall
0
I just got EE's help to make copies of an svg file with Perl.  How do I make inkscape automatically open an svg file when I double click it?
array.txt
0
I declared an array in perl using the "strict" and "warnings" pragmas.  I annoyingly had to explicitly declare EACH member of the array because I didn't see any pattern in the cemetery lot numbers.  Around element 102 I added a fake value for a lot number (it's clearly marked) just to declare the element.  If I comment or uncomment this line Ige "undeclared variable" warnings.  I'm getting confused.  I think the code is almost there but I'm missing something.
arrays.txt
0
is there a macro that would delete row 2 in every file in a windows folder? these are CSV files - so i suppose i will need to convert them all to excel as well.
0
I would like to have a PERL Script that executes the following

The universe that this is updating is about 144 million rows.

UPDATE APR2017_v2 AS T1 INNER JOIN ESEQUENCE_03062017 AS T2 ON T1.ID16 = T2.ID16 SET T1.ESequence = T2.sequence, T1.EMatchLevel = T2.match_code WHERE T1.ESequence IS NULL AND T1.ZIP5 BETWEEN '01000' AND '99499'

We could perhaps change the
...T1.ZIP5 BETWEEN '01000' AND '99499'
to a
"T1.ZIP5 = '01000'
and then up tick the ZIP one chunk at a time. Or even do something like
T1.ZIP5 BETWEEN '01000' AND '06999'
and then have it move up to the next chunk like this
T1.ZIP5 BETWEEN '07000' AND '12999'
(by 5000 at a time) So it is only updating a portion at a time.
0
Free Tool: Subnet Calculator
LVL 9
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.

I have never messed with PERL but understand it is probably what I want to be using to import due to the file sizes I am dealing with.

Environment : Linux MariaDB server.

I have 7 data files of roughly 24 million rows each.

Normally I am importing these via SSH mysql command after I move the ".csv" files over to the server running the following command for each file.

LOAD DATA LOCAL INFILE '/home/APR17/20161003_FULL FILE_01.csv' INTO TABLE FD_MASTER FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n' IGNORE 1 LINES;

Open in new window


Then I run this query to code the batch that got loaded.

UPDATE FD_MASTER
SET LoadInputFile = '01'
WHERE LoadInputFile IS NULL

Open in new window


So my question is how do I create a PERL script that will load each of the 7 files one at a time, and in between each load run the Update Query.

It would be nice if it at the end provided a simple report of what it did including how long each segment took to load.

After this there are a series of queries that I also run on that Master file which I would like to also add to this process, but those can wait.
0
I have a file with times in it.
Example:  Time = 05:02:22.
I want to know how to replace that time using the variables hours, min, sec using perl/regex.
(those variables will have updated times potentially in them).
0
I am trying to take the advice of fishmonger (make my code use an array)
Even though I'm slowed because I forgot alot of vi, here are my:
1) Perl script
2) screen copy of error screen when I use my alias "'r" to run "perl array.pl"
arrays.txt
octalPic.png
0
Can someone explain the following Perl invokation of unlink, and how do I expand to also do files withing multiple sub-direcories.
0
Hi
We used to use CentOS 5 with Sendmail, MailScanner and Sophos SAVI (Perl module) to scan mail virus.
As EOL of CentOS 5, I build the mail server on CentOS 7 instead.

My MailScanner doesn't work with SAVI mode (use less CPU resource), just work with Sophos mode (user more CPU resource).

I have complied the SAVI-Perl-0.30 and the after "make" the SAVI.so has been deployed to /usr/local/lib64/perl5/auto/SAVI/SAVI.so.

I set "Virus Scanners = sophossavi" in MailScanner.conf, let it make use SAVI module.
However I got the following error in maillog, keep saying "SAVI Perl module not found"

Apr 20 15:07:56 myserver MailScanner[5266]: MailScanner E-Mail Virus Scanner version 4.85.2 starting...
Apr 20 15:07:56 myserver MailScanner[5266]: Reading configuration file /etc/MailScanner/MailScanner.conf
Apr 20 15:07:56 myserver MailScanner[5266]: Reading configuration file /etc/MailScanner/conf.d/README
Apr 20 15:07:56 myserver MailScanner[5266]: Using SpamAssassin results cache
Apr 20 15:07:56 myserver MailScanner[5266]: Connected to SpamAssassin cache database
Apr 20 15:07:56 myserver MailScanner[5266]: Enabling SpamAssassin auto-whitelist functionality...
Apr 20 15:07:58 myserver MailScanner[5266]: SAVI Perl module not found, did you install it?

If I set  "Virus Scanners = sophos" in MailScanner.conf, it works, but use a lot of CPU and performance is not good.

In the MailScanner.conf, seems no conf to tell the …
0
I have 2 files that I need to compare and merge. File1 has 3 fields: device_name, status, days_in_cur_status. File1 is the "master status" file.

File2 has 2 fields: device_name, status. File2 is the file produced from checking the current status.

- File1 -
deviceA available 10
deviceB available 8
deviceC unavailable 3

- File2 -
deviceA available
deviceB unavailable
deviceC available
deviceD available

After comparing/merging the files I'd like to produce File3 which should look like:

deviceA available 11
deviceB unavailable 0
deviceC available 0
deviceD available 0

I can't figure out how to open both files and compare a line in file1 to each line in file2. I began by reading both files into an array and then iterating through the arrays, but that's not working. I'd be glad to post the code, but I'm pretty sure that having to read thru file 2 once for each line in file 1 is, well, dumb.

Help?

Thanks,
Steve
0

Perl

25K

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.