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

How do I execute the perl script file using the cfx_exec tag.

I have a perl script file c:\temp\testperl.pl. The perl script opens the word and updates the text in the word and closes it.

<cfx_exec cmd ="c:\perl64\bin\perl.exe">

How do I call the perl script using cfx_exec tag.

Thanks.
0
I am using Mail::DKIM Verifier tool. I am having problems verifying the DKIM signature. The BH is correct, however the B= part of the signature seems to not be validating. Does anyone know how to get the Perl Script to output what the signature is supposed to be vs what it is?
0
I want to use awstats with weblogic logs


This is the log

#Fields:        c-ip date time cs-method cs-uri sc-status bytes time-taken
#Software:      WebLogic
#Start-Date:    2019-10-23      00:00:06
192.168.112.140 2019-10-23      00:00:07        POST    /es.finconsum.arq.webservices.natural/services/WSBCPCFINCConsultaScoringProactivo        200     4565    5.366

Open in new window



format extended and extended logging format fields: c-ip date time cs-method cs-uri sc-status bytes time-taken

in /etc/awstats/awstats10.weblogic_ccf_lpfcashwlg0.conf I configure
LogFile="bzip2 -dc /var/log/awstats/caixabank/lpfcashwlg0/*.bz2 |"
LogFormat = %host %time2 %method %cs-uri %code %bytesd %other

Open in new window



And when I execute  /var/awstats/wwwroot/cgi-bin/awstats10.pl -config=weblogic_ccf_lpfcashwlg0 -databasebreak=day -update -showcorrupted it resolves all lines as corrupted


Corrupted record line 216523 (record format does not match LogFormat parameter): 192.168.112.140        2019-10-22       23:59:59        POST    /es.finconsum.arq.webservices.natural/services/WSBACCFINCConsultaDatosCliente   200      3991    5.743
Jumped lines in file: 0
Parsed lines in file: 216523
 Found 1 dropped records,
 Found 216522 corrupted records,
 Found 0 old records,
 Found 0 new qualified records.

Open in new window



Can you help me? I don´t find where is the error

If you need any other data please request it
0
I have this code here.

no information seems to be passed to @match and @nomatch. I have attached the input test file. Could someone help me determine why no information is being passed to these arrays ?
(information passes from @array fine)


open(INPUT, "<C:/Users/mickg/Desktop/Lessons/arrays/input.txt");

my $line = 1;
my @array = 1..6;

while(<INPUT>)
{
      my $text = added;
      print WRITE "my array: @array \n\n";
      print "$line\t $text \t $_ \n";
      print WRITE "$line\t $text \t $_ \n";
      $line += 1;
      my @match = grep { $_ eq $lines[5] } @lines[0..4];
      my @nomatch = grep {$_ ne $lines[5] } @lines[0..4];
      print WRITE "all matching numbers : @nomatch \n\n";
      shift @lines;
}
print WRITE "all matching numbers : @nomatch \n\n";
close (INPUT);
input.txt
0
I have a perl script that is doing a REST call to a server .  The REST call is working as designed.  I now have to enforce TLS 1.2 for that REST API call in the perl script but I do not know what I have to modify.  Any help would be appreciated.

I have until 10/30/2019 to fix as the server receiving the REST call will begin to refuse TLS 1.0 connections.
0
have a rename oneliner, but I cant seem to get it to work

my contents look like this:, but mass quantity

100.10.in-addr.arpa
11.5.10.in-addr.arpa

I need them all to have a .db at the end so

11.5.10.in-addr.arpa.db
100.10.in-addr.arpa.db

I have this string that I use to echo the change to screen to make sure I like it, but it does not work right, I cant seem to get it to add the.db


for i in `ls`; do newname=`echo $i | sed 's/.arpa//'`; echo mv $i $newname; done

Open in new window


Then i used this one to change it

for i in `ls`; do newname=`echo $i | sed 's/.arpa//'`; mv $i $newname; done

Open in new window


can someone please help me mod this please.
0
Please bare with me, I have never used Perl in my life and I'm attempting to modify an existing script from previous worker. Any help is much appreciated.

I have a perl script that loops through Cisco Switches / Routers and can run commands. I want to log all output and "show" commands to a log file. For example:

# create log files
open STDOUT, '>', "test.txt";
open STDERR, '>', "test-errors.txt";

# Enable Mode
@out = $session->enable($password); 

$session->cmd("show run int Gi1/0/1\n");
$session->cmd("show run int vlan 1\n");
$session->cmd("show int status | inc something-here\n");

Open in new window


This is just an example but I'm having trouble outputting it all to a text file. I've attempted to put something like this:

print $session->cmd("show run int Gi1/0/1\n");
print $session->cmd("show run int vlan 1\n");
print $session->cmd("show int status | inc something-here\n");

Open in new window


But doesn't work as expected.

Any help is much appreciated thank you
0
Is there an easy way to set up shortcuts using your own domain (but not break or involve the existing website)?

Say the domain is mydomain.com.  People currently can type mydomain.com or www.mydomain.com and it goes to the website.

