/[<">
Rumahpangkalan datatutorial mysqlperl程序设计技巧
perl程序设计技巧Jun 07, 2016 pm 03:23 PM
passperlpoeKemahiranPengaturcaraan

1. Why does POE pass parameters as array slices? http://poe.perl.org/?POE_FAQ/calling_convention 2. perl regular expression fast referecnces metacharacters are {}[]() ^ $ . | * + ? a metacharacter can be matched by putting a backslash befo

1. Why does POE pass parameters as array slices?
http://poe.perl.org/?POE_FAQ/calling_convention

2.  perl regular expression fast referecnces
metacharacters are

perl程序设计技巧{ } [ ] ( ) ^ $ . |  * + ? 

a metacharacter can be matched by putting a backslash before it
anchor metacharacters ^ and $ .
The anchor ^ means match at the beginning of the string and the anchor $ means match at the end of the string, or before a newline at the end of the string.

perl程序设计技巧"housekeeper" =~ /keeper/;          # matches
perl程序设计技巧
"housekeeper" =~ /^keeper/;        # doesn't match
perl程序设计技巧
"housekeeper" =~ /keeper$/;        # matches
perl程序设计技巧
"housekeeper " =~ /keeper$/;    # matchesperl程序设计技巧

A character class allows a set of possible characters, rather than just a single character, to match at a particular point in a regexp.Character classes are denoted by brackets [...], with the set of characters to be possiblly matched inside. Some examples:

perl程序设计技巧/cat/;      #matches 'cat'
perl程序设计技巧
/[bcr]at/;  #matches 'bat', 'cat', or 'rat'
perl程序设计技巧
/item[0123456789]/;   #matches 'item0' or ... or 'item9'
perl程序设计技巧
"abc" =~ /[cab]/;  #matches 'a'
perl程序设计技巧
/[yY][eE][sS]/ can be rewritten as /yes/i.

The 'i' stands for case-insensitive and is an example of a modifier of the matching operation.
The special characters for a character class are - ] / ^ $ (and the pattern delimiter, whatever it is). ] is special because it denotes the end of a character class. $ is special because it denotes a scalar variable. / is special because it is used in escape sequences.

perl程序设计技巧/[/]c]def/# matches ']def' or 'cdef'
perl程序设计技巧
   $x = 'bcr';
perl程序设计技巧   
/[$x]at/;   # matches 'bat', 'cat', or 'rat'
perl程序设计技巧
   /[/$x]at/;  # matches '$at' or 'xat'
