Learning Perl, 6th Edition

Chapter 1 : Introduction

Questions and Answers
What Does “Perl” Stand For?
How Can I Get Perl?
How Do I Make a Perl Program?
A Whirlwind Tour of Perl
Exercises

Chapter 2 : Scalar Data

Numbers
Strings
Perl’s Built-in Warnings
Scalar Variables
Output with print
The if Control Structure
Getting User Input
The chomp Operator
The while Control Structure
The undef Value
The defined Function
Exercises

Chapter 3 : Lists and Arrays

Accessing Elements of an Array
Special Array Indices
List Literals
List Assignment
Interpolating Arrays into Strings
The foreach Control Structure
Scalar and List Context
in List Context
Exercises

Chapter 4 : Subroutines

Defining a Subroutine
Invoking a Subroutine
Return Values
Arguments
Private Variables in Subroutines
Variable-Length Parameter Lists
Notes on Lexical (my) Variables
The use strict Pragma
The return Operator
Non-Scalar Return Values
Persistent, Private Variables
Exercises

Chapter 5 : Input and Output

Input from Standard Input
Input from the Diamond Operator
The Invocation Arguments
Output to Standard Output
Formatted Output with printf
Filehandles
Opening a Filehandle
Fatal Errors with die
Using Filehandles
Reopening a Standard Filehandle
Output with say
Filehandles in a Scalar
Exercises

Chapter 6 : Hashes

What Is a Hash?
Hash Element Access
Hash Functions
Typical Use of a Hash
The %ENV hash
Exercises

Chapter 7 : In the World of Regular Expressions

What Are Regular Expressions?
Using Simple Patterns
Character Classes
Exercises

Chapter 8 : Matching with Regular Expressions

Matches with m//
Match Modifiers
Anchors
The Binding Operator =~
Interpolating into Patterns
The Match Variables
General Quantifiers
Precedence
A Pattern Test Program
Exercises

Chapter 9 : Processing Text with Regular Expressions

Substitutions with s///
The split Operator
The join Function
m// in List Context
More Powerful Regular Expressions
Exercises

Chapter 10 : More Control Structures

The unless Control Structure
The until Control Structure
Expression Modifiers
The Naked Block Control Structure
The elsif Clause
Autoincrement and Autodecrement
The for Control Structure
Loop Controls
The Conditional Operator ?:
Logical Operators
Exercises

Chapter 11 : Perl Modules

Finding Modules
Installing Modules
Using Simple Modules
Exercises

Chapter 12 : File Tests

File Test Operators
The stat and lstat Functions
The localtime Function
Bitwise Operators
Exercises

Chapter 13 : Directory Operations

Moving Around the Directory Tree
Globbing
An Alternate Syntax for Globbing
Directory Handles
Recursive Directory Listing
Manipulating Files and Directories
Removing Files
Renaming Files
Links and Files
Making and Removing Directories
Modifying Permissions
Changing Ownership
Changing Timestamps
Exercises

Chapter 14 : Strings and Sorting

Finding a Substring with index
Manipulating a Substring with substr
Formatting Data with sprintf
Advanced Sorting
Exercises

Chapter 15 : Smart Matching and given-when

The Smart Match Operator
Smart Match Precedence
The given Statement
Using when with Many Items
Exercises

Chapter 16 : Process Management

The system Function
The Environment Variables
The exec Function
Using Backquotes to Capture Output
External Processes with IPC::System::Simple
Processes as Filehandles
Getting Down and Dirty with Fork
Sending and Receiving Signals
Exercises

Chapter 17 : Some Advanced Perl Techniques

Slices
Trapping Errors
Picking Items from a List with grep
Transforming Items from a List with map
Fancier List Utilities
Exercises

Appendix : Beyond the Llama
Further Documentation
Regular Expressions
Packages
Extending Perl’s Functionality
Databases
Other Operators and Functions
Mathematics
Lists and Arrays
Bits and Pieces
Formats
Networking and IPC
Security
Debugging
Command-Line Options
Built-in Variables
Syntax Extensions

References
Tied Variables
Operator Overloading
Dynamic Loading
Embedding
Converting Other Languages to Perl
Converting find Command Lines to Perl
Command-Line Options in Your Programs
Embedded Documentation
More Ways to Open Filehandles
Threads and Forking
Graphical User Interfaces (GUIs)
And More…

