1. The use strict command means that all variables must be declared using my, and bare words must be enclosed in quotation marks.
2. Check the installed module: perldoc perllocal
Manual module installation:
Gunzip Module . Tar . GZ
Tar xvf Moudle . Tar
Go to the corresponding directory
Perl makefile . PL
Make
Make Test
Make install
3. Net: Telnet Module Instructions on CPAN. You can also search for any modules.
Http://search.cpan.org /~ Jrogers/Net-Telnet-3.03/lib/NET/telnet. PM
4. Net: Telnet usage Code
1 Use Net :: Telnet;
2
3 Print " Telnet begin connect OMC host \ n " ;
4 My $ Net_telnet = New net :: Telnet (timeout => 60 , Prompt => ' /[\ $ % #>] \ S * $/ ' );
5 If ( ! ( $ Net_telnet -> Open ( $ Host )))
6 {
7 Print ( " Err: Net: Telnet can't connect $ host \ n " );
8 Die " Can't connect: $ @ \ n " ;
9 }
10
11 If ( ! ( $ Net_telnet -> Login ( $ User , $ Pass )))
12 {
13 Print ( " Err: Net: Telnet couldn't authenticate \ n " );
14 Die " Couldn't authenticate, even with explicit username and password. \ n " ;
15 }
16 $ Net_telnet -> CMD ( " CD $ rdir " );
17
18 $ Net_telnet -> Close ;
19
5. Shift function in Perl Code
Shift Array
Shift
This function removes the first value of the array and returns it. Then, it removes the length of the array by one and moves everything along. If no element exists in the array, it returns UNDEF .
If array is omitted, the function moves in the subprocess and the lexical range of the format. @_ ;
It moves in the file range (usually the main program) @ Argv .
Sub-processes usually start by copying their parameters to the lexical variables. Shift It can be used for this purpose:
Sub Marine {
My $ Fathoms = Shift ; # Depth
My $ Fishies = Shift ; # Number of fish
My $ O2 = Shift ; # Oxygen Problems
#
}
In short, shift is moving when no array is used as the parameter. @ _ This default parameter .
This default method is often used in Perl.
6. List and array
List data can be expressed in three ways: List, array, and hash structure.
the list is the simplest expression of List data. They are just a combination of scalar values. Sometimes they use a set of parentheses to enclose a scalar. Each scalar is separated by a comma.
to store a list in a variable, an array variable is required. Arrays can be directly initialized using a list.
7. the functions of Q and QQ functions in Perl are similar to those of single quotes. QQ function is similar to double quotation marks. The main The purpose is to prevent users from using \ ' , \\ and \" can be used in strings with single double quotation marks.