1. Perl "glue", which can combine various applications or code in various languages.
Perl can write common scripts, cgi Modules can be used to write Web applications, and DBI can be used to access various databases.
In addition, Perl can stick applications of various levels together to provide more powerful functions.
2.
The front-end is a website Web application. The underlying or backend is written in C, C ++, or Java. Using Perl, you can connect the two to achieve more powerful functions, give full play to their respective advantages.
There are two ways to implement this method in Perl:
1) directly embed code written in other languages in the Perl script. This can use Perl-related modules. Inline is relatively simple, and XS is more powerful but slightly complicated.
2) Another method is to use the Perl system to call the function system:
For example:
Windows
Copy codeThe Code is as follows: use strict;
My $ file = "test.txt ";
System ("edit $ file ");
# Call the dos edit tool
System ("dir ");
.
Another method:
Qx {dir };
To capture the returned results, you can assign the results to a scalar or a list array. If the scalar is used, the final result character is the same. If the array is used, each element corresponds to each row of the result.
For example:
Copy codeThe Code is as follows: use strict;
My @ result = qx {dir };
My $ eachline;
Foreach $ eachline (@ result)
{
Print "$ eachline ";
}
You can also compile your own exe, which is then called by the perl system function (or qx.
For example, you can write an exe program that can be used to input parameters:
Main. c
Copy codeThe Code is 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 the parameters passed to the main function.
Example:Copy codeThe Code is as follows :#! /Usr/bin/perl
Use strict;
My @result?qx=main.exe hello iam here };
My $ eachline;
Foreach $ eachline (@ result)
{
Print "$ eachline ";
}