1. Basic syntax reference
Http://ind.ntou.edu.tw /~ Dada/cgi/perlsynx.htm
2. Configuration File
Http://www.itqun.net/content-detail/93521.html
Http://www.9php.com/FAQ/cxsjl/perl/2009/07/4285989147407.html
Http://blog.chinaunix.net/u/29291/showart_344126.html
[Test. pl]
Use Config :: Inifiles;
My $ Cfg = New config :: Inifiles ( - File => " Test. ini " , # Configuration File Name
- Allowcontinue => 1 , # Whether to run a parameter value in multiple rows
- Reloadwarn => 1 ,
- Nocase => 1 ); # Case Insensitive
@ Sect = $ Cfg -> Sections;
Print " @ Sect \ n " ;
$ A1 = $ Cfg -> Val ( " Section1 " , " A " );
$ B1 = $ Cfg -> Val ( " Section1 " , " B " );
Print " $ A1 $ B1 \ n " ;
$ A2 = $ Cfg -> Val ( " Section2 " , " A " );
$ B2 = $ Cfg -> Val ( " Section2 " , " B " );
@ B3 = $ Cfg -> Val ( " Section2 " , " B " );
Print " A2: $ A2 \ n \ nb2: $ B2 \ n \ nb3: @ B3 \ n " ;
[Test. INI]
code highlighting produced by actipro codehighlighter (freeware)
http://www.CodeHighlighter.com/
--> [ Section1 ]
A = 1
B = 2
[ section2 ]
A = Hello \
world
B =
Hello
world
EOT
[Output]
Section1 section2
1 2
A2: helloworld
B2: Hello
World
B3: Hello World
3. Template
Http://www.lupaworld.com/tutorial-view-aid-8885.html
[Test. pl]
Print & Template ( " Test. Template " );
Sub Template {
Local ( * File ); # Filehandle
Local ( $ File ); # File Path
Local ( $ Html ); # HTML data
$ File = $ _ [ 0 ] | Die " Template: no template file specified \ n " ;
Open (File , " <$ File " ) | Die " Template: couldn't open $ file: $! \ N " ;
While ( < File > ){ $ Html . = $ _ ;}
Close (File );
@ Contents = QW (Xiao Zhang Xiaoming );
$ Html = ~ S /\ $ ( \ W + ) \ $ / $ Contents [$ 1 - 1 ] / G;
Return $ Html ;
}
[Test. TEMPLATE]
$1 $ hello, I am$2$
[Output]
Hello, James. I'm James.
4. Regular Expression
Http://www.chinaunix.net/jh/25/159388.html
9.1 three forms of Regular Expressions
First, we should know PerlProgramRegular expressions have three forms:
Match: M/<Regexp>;/(can also be abbreviated as/<Regexp>;/, skip m)
Replace: S/<pattern >;/ <replacement> ;/
Conversion: TR/<pattern>;/<replacemnt> ;/
This articleArticleThe regular expression syntax is also explained.