`

perl中的and or

    博客分类:
  • perl
 
阅读更多

perl的操作符 &&,||除了具有静态语言如java的特性外,其操作符两端还可以是任意表达式

例子1:

 sub a{
 	print "a\n";
 }
 sub b{
 	print "b\n";
 }
a||b;

 以上输出为

可以看出若无返回值则当做返回true处理

 

例子2:

 sub a{
 	print "a\n";
                return 0;
 }
 sub b{
 	print "b\n";
 }
a||b;

 

输出为

a

b

 

对于&&操作符,则有点类似,在此不举例了

 

通过使用&&,||,可以很灵活的执行一些表达式组合

分享到:
评论

相关推荐

    Perl 语言编程 第三版 作者:Larry Wall, Tom Christiansen, and Jon Orwant 译者:何伟平

    Perl语言编程,作为一门强大的文本处理和脚本编程语言,由Larry Wall、Tom Christiansen和Jon Orwant共同创作,并在第三版中得到了进一步完善。这本书是Perl学习者的宝贵资源,无论你是初学者还是有一定编程经验的...

    Perl Best Practices: Standards and Styles for Developing Maintainable Code

    Perl Best Practices author Damian Conway explains that rules, conventions, standards, and practices not only help programmers communicate and coordinate with one another, they also provide a reliable...

    EPIC - Perl Editor and IDE for Eclipse

    Whether you are into CGI scripting or full-fledged Perl projects with hundreds of modules, EPIC is the most feature-rich and extensible free Perl IDE available today, thanks to a seamless integration...

    Modern.Perl.4th.Ed

    Perl 5.16 or newer (Perl 5.20 or 5.22 preferred). Installation/upgrade instructions included. Table of Contents Chapter 1. The Perl Philosophy Chapter 2. Perl and Its Community Chapter 3. The Perl ...

    perl-5.8.8-38.el5.x86_64.rpm

    Perl is a high-level programming language with roots in C, sed, awk and shell scripting....Install this package if you want to program in Perl or enable your system to handle Perl scripts.

    Perl.Template.Toolkit

    And because it has its own simple templating language, templates can be written and edited by people who don't know Perl. In short, the Template Toolkit combines the best features of its competitors,...

    minimal_perl_for_unix_and_linux_people.pdf

    In this preface, I’ll tell you about the history of Minimal Perl and the origins of this book. THE HISTORY OF MINIMAL PERL The seeds of this book were sown many years ago, when I was building up my ...

    beginning perl for bioinformatics

    Regular expressions and finding motifs in data, Arrays, hashes, and relational databases, Regular expressions and restriction maps, Using Perl to parse PDB records, annotations in GenBank, and BLAST ...

    Expect and using Expect with PERL

    **Expect.pm** 是Perl的一个模块,它可以让你在Perl程序中使用Expect的功能。通过这个模块,可以在Perl脚本中轻松实现Expect的各种功能,比如创建进程、等待响应、发送数据等。 #### 五、具体应用场景实例 **1. ...

    Intermediate Perl.pdf

    ActivePerl from ActiveState and all other modern implementations of Perl. To use this book, you just need to be familiar with the material in Learning Perl and have the ambition to go further. ...

    Games Diversions and Perl Culture

    《Games, Diversions, and Perl Culture》一书由《The Perl Journal》的原编辑和出版人Jon Orwant编纂,这是三个精选系列中的第三部。 这本书中包含的47篇文章是关于游戏、消遣以及Perl独特文化的一些最棒的Perl...

    Perl 常用函数 初学PERL

    printf "The value is %d and the string is %s\n", 42, "Perl"; ``` 在这个例子中,`%d` 表示整数占位符,`%s` 表示字符串占位符。`printf` 函数支持多种格式化选项,如 `%c` (字符)、`%d` (十进制整数)、`%f` ...

    perl基本语法

    * 逻辑操作符:and、or、not 等 * 上下文强制符:scalar、list、hash 等 结构控制 结构控制语句是 Perl 中控制程序流程的语句。下面是 Perl 中常用的结构控制语句: * 选择语句:IF、unless、switch 等 * 循环...

    Mastering_Perl_Tk_1st_ed_2002.pdf

    This section introduces fundamental concepts related to Perl/Tk, including the relationship between Perl and Tk, and how they work together to create GUI applications. It covers the basic architecture...

    Teach Yourself Perl In 21 Days

    This book uses different typefaces to help you differentiate between Perl code and regular English, and also to help you identify important concepts. l Actual Perl code is typeset in a special ...

    周末速成课程-Perl

    Perl(Practical Extraction and Report Language,实用提取与报告语言)是由 Larry Wall 在上世纪80年代开发的一种脚本语言。起初,Perl 被设计用于生成从多种数据源提取的报告,它比当时的 awk 更加强大,能够处理...

    Beginning Perl for Bioinformatics

    Regular expressions and finding motifs in data, Arrays, hashes, and relational databases, Regular expressions and restriction maps, Using Perl to parse PDB records, annotations in GenBank, and BLAST ...

    Perl 语言编程 全面讲解Perl各个部分

    - **变量语法**:Perl 中的变量使用符号 `$`、`@` 和 `%` 来表示标量、数组和哈希。 - **单数变量**:使用 `$` 符号定义,用于存储单个值,如数字或字符串。 - **复数变量**: - **数组**:使用 `@` 符号定义,可以...

Global site tag (gtag.js) - Google Analytics