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'm using ubuntu 18.04 and i am trying to learn perl and get a window to appear like visual studios where i can create buttons and drop-down boxes, etc and i cannot seem to gt it installed.  i used and i cannot get their examples:ptked and ptksh to execute.  these are listed in the paragraph right above: pTk Core Concepts.  is there a better example or do you see what i'm missing?
Introduction to Web Design
LVL 13
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

I wrote a CGI in perl a long ago (never wrote perl script for ten years ;-). It is  named "check.cgi" in the www/cgi-bin directory (i.e. www/cgi-bin/check.cgi)

It starts as follows:

use strict;
use CGI;
our $mailprog        = "/usr/sbin/sendmail -t";
our $respond         = "";
our $upto            = "";
our $data            = '';
our $db              = '';

# -----------------------------------------------------------------------------
# declare base
# -----------------------------------------------------------------------------
our @token;
our $q  = new CGI;
our %in = $q->Vars;
our %gp;

# -----------------------------------------------------------------------------
# get the inputs
# -----------------------------------------------------------------------------
our $dn       =lc($in{'dn'       }) || ''         ;
our $orig     =lc($in{'orig'     }) || ''         ;
our $tld      =lc($in{'tld'      }) || ''         ;

Open in new window


Which URL should be entered to trigger it : ""  what the "...." should be ?

Thanks a lot !
I'm trying to "POST" data via jquery ajax to a back end perl script

