I. Data Types(Data type):
Perl has four data types: Scalar (variable), Scalar Array (Array), Hash Array (Hash), and References (pointer ), it seems to be rare, but it is more than enough to use it. Especially when writing Perl programs, you do not
one. DataType (data type ):Perl's data types are roughly four: Scalar (variables), Scalar Array (array), hash array (hash), References (pointer), but they seem to be small but more than sufficient. In particular, you can write a Perl program without
Built-in variable $_:Let's take a look at an example:
Copy Code code as follows:
#!/usr/bin/perl-w
@array = QW (a b c d);
foreach (@array) {
Print $_, "";
}
The role of an example is to define an array and print out the
Often encounter downloaded files or e-books, the name contains a number of web site information, the actual use because the name is too long inconvenient, the following script uses regular expressions to rename all the files under the directory:For
The Perl script batchreplace.pl can be used to bulk replace the text/code in the file. You can find files of the specified type in the specified directory and recursively check subdirectories, and copy the directory structure of the input file when
I. file input/output functions
1. Basic I/O functions
Open: Allow programs to access files
Close: Terminate File Access
Print: file write string
Write: Write the formatting information to the file.
Printf: format the string and output it to the
The Perl script batchReplace. pl can be used to replace text/code in files in batches. You can search for files of the specified type in the specified directory and recursively check the subdirectories. Copy the directory structure of the input file
In Perl, The chdir function is used to change the current working directory to the specified directory. If no directory is specified, it goes to the user's main directory. This function calls the CD command in UNIX to switch directories. Here is a
Environment for WinDOS, two points to note:
1, the default ActivePerl under the code is GBK, so you need to convert the string to GBK will not display garbled2, to traverse the file directory, you need to exclude a special directory.
Complete code:
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.