Appendix : A Unicode Primer

Unicode
UTF-8 and Friends
Getting Everyone to Agree
Fancy Characters
Dealing with Unicode in Perl
Further Reading

Colophon

Mac OS X 鍵盤快速鍵

摘要

瞭解常用的 Mac OS X 鍵盤快速鍵。鍵盤快速鍵讓您按鍵盤上的組合鍵,就能叫出 Mac OS X 的功能。

受影響的產品

Mac OS X 10.0, Mac OS X 10.3, Mac OS X 10.2, Mac OS X 10.1, Mac OS X 10.4, Mac OS X 10.6, Mac OS X 10.5, OS X Lion

如果要使用鍵盤快速鍵或組合鍵,必須同時按下變更鍵和字元鍵。例如同時按 Command 鍵(印有 符號的按鍵)和“c”鍵就能把目前選擇的所有項目(文字、圖形等等)拷貝到剪貼板。這個動作又叫做 Command-C 組合鍵(或鍵盤快速鍵)。

變更鍵是許多組合鍵的一部分。變更鍵會改變 Mac OS X 解譯其他按鍵或按一下滑鼠的方式。變更鍵包括 Command、Control、Option、Shift、Caps Lock 與 Fn 鍵(若鍵盤有 Fn 鍵)。

以下是您能在 Mac OS X 選單中看到的變更鍵符號:

Command 鍵圖像(Command 鍵):幾種 Apple 鍵盤的這個鍵還同時印有 Apple 標誌(蘋果標誌
Control 鍵圖像(Control 鍵)
Option 或 Alt 鍵圖像(Option 鍵):這個按鍵還可能印有“Alt”
Shift 圖像(Shift 鍵)
大寫鎖定鍵圖像(Caps Lock):切換大寫鎖定開關
fn(功能鍵)

開機鍵盤快速鍵

按下按鍵或組合鍵,直到所要的功能出現為止(例如在開機期間按住 Option 直到“開機管理程式”出現為止,或是按住 Shift 直到“安全啟動”出現為止)。秘訣:如果開機功能沒有作用,而且您使用的是協力廠商鍵盤,請接上 Apple Keyboard 鍵盤再試一次。

Option 顯示所有可開機卷宗(開機管理程式
Shift 執行安全啟動安全啟動模式
C 從可開機磁碟啟動(DVD、CD)
T FireWire 目標磁碟模式啟動
N 從 NetBoot 伺服器啟動
X 強迫以 Mac OS X 啟動(如果有非 Mac OS X 啟動卷宗)
Command-V Verbose 模式啟動
Command-S “單一使用者模式”啟動


Finder 鍵盤快速鍵

Command-A 選擇前端 Finder 視窗中的所有項目(如果沒有開啟中視窗則是桌面)
Option-Command-A 取消選取所有項目。
Shift-Command-A 開啟“應用程式”檔案夾
Command-C 拷貝選取項目/文字至剪貼板
Shift-Command-C 開啟“電腦”視窗
Command-D 複製選取項目
Shift-Command-D 開啟桌面檔案夾
Command-E 退出
Command-F 尋找任何相符的 Spotlight 屬性
Shift-Command-F 尋找 Spotlight 檔案名稱符合項目
Option-Command-F 移動到已經開啟的 Spotlight 視窗中的搜尋欄位
Shift-Command-G 前往檔案夾
Shift-Command-H 開啟目前登入使用者帳號的個人專屬檔案夾
Command-I 簡介
Option-Command-I 顯示檢閱器
Control-Command-I 取得摘要簡介
Shift-Command-I 開啟 iDisk
Command-J 開啟顯示方式選項
Command-K 連接伺服器
Shift-Command-K 開啟“網路”視窗
Command-L 製作所選項目的替身
Command-M 視窗最小化
Option-Command-M 將全部視窗縮到最小
Command-N 新增 Finder 視窗
Shift-Command-N 新增檔案夾
Option-Command-N 新增智慧型檔案夾
Command-O 開啟選取項目
Shift-Command-Q 登出
Option-Shift-Command-Q 立即登出
Command-R 顯示替身的原項目
Command-T 加到側邊欄裡
Shift-Command-T 加到喜好項目
Option-Command-T 在“Finder”視窗中隱藏工具列 / 顯示工具列
Shift-Command-U 開啟“工具程式”檔案夾
Command-V 貼上
Command-W 關閉視窗
Option-Command-W 關閉所有視窗
Command-X 剪下
Option-Command-Y 幻燈片秀(Mac OS X 10.5 或以上版本)
Command-Z 還原/重作
Command-1 以圖像顯示
Command-2 依列表顯示
Command-3 依欄位顯示
Command-4 依 Cover Flow 顯示(Mac OS X 10.5 或以上版本)
Command-,(Command 和逗號鍵) 開啟 Finder 偏好設定
Command-`(次重音符號鍵,在美式英文鍵盤佈局的 Tab 鍵上方) 循環檢視開啟中的“Finder”視窗
Command-Shift-? 開啟 Mac 輔助說明
Option-Shift-Command-Esc(按住三秒)- 僅限 Mac OS X v10.5、v10.6 或以上版本 強制結束最前面的應用程式
Command-[ 返回
Command-] 往前
Command-向上鍵 開啟所含的檔案夾
Control-Command-向上鍵 以新視窗開啟所含的檔案夾
Command-向下鍵 開啟反白項目
Command-Tab 切換應用程式:向前循環
Shift-Command-Tab 切換應用程式:向後循環
Command-Delete 丟到垃圾桶
Shift-Command-Delete 清空垃圾桶
Option-Shift-Command-Delete 不顯示確認對話框便直接清空垃圾桶
空白鍵(或 Command-Y) 快速查看(Mac OS X 10.5 或以上版本)
按住 Command 鍵同時拖移 把拖移的項目移動到其他卷宗/位置(按住本鍵時游標圖像會改變,請參閱這篇文章
按住 Option 鍵同時拖移 拷貝拖移的項目(按住本鍵時游標圖像會改變,請參閱這篇文章
按住 Option-Command 組合鍵同時拖移 製作拖移項目的替身(按住本鍵時游標圖像會改變,請參閱這篇文章

 

應用程式和其他 Mac OS X 鍵盤指令

附註:某些應用程式可能不支援以下某些應用程式組合鍵。

Command-空白鍵 顯示或隱藏 Spotlight 搜尋欄位(如果安裝多種語言,則可能要切換到已啟用的語系)
Control-A 移動到一行或一段的開頭
Control-B 後退一個字元
Control-D 刪除游標前的字元
Control-E 移動到一行或一段的結尾
Control-F 前進一個字元
Control-H 刪除游標後的字元
Control-K 從游標前面的字元刪除到一行或一段的結尾
Control-L 將游標或所選範圍移到可視區域中央
Control-N 下移一行
Control-O 在游標後插入一行
Control-P 上移一行
Control-T 將游標後和游標前的字元位置對調
Control-V 向下移動一頁
Option-Delete 刪除游標左側的字以及後面的任何空格或標點符號
Option-Command-空白鍵 顯示 Spotlight 搜尋結果視窗(如果安裝多種語言,則可能要切換到各語系專屬的鍵盤佈局和輸入法)
Command-Tab 向前移動到已開啟應用程式列表中的下一個近期使用應用程式
Shift-Command-Tab 向後移動已開啟應用程式的列表(依照近期使用順序排列)
Shift-Tab 反向切換控制項目
Control-Tab 把焦點移到對話框中的下一類控制項目或下一個表格(按 Tab 是移動到下一個輸入格)
Shift-Control-Tab 把焦點移到對話框中的前一類控制項目
Command-esc 開啟 Front Row(如果已經安裝)
Option-退出鍵 退出第二個光碟機(如果已經安裝)
Control-退出鍵 顯示關機對話框
Option-Command-退出 使電腦進入睡眠模式
Control-Command-退出 結束所有應用程式(會先讓您儲存已開啟文件的更改內容),然後重新啟動電腦
Control Option-Command-退出 結束所有應用程式(會先讓您儲存已開啟文件的更改內容),然後關機
fn-Delete 往前刪除(在可攜式 Mac 的內建鍵盤上)
Control-F1 開啟/關閉全面鍵盤操控功能
Control-F2 把焦點移到選單列
Control-F3 把焦點移到 Dock
Control-F4 把焦點移到現用視窗或下一個視窗
Shift-Control-F4 把焦點移到前一個現用視窗
Control-F5 把焦點移到工具列
Control-F6 把焦點移到第一個面板或下一個面板
Shift-Control-F6 把焦點移到上一個面板
Control-F7 暫時覆蓋視窗和對話框的目前鍵盤操控模式
F9 並排所有開啟中視窗或取消並排
F10 並排目前現用應用程式的所有開啟中視窗或取消並排
F11 隱藏或顯示所有開啟中視窗
F12 隱藏或顯示 Dashboard
Command-` 在最上層應用程式中啟動下一個開啟中視窗
Shift-Command-` 在最上層應用程式中啟動上一個開啟中視窗
Option-Command-` 把焦點移到視窗抽屜
Command- -(減號) 縮小所選項目
Command-{ 所選範圍齊左
Command-} 所選範圍齊右
Command-| 所選範圍中間對齊
Command-: 顯示“拼字檢查”視窗
Command-; 尋找文件中的錯字
Command-, 開啟前端應用程式的偏好設定視窗(如果應用程式支援這個鍵盤快速鍵)
Option-Control-Command-, 降低螢幕對比
Option-Control-Command-. 調高螢幕對比
Command-? 在輔助說明檢視程式中開啟應用程式的輔助說明
Option-Command-/ 開啟或關閉字體平滑功能
Shift-Command-= 放大所選項目
Shift-Command-3 將螢幕擷取成檔案
Shift-Control-Command-3 將螢幕擷取到剪貼板
Shift-Command-4 將所選範圍擷取成檔案
Shift-Control-Command-4 將所選範圍擷取到剪貼板
Command-A 反白文件或視窗中的所有項目,或是文字欄位中的所有字元
Command-B 讓所選的文字變成粗體;啟動或關閉文字粗體功能
Command-C 將所選資料拷貝到剪貼板
Shift-Command-C 顯示“顏色”視窗
Option-Command-C 拷貝所選文字的樣式
Control-Command-C 拷貝所選項目的格式化設定,並且儲存到剪貼板
Option-Command-D 顯示或隱藏 Dock
Command-Control-D 顯示“字典”應用程式中所選文字的定義
Command-D 在“打開和儲存”對話框中選取“桌面”檔案夾
在 Mac OS X v10.6.8 和以下版本中,選取包含“不儲存”按鈕的對話框中的“不儲存”
Command-Delete 在 OS X Lion 中,選取包含“不儲存”按鈕的對話框中的“不儲存”
Command-E 在所選範圍內尋找
Command-F 開啟“Find”視窗
Option-Command-F 移到搜尋欄位控制項目
Command-G 尋找所選範圍下次出現的地方
Shift-Command-G 尋找所選範圍上次出現的地方
Command-H 隱藏目前執行中應用程式的視窗
Option-Command-H 隱藏其他執行中應用程式的視窗
Command-I 讓所選文字變成斜體;啟動或關閉文字斜體功能
Option-Command-I 顯示檢閱器視窗
Command-J 捲視到所選範圍
Command-M 把現用視窗縮小到 Dock
Option-Command-M 把現用應用程式的所有視窗縮小到 Dock
Command-N 在最前方的應用程式中製作新文件
Command-O 顯示對話框,以便選擇要在最前方應用程式中開啟的文件
Command-P 顯示“列印”對話框
Shift-Command-P 顯示對話框以便指定列印參數(設定頁面)
Command-Q 結束最前方的應用程式
Command-S 儲存現用的文件
Shift-Command-S 顯示“儲存為”對話框
Command-T 顯示“字體”視窗
Option-Command-T 顯示或隱藏工具列
Command-U 為所選文字加上底線;啟動或關閉文字底線功能
Command-V 在插入點貼上剪貼板內容
Option-Command-V 把一個物件的樣式套用到所選物件(貼上樣式)
Option-Shift-Command-V 把周圍文字樣式套用到插入物件(貼上並符合樣式)
Control-Command-V 把格式化設定套用到所選物件(貼上尺標指令)
Command-W 關閉最上層視窗
Shift-Command-W 關閉檔案和相關視窗
Option-Command-W 關閉應用程式的所有視窗但不結束應用程式本身
Command-X 刪除所選範圍並儲存到剪貼板
Command-Z 還原前一個指令(某些應用程式可還原多個指令)
Shift-Command-Z 重作前一個指令(某些應用程式可重作多個指令)
Control-向右鍵 把焦點移到顯示方式(例如表格)中的另一個數值或輸入格
Control-向左鍵 把焦點移到顯示方式(例如表格)中的另一個數值或輸入格
Control-向下鍵 把焦點移到顯示方式(例如表格)中的另一個數值或輸入格
Control-向上鍵 把焦點移到顯示方式(例如表格)中的另一個數值或輸入格
Command-向右鍵 將文字插入點移到目前這一行結尾
Command-向左鍵 將文字插入點移到目前這一行開頭
Command-向下鍵 將文字插入點移到文件結尾
Command-向上鍵 將文字插入點移到文件開頭
Shift-Command-向右鍵 選擇從插入點到目前這一行結尾之間的所有文字(*)
Shift-Command-向左鍵 選擇從插入點到目前這一行開頭之間的所有文字(*)
Shift-向右鍵 把文字所選範圍向右延伸一個字元(*)
Shift-向左鍵 把文字所選範圍向左延伸一個字元(*)
Shift-Command-向上鍵 選擇從插入點到文件開頭之間的所有文字(*)
Shift-Command-向下鍵 選擇從插入點到文件結尾之間的所有文字(*)
Shift-向上鍵 把文字所選範圍延伸到上一行相同水平位置的最近字元邊界(*)
Shift-向下鍵 把文字所選範圍延伸到下一行相同水平位置的最近字元邊界(*)
Shift-Option-向右鍵 把文字所選範圍延伸到現用字結尾,再按一次就會延伸到下一個字的結尾(*)
Shift-Option-向左鍵 把文字所選範圍延伸到現用字開頭,再按一次就會延伸到下一個字的開頭(*)
Shift-Option-向下鍵 把文字所選範圍延伸到現用段落結尾,再按一次就會延伸到下一段結尾(*)
Shift-Option-向上鍵 把文字所選範圍延伸到現用段落開頭,再按一次就會延伸到下一段開頭(*)
Control-空白鍵 在現用輸入來源和上一個輸入來源之間切換
Option-Control-空白鍵 循序切換到所有啟用的輸入來源
Option-Command-esc 強制結束

(*)附註:如果沒有選擇文字,則會從插入點開始延伸。如果用拖移方式選擇文字,則會從所選範圍的邊緣開始延伸。如果反向選取,則會取消選取適當的單元。


輔助使用:VoiceOver 鍵盤指令

若要了解 Mac OS X v10.6 的 VoiceOver 組合鍵差異,請參考這篇文章

Command-F5 或
fn Command-F5
開啟或關閉 VoiceOver
Control Option-F8 或
fn Control Option-F8
開啟 VoiceOver 工具程式
Control Option-F7 或
fn Control Option-F7
顯示“VoiceOver”選單
Control Option-;
或 fn Control Option-;
啟用/停用 VoiceOver 控制選項鎖定功能
Option-Command-8 或
fn Command-F11
啟用縮放功能
Option-Command-+ 放大
Option-Command- -(減號) 縮小
Option-Control-Command-8 螢幕顏色呈現負片效果/回復
Control Option-Command-, 降低對比
Control Option-Command-. 調高對比

附註:您可能需要啟用“鍵盤”偏好設定中的“使用所有 F1、F2 等按鍵作為標準功能鍵”,才能讓 VoiceOver 選單和工具程式正常運作。


輔助使用:模擬滑鼠

在“輔助使用”偏好設定中開啟模擬滑鼠功能時,可用鍵盤或數字鍵盤移動滑鼠游標。如果您的電腦沒有數字鍵盤,請使用 Fn(功能)鍵。

8 向上移動
2 向下移動
4 向左移動
6 向右移動
1 成對角線往左下角移動
3 成對角線往右下角移動
7 成對角線往左上角移動
9 成對角線往右上角移動
5 按下滑鼠按鈕
0 按住滑鼠按鈕
. (數字鍵盤上的句號) 放開滑鼠按鍵

另請參閱:「模擬滑鼠的快速鍵」。

其他資訊

進階:本文說明預設的指定變更鍵。您可在“系統偏好設定”的“鍵盤與滑鼠”偏好設定面板中,更改指定變更鍵。例如您可以把 Command 改成有 Option 鍵功能,反之亦然。您也可以回復預設的變更鍵設定。