Go Premium for a chance to win a PS4. Enter to Win

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

Hello,
i need to process lots of small text files (1k to ~1M in size) millions per day.
they are syslogs files. the processing logic can be summarized in: filter out unwanted lines.
i did some tests with: cat File | grep -v bla | grep -v foo | grep -v bar > File.2
and i get huge space and clearness benefits. But the piping have some limits, after 20 not good any more :)
i'm not a day to day programmer, but kept playing around over the years.
i know/remember C,C++,Perl, some basic bash, started to learn Python some years back. i see that the fancy thing now is Go :)
do any of the language would offer a performance plus or minus, in this scenario? or the limiting factor for all will be the disk access?
Thank you for your thoughts

Ciprian
0
Concerto's Cloud Advisory Services
LVL 5
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.

Hi,

I am modifying a perl script

Here is a section

sub forgotten_password		{
print header;
print start_html( -title => $title,  -style => { 'src' => "$web_path$style" }, -onload => "document.loginform.email.focus();" );

Open in new window


I need to get rid of formatting but keep the onload function. The following seems to work, however I would like to know of a way to put the onload command on it's own line.

sub forgotten_password		{
print header ( -onload => "document.loginform.email.focus();" );

Open in new window


thanks for you help.
0
The format of input file is ( two columns in excel):

A1;A2
A1:B3
A1:C3
A2:C3
A2:D1

I'd like to get (make) something like that:

A1=>[A2,B3,C3];
A2=>[C3,D1];

No Idea ho to do it ;(
0
hi,
i wrote simple perl script and trying to run geting below error from


https://www.tutorialspoint.com/unix_terminal_online.php

sh-4.4$ vi hi.pl                                                                                                                                                                            
sh-4.4$ pwd                                                                                                                                                                                  
/home/cg/root                                                                                                                                                                                
sh-4.4$ /home/cg/root/hi.pl                                                                                                                                                                  
sh: /home/cg/root/hi.pl: Permission denied                                                                                                                                                  

i just wrote in hi.pl as
print "hii";


in command prompt of windows it ran fine once i install activevperl
https://www.activestate.com/activeperl/downloads

C:\Users\ss\perl\code>perl hello.pl
hii

please advise
0
Hi

I have a large file and I am updating it using a foreach loop with an array of data.

Is there a way to skip/unsee the listing in the array if it has been used by the update part of the foreach.

Just want to speed up the looping as it goes through the array.

Thanks

Mike
0
Hello,
an xml file contains user records like:

<user>
<account_type>EXTERNAL</account_type>
<primary_id>BRMNTN62M16A944E</primary_id>
<first_name>John</first_name>
<last_name>Doe</last_name>

...other fields...

<user_identifier>
<id_type desc="Additional">02</id_type>
<value>john.doe@mymail.com</value>
</user_identifier>

...other fields...

</user>

Open in new window

it happens that some records have the SAME <primary_id> but the <value> of the <user_identifier> of <type> 02 (see above) have a value different than "<first_name>.<last_name>@mymail.com"
is it possible individuating & suppressing all and only these <user> records?
Thanks a lot,
Fabiano
0
Hi

I have a large XML file and I need to remove the line
<INCOND NAME="A-OK" ...... />  or <OUTCOND NAME="A-OK" ...... />

in it if the line matches an entry in an Array (@LIST)


The array is @LIST with entries
A-OK
B-OK
C-OK
...

The entry from the @list could contain special characters.

There could be multiple line in the XML file with the same pattern.

I need to make it fast as possible.

Thanks

Mike
0
RT Version 3.8.7
All tickets are being submitted to the 'General' queue.
They are submitted via email and on creation the Owner is set to 'Nobody in Particular'

Is there a way to configure RT so it assigns tickets based on email address? We have 5 people in this queue.
If person1@domain.com sends an email to RT , RT should auto assign the created ticket to person1.
Same with person2, person3, etc.

I found the suggestion of creating this scrip: https://rt-wiki.bestpractical.com/wiki/AutoSetOwnerForQueue
I entered this in my RT:
my $MyUser = "bob";

my $QueueName = "general";
my $Sender = "bob@domain.com";
return 1 unless $self->TicketObj->QueueObj->Name eq $QueueName;
my $Actor = $self->TransactionObj->Creator;
return 1 if $Actor == $RT::SystemUser->id;
return 1 unless $self->TicketObj->Owner == $RT::Nobody->id;
return 1 unless $self->TransactionObj->CreatorObj->Name() =~ /$Sender/;
$RT::Logger->info("Auto assigning ticket #". $self->TicketObj->id ." to user $MyUser" );
my ($status, $msg) = $self->TicketObj->SetOwner( $MyUser );
unless( $status ) {
  $RT::Logger->warning("Impossible to assign the ticket to $MyUser: $msg");
  return undef;
}
1;

Open in new window



I put all this code under 'Custom Action Cleanup Code'

The other settings in the scrip are:

Description:      
AutoAssignOwner - Bob
Condition: On Create
Action:          User Defined
Template:   Global Template:Blank
Stage:            Transaction Create
0
Hi,

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);
$Selection->Sort(\%hash);

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

Rapha
0
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.

Thanks,
Pra
0
Concerto Cloud for Software Providers & ISVs
LVL 5
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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.

Regards,
Krishna
0
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.
0
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");

      $temp1->execute;
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");
      $temp2->execute;

0
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.
0
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.
0
Hello,

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!

-jn
0
I currently login to the time from website using the following script.


browser = webdriver.Chrome('E:/Shared Folders/Users/runnerjp/chromedriver/chromedriver.exe')
browser.get("https://www.timeform.com/horse-racing/account/sign-in?returnUrl=%2Fhorse-racing%2F") 
time.sleep(3)
username = browser.find_element_by_id("EmailAddress")
password = browser.find_element_by_id("Password")
username.send_keys("usr")
password.send_keys("pass")
login_attempt = browser.find_element_by_xpath("//input[@type='submit']")
time.sleep(3)
login_attempt.submit()

Open in new window


it works but I find using Chrome web driver is hammering my CPU. Is there an alternative code I could use that does not mean I need to physically load the page to sign in?
0
I had this question after viewing adding leading zeros and trailing zeros.

I have the following:

C  --------------                                                                                                                                                                                    
P  IMAGE PANEL                                                                                                                                                                                        
C  --------------                                                                                                                                                                                    
C                                                                                                                                                                                                    
C                                                                                                                                                                                                    
C  ALIGN BOARD RECORDS :   # I need to match this pattern                                                                                                                                                                          
C                                                           …
0
Can you please give me the unix permissions for Today In History?  I have purchased the CGI/Perl Cookbook and spoken to Craig Patchett and he told me they were in the code section, but I could not find them, as it was not listed.  I'd appreciate it very, very much!
Warmest Regards,
Matt Mattero
0
Ask an Anonymous Question!
LVL 11
Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

I work on an ubuntu Box in my company. I have limited Admin rights. I am behind firewall and proxy. cpan and cpanm not working. Need to be able to load packages and install manually on the box.
I can install on my windows personal and move the corporate box.

Can you give me directions?
0
Hello experts,
I have a perl script that does the following::
-get log files from a directory;
-zip them
-send them over smtp to a given mailbox
-redownload them from the mailbox
-crypt them using pgp
-crypted files gets pushed on ftp
-delete the original file

What i would like to do is:
-Delete the ftp sending part, instead move the files in a local given directory

Attached you will find the script.

Thank you in advance!!!!
export.pl.txt
0
I have stored all my passwords in a text file.Now i want to encrypt the text file containing password for security.my question is how to encrypt the password file so that later i can easily read passwords out of it and validate through perl
0
Hi,
I need a perl that will list down all the files in the given folder and its subfolder that are modified 'x' minute ago say (20min ago) compared to localtime or system time.Please help me out if you have any idea of how to do this because I am very much new to perl.
0
Hi

I have a script that I am executing and need to get the full value for a child.

<?xml version="1.0" encoding="ISO-8859-1"?>
<DEFTABLE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Folder.xsd">
  <SMART_FOLDER DATACENTER="DEV" CREATION_DATE="20170406" CREATION_TIME="113155" FOLDER_NAME="AAA_TEMPLATE" USED_BY_CODE="0" ADJUST_COND="N" FOLDER_ORDER_METHOD="" APPLICATION="CRITICAL" RUN_AS="DEFAULT_RUN_AS" CREATED_BY="DEFAULT_CREATED_BY" CONFIRM="0" CRITICAL="0" JOBNAME="AAA_TEMPLATE" SUB_APPLICATION="BATCH" DESCRIPTION="== Conversion Messages Start ==&#13;&#10;&#13;&#10;Message ID&#9;: INF11004 (2-5)&#13;&#10;Description&#9;: An empty RBC is added..&#13;&#10;&#13;&#10;== Conversion Messages End ==&#13;&#10;New Chain Template" TIMEFROM="" TIMETO="" PRIORITY="U7" CREATION_USER="5" PLATFORM="UNIX">
</SMART_FOLDER>
</DEFTABLE>

Code is

#!/usr/local/ActivePerl-5.20/bin/perl-static

  use XML::LibXML;
  my $filename = "$ARGV[0]";
  my $dom = XML::LibXML->load_xml(location => $filename);

  foreach my $smart_folder ($dom->findnodes('/DEFTABLE/SMART_FOLDER')) {
      print $smart_folder->getAttribute('FOLDER_NAME'), ":::";
      print $smart_folder->getAttribute('JOBNAME'), ":::";
      print $smart_folder->getAttribute('DESCRIPTION'), ":::";
      print "\n";
  }


output is

AAA_TEMPLATE:::AAA_TEMPLATE:::== Conversion Messages Start ==

Message ID      : INF11004 (2-5)
Description      : An empty RBC is added..

== …
0
Hello Experts!

I have a question regarding a Perl script that evidently has no output and I need to figure out what I'm doing wrong. I've attached some of the debug as well. Is it the line "next if int(length($data))<128;" that's causing the issue?

OS: Ubuntu Yakkety (WIN 10 is also available with Strawberry Perl)
Attached: Perl script and Sql dump I'm attempting to extract from

==Script==
##!/usr/bin/perl

use strict;
use vars qw { $FILE };

$FILE = shift;
if ($FILE eq "") {
    die "Syntax: $0 [filename]\n";
}

&parse($FILE);

sub parse {
    my($FILE) = @_;
    open(FILE, "<$FILE") || die "$FILE: $!";
    mkdir("./maptiles-output", 0755);
    while(<FILE>) {
        chomp;
        my $j = 0;
        my $contents = $_;
        next unless ($contents =~ /^INSERT /);
        my ($junk, $sql, $junk) = split(/\(|\)/, $contents);
        my ($zoom, $x, $y, $flags, $length, $data) = split(/\,/, $sql);
        $data =~ s/^X'//;
        $data =~ s/'$//;
        my $filename = "./maptiles-output/$x,$y\@$zoom.png";
        next if int(length($data))<128;
        print $filename . "\n";
        open(OUT, ">$filename") || die "$filename: $!";
        print int(length($data)) . "\n";
        while($j < length($data)) {
            my $hex = "0x" . substr($data, $j, 2);
            print OUT chr(hex($hex));
            $j += 2;
        }
        close(OUT);
    }
    close(FILE);
}

++ Debug Output (partial) ++
maptiles.sql
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.