If i change bellow method to GET it works

    <title>TODO supply a title</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
         <script src="//"></script>
           var url = "cgi-bin/,456,789&foo=bar";
           $(function() {
            url: url, 
            success: function(data, textStatus, jQxHr) {
    <div><button id="PostBtn" value="Post btn">Post btn</button></div>
    <div id="res"></div>

Open in new window

print "Content-type:text/html\n\n";

use CGI;
 my $query = CGI->new;

my @Names = $query->param;
my $list = $query->param('list');
my $foo = $query->param('foo');

<p>data $data</data>
print <<HTML;
  <h1>Hello Posts</h1>
foreach my $name (@Names)
    print "<p>" . $name . "[ " . $q->param($name) . "]</p>";  

Open in new window

How do I receive the parameters in perl?
I use ActivePerl on WIN7.
I've found a useful script for converting ANSI to UTF8 (call it

use File::Slurp;
use Encode;


open (OUT, ">c:\\dottorandiUTF8.xml");
print OUT encode('utf8', $file_con);
close OUT;

Open in new window

but I'd like to use NOT fixed paths to the file to convert (like c:\\dottorandi.xml) but the STDIN and STDOUT, so I can call the script from the command line like:

Open in new window

I've try to use:
open (OUT, <STDOUT>);

Open in new window

but without luck.
Where's my error?
what is wrong with my syntax of this short perl hash program:
#!/usr/bin/perl;                                           # ex4_3
use warnings;
use strict;
use 5.010;
my $family_name{"fred"}="flintstone";

Open in new window

~     sorry but your web site would not let me attach that file...
i'm new to perl so this is hopefully simple.  i keep getting the following error:

syntax error at /home/dwcronin/programs/ex4_1 line 7, near "$family_name{"
Execution of /home/dwcronin/programs/ex4_1 aborted due to compilation errors.

specifically. i'm trying to learn hashes by following the o'reilly book 'learning perl" by randal schwartz.

How do I truncate a string to a maximum length but at a white space?
I know substr(0,15) would work but I don't want to end in the middle of a word

the result of the code bellow should be $ShortString  = "Lorem ipsum" because the 15th character is the "l" in dolor!

In reality the length  would be 150 but it's easier to count 15 characters

Once I have $ShortString  this will form part of a URL do I need escape it?


<a href="$$ShortString>My Link</a>

my $LongString="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas fermentum, nunc in vestibulum lobortis, sapien dui aliquam risus, vitae tincidunt risus augue id dolor. Nullam.";

my $len = length($LongString);

print "Lenth of LongString = $len\n";

my $ShortString;

if ($len > 15){
    ($ShortString) = $LongString =~ m/^(.*[15])?<=\b/
    $ShortString = $LongString
print "ShortString = $ShortString\n";

Open in new window

what is the perl regular expresssion to compare "machinename\\username" in perl scripts?

sample code:
print "Hello World!\n";
$user = "test";
$mu_reg = "^(?i)$mname/\/\$user \$";
$mu_str = "164AUTH/\/\chris";

$ipstr="$mu_str ";
$ipstr_re = "^(?i)mu_reg \$"; # regex failed with two backslashes. How to fix it?
if ($ipstr !~ /$ipstr_re/) {
    print "It doesn't match\n";
else {
    print "It matches\n";
Code is here:

my $a1 = ‘a1_v’;
my $c1;
my $varName;

my $code = qq(
      \$varName = ‘a1’;
      eval(‘\$c1 = \$\$varName;’);


# I hope this line print a1_v, but print nothing
print “$c1\n”;
When we get threat intels info for hashes to be added to Trendmicro
Officescan, the MD5 or SHA1 hash value has to be entered into an
IOC Editor (we use Mandiant's ie
 to generate 2 values indicated by 1st value & 2nd value enclosed in "...'  below.

However, sometimes, the intel that comes in can be more than a hundred, so this makes
it very tedious to manually generate the values & populate into the IOC file for Officescan
to read in.  Is there an automated way / script to generate the 2 values for each hash &
auto-populate (using script etc) or an easier way for Officescan to read in just the hash
values?    Have logged a case with Trendmicro & was advised to do it manually which
does not help at all.

attached the full IOC file.

   Sample IOC file's content:
<?xml version="1.0" encoding="us-ascii"?>
<ioc xmlns:xsi="" xmlns:xsd="" id="2146113a-1513-4be6-b07e-f43969847a6a" last-modified="2018-12-02T02:19:17" xmlns="">
  <links />
    <Indicator operator="OR" id="a1c825b0-ae7f-4461-85dd-25a20720acac">          <== 1st value enclosed in "...";  once only for entire IOC file
      <IndicatorItem …
Learn Ruby Fundamentals
LVL 13
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Nagios Core 4.3.4
Nsclient 4.3
Windows 10

Just restarted my Windows 10 Desktop VM after November Updates and Nagios reports this warning on two checks

 Error: Can't locate perl510.dll

Check Windows Temp Folder WARNING 11-14-2018 22:01:47 0d 0h 32m 58s 10/10 Error: Can't locate perl510.dll

Explorer WARNING 11-14-2018 22:28:58 0d 0h 33m 34s 20/20 Error: Can't locate perl510.dll

I have the exact same checks on other Windows 10 VMs and Physical Windows 10 Desktop and they all work

I have no perl program installed on any of y computers

Searching for this dll shows nothing any where.

Any ideas?
Hi, we have a gift certificate form.  - cart is written in PERL,

In the amount window, if someone enters a dollar sign before the number, they get an error. Error: Invalid input for VALUE: $|$35|

Is there a simple way to remove the $ sign if someone enters it, as the form is submitted? Or is there another simple solution?

As an interim measure, I'll be changing the placeholder text. Thanks.
On a new RHEL 7.5 server, I'm trying to get mod_fcgid to run on a simple perl script. I had previously been using mod_perl on an older server, with no issues.  I have confirmed that fcgi_module is installed and running. Server is Apache 2.4.6.

AddHandler fcgid-script .fcgi

print "Content-Type: text/html\n\n";
print "hello world";

Error log:
[Fri Oct 12 17:33:50.655808 2018] [fcgid:warn] [pid 13551] (104)Connection reset by peer: [client] mod_fcgid: error reading data from FastCGI server
[Fri Oct 12 17:33:50.655891 2018] [core:error] [pid 13551] [client] End of script output before headers: hello.fcgi

In a file I need to have the possibility to grep a pattern in the first or in the second column.  If found the entire line is returned.
Comes with it that that pattern is a variable.

Grepping the var in the first column is easy, but I can't get it to work for the second column (sep is >).



This is what would need to be returned:


Thank you for  your help.
In my current Perl script I want to modify a string that identifies my database RAC zone cluster.  Currently using:  nslookup `hostname` to get my fully qualified hostname.  However, this is not the name I need to use for my network administration HOST string in my "tnsnames.ora" file.  So, please help me modify this string:
       An example   dbserver01.dpsn.local  -->  need this string to be  dbzonecluster.01.dpsn.local

In general I will always want to replace what comes before the first '.' character in the file with some predefined string.  Can't figure out how Perl function substr would help, or something like  $myZoneClusterName =~ s/xxxxx/yyyy/g
My plan is to automate our current Database STIG Audit process.  I want to write a short Perl script to:

   1)  Read XML STIG File (i.e.  U_Oracle_Database_12c_V1R10_Manual-xccdf.xml)
   2)  Parse out all the STIG #s, with the accompanying SQL Query Statements
   3)  Write new ascii text output to new file

Please help me with Perl file example to do this parsing?
I had this question after viewing Unix AIX compare column of 2 files.

Hi Experts,
I try to make these lines work:

while read LINE ; do
FileSystem=`echo $LINE | awk '{print $3}'`
GrowthTreshold=`echo $LINE | awk '{print $5}'`
if [ "$GrowthTreshold" -ge 0 ] 2>/dev/null  ; then
echo $GrowthTreshold
perl -ane '$k=$F[0].$F[2]; print if exists($h{$k}) && $F[3]-$h{$k}>='$GrowthTreshold'; $h{$k}=$F[3]' $file1 $file2 >>ExceptionList.txt
echo ""$FileSystem" could not be checked"
done <$file1.txt


I attach a file1.txt and a file2.txt

Values of file2.txt are compared to those of file1.txt
In this example:
- the first line is one that should be logged: 78 to 88 = 10 so that exceeds the allowed growth treshold of 5
- and also the last line: 34 to 40 = 6 so that exceeds of the allowed growth treshold of 5

When I run the script as it is now this is returned:

syntax error at -e line 1, near ">=;"
Execution of -e aborted due to compilation errors.

Thank you for your help.
I'm trying to ingest a large text file into PostgreSQL Full details here

I may need to run  a script against the file to either remove the problem rows into a separate file, or insert into the database via DBI and was wondering how perl handles diacritics?

I'm sure perls native I/O file handle is UTF8 but not certain about the diacritics or non roman characters
I need to run multiple sql queries (These are built elsewhere in the script  with no possibly why of introducing SQL injection)

Rather than writing multiple prepare /   execute statements I thought about  using a foreach loop something like bellow but I get error
Use of uninitialized value $sql in concatenation (.) or string at line 19.

Any idea how I might do this?

use strict;
use warnings;
use  DBI;
my $dbi = DBI->connect('DB Connection string', {
    PrintError =>0;
    HandleError => "OH No!"}
)or print DBI->errstr;
# built elsewhare
my $Q1 = "insert into my_table 'ABC'";
my $Q2 = "insert into my_table 'EFG'";
my $Q3 = "insert into my_table 'XYZ'";

   my $sql = $1; 
    print $sql . "\n";  # line 19
#    my $qa = $dbh->prepare($sql);
#    $qa->execute();
#    if(defined(DBI->errstr)){
 #       print DBI->errstr . "\n";
  #  }

Open in new window

Python 3 Fundamentals
LVL 13
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.


how to parse this in perl
how to compile 64 bit version of libperl.a from perl 5.28 source code on solaris.

Tried with -fPIC while configuring. But, no luck.

I am setting up the first MySQL cluster and I need to install the auto install rpm first, but that one said it depends on community server rpm first, which asking for the client to be install, but when I install the client it complain:

when installing MySQL client
so how can I get ride of that error when installing the client?

what is perl (Class::MethodMaker) ? how to install it?

I download all component from

and now the files list is:

MySQL  Cluster binary downloaded.
anything missed?
Hi experts,

Need help on how to convert a string of values in both 2nd and 3rd fields that are actually Date and Time in GMT and then calculate the difference in seconds.
Preferably using the following scripting methods:  BASH or PERL

Sample source file in CSV:  inputfile.csv


Open in new window


Required Output File: Start and End Date/Time in GMT+8, plus the Date/Time difference or Duration (in seconds) inserted as a new column (4th field)

Output CSV File:  outputfile.csv


Open in new window

I'm migrating my website to a secure server, and a certain cgi script is not being found when it is needed.  I've attached an excerpt from the server's error log, specifying what happened.  I don't know how to interpret this error log text, or how to remedy the issue.  The script which isn't being found is properly situated in the cgi-bin folder.Error-loading-SecureForm.txt

A cgi script that was functioning properly when accessed via IP address, is currently not working when accessed via domain name (now that the nameservers have propagated.)
Instead it is producing a message to open or save the cgi file.

I have checked the scripts in cgi-bin and the permissions are all correct 755.

Thanks for your help.






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