1. Perl "Glue" enables the integration of code in various applications or languages.
Perl can write common scripts, and you can use CGI modules to write Web applications, and you can use DBI to access various databases.
In addition to this, Perl can put together various layers of applications and play more powerful functions.
2.
The front desk is a Web application, the bottom or the background is written in c,c++ or Java, using Perl can connect the two, achieve more powerful features, play their respective advantages.
Perl has two ways to implement this method:
1 directly embedded in the Perl script code written in another language, this can use Perl-related modules, simpler is inline, but slightly more powerful but slightly more complex is XS, etc.
2 The other is using Perl to call function system:
Such as:
Under Windows
Copy Code code as follows:
Use strict;
My $file = "test.txt";
System ("edit $file");
#调用dos的edit工具
System ("dir");
Wait
Another way of writing:
Qx{dir};
Capturing the returned result, you can assign the result to a scalar or an array of lists, and scalar words get the last of the resulting characters; the array words, each of the elements corresponds to each row of the result.
Such as:
Copy Code code as follows:
Use strict;
My @result =qx{dir};
My $eachline;
foreach $eachline (@result)
{
print "$eachline";
}
You can also write your own exe, which is then invoked by the system function (or QX) of Perl.
For example, you can write an EXE program that can give input parameters:
Main.c
Copy Code code as follows:
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char **argv)
int main (int argc, char *argv[])
{
int i;
for (i=0; i<argc; i++)
{
printf ("%d arg is%s", I,argv[i]);
}
return 0;
}
The main function of the program is to print out the parameters passed to the main function.
Example:
Copy Code code as follows:
#!/usr/bin/perl
Use strict;
My @result =qx{main.exe hello iam here};
My $eachline;
foreach $eachline (@result)
{
print "$eachline";
}