perl程序设计技巧
   /[//$x]at/# matches '/at', 'bat, 'cat', or 'rat'

The specia character '-' acts as a range operator within a character class.

perl程序设计技巧/item[0-9]/;  # matches 'item0' or ... or 'item9'
perl程序设计技巧
/[0-9bx-z]aa/;  # matches '0aa', ..., '9aa',
perl程序设计技巧                    # 'baa', 'xaa', 'yaa', or 'zaa'

   /[0-9a-fA-F]/;  # matches a hexadecimal digit
   /[0-9a-zA-Z_]/# matches a "word" character,
perl程序设计技巧                    # like those in a Perl variable name

If '-' is the first or last character in a character class, it is treated as an ordinary character; [-ab], [ab-] and [a/-b] are all equivalent.
The special character ^ in the first position of a character class denotes a negated character class, which matches any characters but those in the brackets.

perl程序设计技巧    /[^a]at/;  # doesn't match 'aat' or 'at', but matches
perl程序设计技巧               # all other 'bat', 'cat, '0at', '%at', etc.

perl程序设计技巧
    /[^0-9]/;  # matches a non-numeric character
perl程序设计技巧
    /[a^]at/;  # matches 'aat' or '^at'; here '^' is ordinary

perl程序设计技巧/d matches a digit, not just [0-9] but also digits from non-roman scripts
perl程序设计技巧/
s matches a whitespace character, the set [/ /t/r/n/f] and others
perl程序设计技巧/
w matches a word character (alphanumeric or _), not just [0-9a-zA-Z_] but also digits and 
perl程序设计技巧     characters from non
-roman scripts
perl程序设计技巧/
D is a negated /d; it represents any other character than a digit, or [^/d]
perl程序设计技巧/
S is a negated /s; it represents any non-whitespace character [^/s]
perl程序设计技巧/
W is a negated /w; it represents any non-word character [^/w]
perl程序设计技巧The period 
'.' matches any character but "/n" (unless the modifier //s is in effect, as explained
perl程序设计技巧below)
.

perl程序设计技巧    //d/d:/d/d:/d/d/# matches a hh:mm:ss time format
perl程序设计技巧
    /[/d/s]/;         # matches any digit or whitespace character
perl程序设计技巧
    //w/W/w/;         # matches a word char, followed by a
perl程序设计技巧                      # non-word char, followed by a word char

perl程序设计技巧
    /..rt/;           # matches any two chars, followed by 'rt'
perl程序设计技巧
    /end/./;          # matches 'end.'
perl程序设计技巧
    /end[.]/;         # same thing, matches 'end.'

The alternation metacharacter | .To match dog or cat, we  form the
regexp dog|cat. As before, Perl will try to match the  regexp at the earliest possible point in the
string. At each  character position, Perl will first try to match the first  alternative, dog. If dog doesn't
match, Perl will then try the  next alternative, cat. If cat doesn't match either, then the  match fails and
Perl moves to the next position in the string.

perl程序设计技巧    "cats and dogs" =~ /cat|dog|bird/;  # matches "cat"
perl程序设计技巧
    "cats and dogs" =~ /dog|cat|bird/;  # matches "cat"

() is grouping metacharacter.

perl程序设计技巧    /(a|b)b/;    # matches 'ab' or 'bb'
perl程序设计技巧
    /(ac|b)b/;   # matches 'acb' or 'bb'
perl程序设计技巧
    /(^a|b)c/;   # matches 'ac' at start of string or 'bc' anywhere
perl程序设计技巧
    /(a|[bc])d/# matches 'ad', 'bd', or 'cd'
perl程序设计技巧
    /house(cat|)/;  # matches either 'housecat' or 'house'
perl程序设计技巧
    /house(cat(s|)|)/;  # matches either 'housecats' or 'housecat' or
perl程序设计技巧                        # 'house'.  Note groups can be nested.

perl程序设计技巧
    /(19|20|)/d/d/;  # match years 19xx, 20xx, or the Y2K problem, xx
perl程序设计技巧
    "20" =~ /(19|20|)/d/d/;  # matches the null alternative '()dd',
perl程序设计技巧                             # because '20dd' can't match

Kenyataan
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
提高 Python 代码可读性的五个基本技巧提高 Python 代码可读性的五个基本技巧Apr 12, 2023 pm 08:58 PM

Python 中有许多方法可以帮助我们理解代码的内部工作原理,良好的编程习惯,可以使我们的工作事半功倍!例如,我们最终可能会得到看起来很像下图中的代码。虽然不是最糟糕的,但是,我们需要扩展一些事情,例如:load_las_file 函数中的 f 和 d 代表什么?为什么我们要在 clay 函数中检查结果?这些函数需要什么类型?Floats? DataFrames?在本文中,我们将着重讨论如何通过文档、提示输入和正确的变量名称来提高应用程序/脚本的可读性的五个基本技巧。1. Comments我们可

提高Python代码可读性的五个基本技巧提高Python代码可读性的五个基本技巧Apr 11, 2023 pm 09:07 PM

译者 | 赵青窕审校 | 孙淑娟你是否经常回头看看6个月前写的代码,想知道这段代码底是怎么回事?或者从别人手上接手项目,并且不知道从哪里开始?这样的情况对开发者来说是比较常见的。Python中有许多方法可以帮助我们理解代码的内部工作方式,因此当您从头来看代码或者写代码时,应该会更容易地从停止的地方继续下去。在此我给大家举个例子,我们可能会得到如下图所示的代码。这还不是最糟糕的,但有一些事情需要我们去确认,例如:在load_las_file函数中f和d代表什么?为什么我们要在clay函数中检查结果

使用Vue.js和Perl语言开发高效的网络爬虫和数据抓取工具使用Vue.js和Perl语言开发高效的网络爬虫和数据抓取工具Jul 31, 2023 pm 06:43 PM

使用Vue.js和Perl语言开发高效的网络爬虫和数据抓取工具近年来,随着互联网的迅猛发展和数据的日益重要,网络爬虫和数据抓取工具的需求也越来越大。在这个背景下,结合Vue.js和Perl语言开发高效的网络爬虫和数据抓取工具是一种不错的选择。本文将介绍如何使用Vue.js和Perl语言开发这样一个工具,并附上相应的代码示例。一、Vue.js和Perl语言的介

使用Python和Perl构建高性能Web应用程序的最佳实践使用Python和Perl构建高性能Web应用程序的最佳实践Jun 17, 2023 am 08:09 AM

在当今数字时代,Web应用程序越来越普遍,让我们的生活更加便利和高效。Python和Perl是两种广泛使用的编程语言,它们都是构建Web应用程序的理想选择。但是,要想建立高性能的Web应用程序,需要掌握一些最佳实践,本文将介绍一些Python和Perl构建高性能Web应用程序的最佳实践。选择合适的Web框架选择一个合适的Web框架是一个设计高性能Web应用程

Python中简单易用的并行加速技巧Python中简单易用的并行加速技巧Apr 12, 2023 pm 02:25 PM

1.简介我们在日常使用Python进行各种数据计算处理任务时,若想要获得明显的计算加速效果,最简单明了的方式就是想办法将默认运行在单个进程上的任务,扩展到使用多进程或多线程的方式执行。而对于我们这些从事数据分析工作的人员而言,以最简单的方式实现等价的加速运算的效果尤为重要,从而避免将时间过多花费在编写程序上。而今天的文章费老师我就来带大家学习如何利用joblib这个非常简单易用的库中的相关功能,来快速实现并行计算加速效果。2.使用joblib进行并行计算作为一个被广泛使用的第三方Python库(

使用Vue.js和Perl语言开发系统脚本和自动化工具使用Vue.js和Perl语言开发系统脚本和自动化工具Jul 29, 2023 pm 04:57 PM

使用Vue.js和Perl语言开发系统脚本和自动化工具在当前的软件开发环境中,系统脚本和自动化工具已经成为开发人员节省时间和提高效率的重要工具。在这篇文章中,我们将介绍如何使用Vue.js和Perl语言开发系统脚本和自动化工具,并提供一些代码示例。Vue.js是一个流行的JavaScript框架,用于构建用户界面。它采用组件化的开发方式,使得开发人员可以将代

指令设计及调试过程称为什么设计指令设计及调试过程称为什么设计Jan 20, 2021 pm 03:44 PM

指令设计及调试过程称为“程序设计”。为解决某一特定问题而设计的指令序列称为程序,而程序设计是给出解决特定问题程序的过程,是软件构造活动中的重要组成部分。程序设计过程应当包括分析问题、设计算法、编写程序、测试、排错等不同阶段。

Linux下如何用Nginx作Perl程序服务器及其中Perl模块Linux下如何用Nginx作Perl程序服务器及其中Perl模块May 16, 2023 pm 11:25 PM

perl+fastcgi+nginx搭建nginx+fastcgi是php下最流行的一套环境了,那perl会不会也有fastcgi呢,当然有,今天来搭建下nginx下perl的fastcgi.性能方面也不亚于php,但是现在web程序php的流行程度perl无法比拟了,性能再好也枉然,但是部分小功能可以考虑使用perl的fastcgi来搞定.进入正题.1.准备软件环境:nginxperl:系统自带fastcgi1.2perl安装一般linux都有自带perl,可以不用安装,如果确实没有,请执行:

See all articles

Alat AI Hot

Undresser.AI Undress

Undresser.AI Undress

Apl berkuasa AI untuk mencipta foto bogel yang realistik

AI Clothes Remover

AI Clothes Remover

Alat AI dalam talian untuk mengeluarkan pakaian daripada foto.

Undress AI Tool

Undress AI Tool

Gambar buka pakaian secara percuma

Clothoff.io

Clothoff.io

Penyingkiran pakaian AI

AI Hentai Generator

AI Hentai Generator

Menjana ai hentai secara percuma.

Alat panas

PhpStorm versi Mac

PhpStorm versi Mac

Alat pembangunan bersepadu PHP profesional terkini (2018.2.1).

Dreamweaver Mac版

Dreamweaver Mac版

Alat pembangunan web visual

SecLists

SecLists

SecLists ialah rakan penguji keselamatan muktamad. Ia ialah koleksi pelbagai jenis senarai yang kerap digunakan semasa penilaian keselamatan, semuanya di satu tempat. SecLists membantu menjadikan ujian keselamatan lebih cekap dan produktif dengan menyediakan semua senarai yang mungkin diperlukan oleh penguji keselamatan dengan mudah. Jenis senarai termasuk nama pengguna, kata laluan, URL, muatan kabur, corak data sensitif, cangkerang web dan banyak lagi. Penguji hanya boleh menarik repositori ini ke mesin ujian baharu dan dia akan mempunyai akses kepada setiap jenis senarai yang dia perlukan.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) ialah aplikasi web PHP/MySQL yang sangat terdedah. Matlamat utamanya adalah untuk menjadi bantuan bagi profesional keselamatan untuk menguji kemahiran dan alatan mereka dalam persekitaran undang-undang, untuk membantu pembangun web lebih memahami proses mengamankan aplikasi web, dan untuk membantu guru/pelajar mengajar/belajar dalam persekitaran bilik darjah Aplikasi web keselamatan. Matlamat DVWA adalah untuk mempraktikkan beberapa kelemahan web yang paling biasa melalui antara muka yang mudah dan mudah, dengan pelbagai tahap kesukaran. Sila ambil perhatian bahawa perisian ini

MinGW - GNU Minimalis untuk Windows

MinGW - GNU Minimalis untuk Windows

Projek ini dalam proses untuk dipindahkan ke osdn.net/projects/mingw, anda boleh terus mengikuti kami di sana. MinGW: Port Windows asli bagi GNU Compiler Collection (GCC), perpustakaan import yang boleh diedarkan secara bebas dan fail pengepala untuk membina aplikasi Windows asli termasuk sambungan kepada masa jalan MSVC untuk menyokong fungsi C99. Semua perisian MinGW boleh dijalankan pada platform Windows 64-bit.