Can be done using find with sed or perl.
To find the current directory,
The code is as follows
Copy Code
Replace into
The code is as follows
Copy Code
Find./-type f-exec sed-i "S//
When you create an array in Perl, you can use the QW.
But there is a problem, if you want to create an array of 20 names, and everyone's name is this form of "Join Smith" "Harry Potter" which means that each name contains both a surname and a name.
Requirements: Take a row in file 1, compare all the data in file 2, save the same, or delete.
Copy Code code as follows:
#!/usr/bin/perl
#use Strict;
Open (FILE1, "c:/perl/bx/bx-users.txt");
Open (FILE2,
Copy Code code as follows:
#!/usr/bin/perl
#use Strict;
Open (FILE1, "c:/perl/bx/bx-users.csv");
Open (FILE2, "c:/perl/bx/bx-books.csv");
Open (FILE3, "c:/perl/bx/bx-book-ratings.csv");
Open (RESULT1, ">c:/perl/bx/bx-users.txt");
The normal subscript operation in the Perl array must be familiar to everyone, not to be explained here.What this article is trying to say is that the majority of the subscript in the Perl array can be used to greatly facilitate the operation of the
Open the file with the open () function
The common ways to open files are:
Copy Code code as follows:
Open (FH, "Or die "couldn ' t open $filename for reading: $!";
The open () function usually comes with two arguments, the
1, single line (large file processing):
Copy Code code as follows:
My $oneline = or
while ($line =)
{ }
2, read all (small file processing):
Copy Code code as follows:
Open (My $in, "path") or Die
perl| Access | data | The database is not just vb.net,c#. Microsoft's development software can invoke the. NET Framework, as far as I know, at least 28 of the development languages I knew how to invoke. Net Framework. Let me give you a case of using
1. Intelligent matching operatorAlternative binding operators:Find a key in the hash: The comparison of two arrays is exactly the same: Find out if an element exists in the list: The smart match operator is independent of order. ~ ~ Around
In PerlProgram, Read the following line of CCode:
Printf ("% d", number );
Save it to the variable $ line and output it to the file handle $ out. What are the differences between the following two methods?
1) printf $ out $ line;
2) printf $
Regular Expressions in Perl
1. It is a wildcard and can match any single character, except for line breaks. If you want to use. In the mode, use /.
2. * match the first item zero or multiple times, such as/AB * C/match AC, ABC, abbbbbc...
3. +
There are three types: system, exec, ''(unquoted ).
1. System: After the command is executed, run the Perl script and output it to stdout.
2. Exec: Once you execute this command, Perl will exit and output it to stdout.
3. (My $ output =) '':
1. chdir change the working directory... chdir "/etc" or die "cannot chdir to/etc: $! "; If the parameter is null, change it to the main directory.
2. My @ all_files = glob "*"; my @ bz_file = glob "*. bz2"; only
3. My @ all_files = ; my $ dir =
Time conversion is inevitable when you use Perl for script development. The following example shows how to convert the system time to the Standard Time:
#! /Usr/bin/perlUse strict;Use dBi;
$ | = 1;
My $ username = "root ";My $ Password = "123456
If you use vs to use C #, you should know that there is an automatic attribute, which is similar
public int MyProperty { get; set; }
It automatically generates get/set methods for you and binds these methods to this property. It is easy to say that
We often use a program in Linux to add parameters. Now let's take a look at the functions related to control parameters in Perl. getopt. in Linux, there are two types of parameters. one is-help and the other is-H. that is, the difference between-and.
I am sorry to send a personal advertisement here. If you are interested, you can view it:Http://www.wachnew.com
#! /Usr/bin/perl-W
$ Family_name {"Fred"} = "flinkstone"; # assign a value to the hash key$ Family_name {"Barney"} = "rubble ";
Foreach
File: whox. pl;Function: lists who is on the system. If the same user has logged on to the group multiple times;Description: lists the user logon times, virtual terminal numbers used, and corresponding IP addresses;Advantage: it is more intuitive
The first Perl script was written by a colleague. After this function is implemented in Java, no exception is thrown out in the middle. After Perl is used, it is normal.
My colleagues helped me write the code. I modified and debugged it myself, so I
Shell: an interface that directly interacts with the Linux kernel. It is relatively basic and used to process basic and simple tasks, such as batch processing.Perl: it is more complex and powerful than shell, and has a powerful regular expression
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service