Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Perl said method B if A judge     - MongoDB upgrade from 2.4.9 to 2.6.0 and PHP record of mongo extension upgrade from 1.4.5 to 1.5.1 (Database)

- Linux operating system boot manager -GRUB (Linux)

- Oracle table compression Technology Introduction (Database)

- CentOS 6.5 installation and simple configuration Nginx (Server)

- CentOS 6.x and CentOS7 install MPlayer (Linux)

- Ubuntu 14.04 set auto sleep time (Linux)

- Dialogue UNIX:! $ # @ *% (Linux)

- Installation and Configuration rsync server under CentOS 6.3 (Server)

- iOS persistence of data archiving NSKeyedArchiver (Programming)

- The direct insertion sort algorithm (Programming)

- AngularJS notes --- Scope and controller (Programming)

- Linux shell script to adjust the Task Scheduler (Linux)

- Linux system using the command line shutdown or restart (Linux)

- PPA on Ubuntu Linux installation Plank 0.8.0 (Linux)

- CentOS 6.5 upgrade to CentOS 7 (Linux)

- Firewall Configuration Red Hat Enterprise Linux 4 (Linux)

- CentOS source installation GitLab Chinese Version (Server)

- Acquaintance C ++: the most simple C ++ program (Programming)

- Java interface and inheritance (Programming)

- Linux SSH login without a password (Linux)

 
         
  Perl said method B if A judge
     
  Add Date : 2017-09-18      
         
       
         
  Perl provides another "if A then B" representation. Modifiers can be added if the general statement that the conditional expressions on the back, such as:

some_statements if condition;

In this statement, for example, if the condition is true, then execute some_statements section. Such wording identical with the following wording:

if (condition) {
  some_statements;
}

Here are some similar usage:

expression unless condition; ## similar unless (condition) {expression};
expression while condition; ## similar while (condition) {expression};
expression until condition; ## similar until (condition) {expression};

The above statements are executed first condition, it decides whether to perform genuine expression.

Modifiers must be a simple expression, not a statement block.

Although the condition determination written on the back, but it is first run.

The other two "if A then B" representation:

this && that;

this || that;

Example:

#! / Usr / bin / perl -w
@a = (97..122);
@b = ( 'a' .. 'z');
@a == @b && print ( "They are equal \ n");
@a == @b || print ( "They are not equal \ n");

Logic procedures are as follows:
Table @a equal list @b, the front part of the third statement is true, the statement following && continue output "They are equal"; fourth statement, because the front is true, the statement following the || is not executed.
Table @a is not equal to the list @b, the front part of the third statement is false, it is no longer execute the statement following &&; fourth statement, because the front is false, so it needs to execute the statement following the output "They are not equal ";
     
         
       
         
  More:      
 
- Commonly used Linux system camouflage method (Linux)
- Linux terminal program running in the background (Linux)
- How to implement large-scale distributed Yahoo depth study on the Hadoop cluster (Server)
- Define and modify strings principle in Python (Programming)
- Android project using the command to create and install the package (Programming)
- View processes and threads under Linux (Linux)
- Installation Experience open source car Automotive Grade Linux system (Linux)
- Nginx + uWSGI + Django + Python Application Architecture Deployment (Server)
- OpenSIPS offline messaging feature set (Server)
- How to install and use the Snort in Ubuntu 15.04 (Linux)
- On Android running ClojureScript (Linux)
- Use DB2 federated access Oracle (Database)
- How to force Linux users to change the initial password the first time you log in (Linux)
- Linux system security configuration Collection (Linux)
- Linux System Getting Started Learning: Repair (Linux)
- Android judgment toward camera pictures (Programming)
- SteamOS installation under Ubuntu 14.04 (Linux)
- Gnu Linux - Ubuntu System Clean-term consolidation (Linux)
- Automate deployment of Docker-based Rails applications (Server)
- IOS distributed management using GitHub project development (Linux)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.