I'd like to be able to set up shortcuts / redirects so  something like time.mydomain.com would redirect to a specific website (in this case, maybe www.time.gov).

This is for someone else.  A long time ago I found a perl script that I put on my website, called it index.cgi, and it had this info:

#!/usr/local/bin/perl       
$mainpage       = "index.html";
%domains = (      
'www.mydomain.com'          =>  'https://www.mydomain.com',      
      
#enter shortcuts here      
'time.mydomain.com'         =>  'http://www.time.gov',


#end of shortucts

'www.mydomain.com'          =>  'http://www.mydomain.com/index.html'      
      
);      
$server = lc($ENV{'HTTP_HOST'});if ($ENV{'HTTP_HOST'} =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/){$t='/'}else{if ($server !~ /^www./){$server = '' . $server;}}@domains = keys(%domains);foreach $domain(@domains){if ($domain eq $server){print "Location: $domains{$server}\n\n";$match="yes";last;exit}}unless($match){print "Location:  https://www.mydomain.com/index.html\n\n";exit}exit;      
      
 
That does what I'm asking about - enter loads of shortcuts and you can enter that subdomain and it takes you to the appropriate webpage.

Are there other ways via the DNS zone record or something else?  

Are there simpler ways to do this redirect of …
0
I have a list of over 800 server 2008 (some std, some R2, some enterprise). I need a script that can run either on my workstation or on a server in the environment that logs in to each server in the list, retrieves all successful logins (whis usernames and dates) and save those logins either to one large spreadsheet or to individual csv files that can later be imported into a spreadsheet.

I have yet to see a script or app for this that actually works. I do have a ps script that has to be uploaded to each server one at a time then run then manually retrieve the data but I just don't have enough time to do that kind of thing with over 800 servers.

An app or script (vb, ps, perl, whatever) that does this and runs from one location would be great. Help please!!!
1
Hi all,

 How to compare string within an array? That string contains backslashes, colon and paranthesis.

sample program:

use strict;
use warnings;

sub perl_func {
    my ($z, $x) = @_;

    print "\n";
    print "z: $z\n\n";
   
    my @lx=@$x;
    foreach my $tx (@lx)
    {
       
        if ($z !~ m|$tx|)
        {
            print "$z !~ $tx\n";
        }
        else
        {
            print "$z == $tx\n";
            return 1;
        }
    }
   
    print "\n";
    return 0;
   

}

#my @x = ("One", "Two", "Three", "Four", "Five");
#my $z = "Four";
#works fine for above x & z

my @x = ("One\\OnesPosition:Num (NumPerl)", "Two\\TensPosition:Num (NumPerl)", "Three\\HundresPosition:Num (NumPerl)", "Four\\ThosandsPosition:Num (NumPerl)", "Five\\TenThousPosition:Num (NumPerl)");
my $z = "Four\\ThosandsPosition:Num (NumPerl)";


if(perl_func($z, \@x))
{
    print "\nfound element\n";
}
else
{
    print "\nnot found element\n";
}
0
Hi

I have a Perl question.

I have an input that is "x                               "   it is 23 characters and I will get a number to adjust the x character back or forward with in the 23 character field.

Example

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
X

I might get -4 which means I need to adjust back 4 and would make it

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
                                                                                    X


The problem is I am not sure how to program this.

I could get +5 or -10

Any help would be appreciated

Thanks

Mike
0
Hi Everyone

I have a perl script and I have an array and am using a foreach and am looping many times to update an XML file.
There are 2 foreach loops in the script. The outer loop is the data and the inner is searching the XML file to add the data to the specific node.
I'm using the XML::LibXML to search and add.

My question is:

Once I use the element in the array I want to get rid of it to make the foreach loop execute faster as the array would decrease in size.

The program now runs 3 hours. It would be good to speed it up.

Is there an easy way to do this?

Thanks for the help

Mike
0
Hello
I changed the top of the page from guestbook.html, addguest.html and guestlog.html
     <?xml version="1.0" encoding="iso-8859-1"?>  to   <?xml version="1.0" encoding="utf-8"?>
And also add
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
But some garbage value appears on the screen instead of Urdu ( Pakistani Language) .
Then I changed all encoding="iso-8859-1   to   encoding="utf-8" in guestbook.pl but same garbage value appears on the screen instead of Urdu.
nms-guestbook is very attractive and I want to use it, so please help me.

 kindly check this link http://www.punjabiandpunjab.com/guestbook.html
Thanks
0
Yesterday I installed FreeBSD on a virtual machine with some web tools to use as a hobby webserver.
My project includes perl scripts, but when I try to run them in my browser a get the whole script shown as a text, instead of getting executed as a program.
So I did some digging and found that I had to do some CGI configuration. So I added the line AddHandler cgi-script .pl to /usr/local/etc/apache24/httpd.conf, and I added the line Options ExecCGI to the apache server directives. I fiddled around with this for hours and still can't get it to work. What am I doing wrong?
I am using a web interface for the server called webmin, if that could be of importance.

Thank you for helping!
1
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
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
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
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
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

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.

Top Experts In
Perl
<
Monthly
>