There is an instance where Perl reads a pattern from the configuration file, which has a combination of shell commands to get current information about Linux, and the entire pattern is complete after getting the return value of the shell
PI is calculated mainly by Monte Carlo method. The code is as follows:1) pi.pl: $time 1 = Time (), foreach (1..20000000) { my ($x, $y) = (rand (), Rand ()); if (sqrt ($x * * 2 + $y * * 2) The Perl script runs as follows, and the average
Using a hash as a reference is deprecated at the template Example/index.html.ep line 8Using a array as a reference is deprecated at the template Example/index.html.ep line 8It's simple because the hash and array are not used correctly.%=% $entries->{
1) Perl is very flexible, and some people say that the worst thing about reading Perl code is that a judgment condition can be placed behind a statement, for example:My $value = "value" if $needvalue;Sometimes, if the preceding statement is long and
Statement:If/unlessWhile/foreach/do. While/for1. Summary of true value of expressionAny expression has a true or false value: logical, String, list, file2.ifif (expression1) {statements;}else if (expression2) {statements;}Else{statements;}3.unless
Psl:perlstandard Library, which focuses on the built-in functions of PerlPerl modules have built-in modules and third-party modules.Perldoc perlocal View built-in modulesPerldoc module-name View Module Help informationPerldoc-m module-name View
Types and usages of Perl variablesvariable types and their uses| type | sigil | example | is a name for | | ------------+-------+-----------+----------------------------------------|| Scalar | $ | $cents
Perl Modules and Packages:Keywords related to modules:Use Module-name: Adding modulesUse Module-name qw/functionname/; #导入具体的函数Use Module-name qw//; #不导入具体函数, you need to call the function with a full pathUse Module-name {};
In this paper, we focus on the use of the Perl split function, a very useful function in Perl is the Perl split function-splitting the string and putting the segmented result into the array. This Perl split function uses the regular expression (RE)
c:\users\admin>ppm install mojoliciousdownloading mojolicious-6.08...donedownloading IO-Socket-IP-0.37 ... Doneunpacking mojolicious-6.08...doneunpacking io-socket-ip-0.37...donegenerating HTML for Mojolicious-6.08 ... Donegenerating HTML for
If It is a small program, you can use the this to:c:\rebecca\script\perl>perl-d calculate.plLoading DB routines from perl5db.pl version 1.39_10Editor support available.Enter h or ' h ' for help, or ' Perldoc perldebug ' for morehelp.Main::(Calculate.
File handleThe file handle (filehandle) is the name of the application that represents the I/O connection between the Perl process and the outside world. is not the name of the file.Open File HandleDefault file handles provided by Perl: STDIN,
1. File read-write and command-line parameters#!/usr/bin/perlUse strict;if (@ARGV Die "Usage:perl $ inputfile outfile\n";}My ($infile) = @ARGV [0];My ($outfile) = @ARGV [1];Open My $infile _fh, "," $infile "| | Die ("Can ' t Open the file!");Open My
When I went to school, I heard the saying "most of the code written by a student in the first few years of programming after graduation is spam", and I did not care about it. I have been working for more than a year now, and I feel more and more
1) The default Inc is as follows: @ INC: C:/perl/site/lib C:/perl/lib2). Set the environment variable perl5lib to add it to Inc. For example: set perl5lib = C: perllibs after perl5lib is set, % env: perl5lib = "C: perllibs" @ INC: C: perllibs
I used the Perl language a few days ago and mainly looked at regular expressions in Perl. In various web languages, regular expressions are very useful when processing strings, so here we will briefly talk about the application of regular
In Perl, you can create a subprogram (subroutine) by yourself ):
Keyword sub, subprogram name, and code block enclosed by curly brackets.
Sub marine {...}
The subprogram name is different from the scalar namespace.
Return Value of a subroutine:
#!/usr/bin/perluse strict;use warnings;#This is a practice of perl, as which shows with below perl code...codes.print "Hello, world!\n";my $animal = "camel\n";my $answer = 42;printf $animal;print "The animal is $animal\n";print "The square of
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.