Perl control structure condition control if while

I. Condition Determination If ( ){ } Elsif ( ){ } ... Else { } Ii. Loop: 1. While Loop While ( ){ } 2. Until Loop Until ( ){ } 3. For Loop of class C, such For ($ COUNT = 1; $ count # Statements inside the loop go here } The following is an

Perl subroutine sub

I. Definition Child Program That is, to execute a separate section of a special task Code It can reduce repeated code and make the program readable. In Perl, subroutines can appear anywhere in the program. Definition method: Sub subroutine

Perl simple variable integer floating-point string

Basically, a simple variable is a data unit, which can be a number or string.I. Integer1. IntegerThe most common simple variables in Perl are not described here because they are basically the same as other languages.Example:$ X = 12345;If (1217 + 116

Perl Chinese processing skills

Perl starts to use utf8 encoding internally to represent characters starting from 5.6. That is to say, there should be no problem in processing Chinese characters and other language characters. We only need to make good use of the encode module to

How to Use Perl Hash

1. What is Perl Hash? A hash is a data structure. Similar to an array, a hash can store a value or retrieve the value from it. However, unlike an array, its index is not a number but a name. That is to say, the index (here we call it key) is not a

Perl compares the instance code of two file strings

Requirement: Take a row in file 1 and compare it with all the data in file 2. Save the row in the same way. Otherwise, delete the row. Copy codeThe Code is as follows :#! /Usr/bin/perl # Use strict; Open (FILE1, "C:/Perl/BX/BX-Users.txt "); Open

$ A and $ B in perl

Even if the strict and warnings options are enabled, the following code does not have errors or warnings. Copy codeThe Code is as follows :#! /Usr/bin/perl Use strict; Use warnings; Sub test { $ A = 1; $ B = 2; Print $ a, "\ n "; Print $ B, "

Introduction to cgi advanced programming in perl

A routines call in CGI. pm 1. CGI. pm implements two usage methods: Object-oriented method and traditional perlmodule method.Object-Oriented Approach: Copy codeThe Code is as follows :#! /Usr/local/bin/perl-w Use CGI; # load CGI routines $ Q = CGI->

Implement a simple NIDS using perl

With the in-depth development of network security requirements, network-based intrusion detection technology has become an important and interesting research direction. The best way to learn NIDS is to write an NIDS program by yourself, in addition

Knowledge about perl references

Why use references? In perl4, the value field in the hash table can only be scalar, not list, which is inconvenient in some cases, such as the following data:Chicago, USAFrankfurt, GermanyBerlin, GermanyWashington, USAHelsinki, FinlandNew York,

Code for perl to sort m x n similar tables by Column

Operations such as csv are frequently encountered in perl processing files. Such a table is similar to a two-dimensional array, so operations on the two-dimensional array are actually performed.For such a row and column table, we often need to sort

Classic usage of Perl file reading

Open a file using the Open () function Common methods to open a file are: Copy codeThe Code is as follows: open (FH, "Or die "Couldn't open $ filename for reading: $! "; The open () function usually has two parameters. The first is the file handle,

Common usage of perl hash

Basic usage # Initialize % h as an empty array % h = {};# Use an array to initialize % h as a => 1, B => 2% h = ('A', 1, 'B', 2 );# The meaning is the same as above. It is just a more Visualized Method. % H = ('A' => 1, 'B' => 2 );# If the key is a

Perl code for replacing columns with different texts

Sometimes it is troublesome to encounter different lines or columns with different lengths. Although you can fill the file in R with the longest rows (columns), it is inconvenient, so I think of using perl to implement one.A text file of an

Perl Method for calling external command (g) awk

However, awk, a commonly used tool in linux, is naturally friendly to Column Operations. Sometimes it is more convenient and effective to call awk directly in perl than to write the corresponding perl script. For example, use system to insert an awk

Perl file operation summary

1. Open and Close files The return value of open is used to determine whether the file is successfully opened. If the file is successfully opened, a non-zero value is returned, and zero is returned if the file fails. Therefore, the following

Code for reading and writing Perl text files, renaming and deleting files, and merging multiple text files

Read files: Copy codeThe Code is as follows :#! Perl Open filetxt, "/path/a.txt"; # filetxtis the file handle and is used to establish a link with file a.txt. The file handle can be named at will, but it should not be the same as several file

Miscellaneous about perl Regular Expressions

$ Can also match \ n For more information about Perl, see page 132. Note 6. 1/^. * $/can it match "\ n? Yes! Because $ not only matches the end of a row, but also matches \ n2/^. * $/can it match "B \ n? Yes !. B matches. \ n matches $3/^. * $/can

Two sections of Perl script code (Array application and say usage)

I. Array application Copy codeThe Code is as follows :#! /Usr/bin env perl @ Zeng = 'top-B-n 1 '; Foreach (@ zeng ){ Print "$ _ \ n "; } Ii. Usage of say: automatic line feedCopy codeThe Code is as follows :#! /User/bin env perlUse 5.010; #

Introduction to special built-in variables of perl

I. Special variables of Regular Expressions 1. $ n: contains the nth substring of the last pattern match.2. $ &: String matched in the previous successful mode3. $ ': Content Before the successful substring4. $ ': content after the child string that

Total Pages: 66 1 .... 62 63 64 65 66 Go to: GO

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.