perl常用語句

2021-09-11 18:49:56 字數 861 閱讀 4146

1、第乙個perl程式:在命令列中使用 -e 選項來輸入語句,並執行該語句**

perl -e 『print 「hello world\n」』

zhl@ltt-empty:~$ perl -e 『print 「hello world\n」』

hello world

###注意print 後的雙引號「 」和單引號『 』的區別:雙引號之間可以轉義,單引號之間為字元輸出

perl -e 「print 『hello world\n』」

zhl@ltt-empty:~$ perl -e 「print 『hello world/\n』」

hello world\n

2、資料型別:

2.1標量:數值/字串/浮點數

$myfirst=123 #數字123

$mysecong=「123」 #字串123

2.2陣列:以@開頭,索引從0開始:

@arr=(1,2,3)

2.3雜湊:無序的key/value對的集合,可以使用鍵作為下標獲取值。以%開頭

%haxi=( 『a』=>1,『b』=>2);

2.4例子:

#!/usr/bin/perl

####注意每行結束用分號;

$name = 「youj」; # 字串

$salary = 1445.50; # 浮點數

print 「salary = $salary \n」;

print 「name = $name \n」;

#陣列@names = (「lizh」,「liyh」);

print 「$names[0] = $names[0]\n」;

print 「$names[1] = $names[1]\n」;

mysql常用語句 MySQL常用語句

create table student id int primary key auto increment comment 學號 name varchar 200 comment 姓名 age int comment 年齡 comment 學生資訊 修改表注釋 alter table studen...

php mysql 常用語句 mysql常用語句

一 修改mysql使用者密碼 mysql h localhost u root p 命令列登入 update user set password password 123456 where user root 二 資料庫操作 show databases 顯示資料庫 create database ...

sql常用語句

use myoa select from delete from department where departmentid 1 insert department departmentid,departmentname values 1,技術部 update department set depa...