13.07.2015 Views

Perl 语言编程 - Linux教程

Perl 语言编程 - Linux教程

Perl 语言编程 - Linux教程

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

在 加 州 , 这 些 打 印 出 :The 1st lucky number is: 18The 2nd lucky number is: 11The 3rd lucky number is: 40The 4th lucky number is: 7The 5th lucky number is: 51The 6th lucky number is: 33And the bonus number is: 5解 引 用 操 作 符 :${},@{},%{},&{},*{} 对 标 量 , 数 组 , 散 列 , 子 过 程 , 和 团 的 解引 用 可 以 通 过 重 载 这 五 个 符 号 来 截 获 。<strong>Perl</strong> 的 overload 的 在 线 文 档 演 示 了 你 如 何 才 能 使 用 这 些 操 作 符 来 仿 真 你 自 己 的 伪 散列 。 下 面 是 一 个 更 简 单 的 例 子 , 它 实 现 了 一 个 有 匿 名 数 组 的 对 象 , 但 是 使 用 散 列 引 用 。 别试 图 把 他 当 作 真 的 散 列 用 ; 你 不 能 从 该 对 象 删 除 键 字 / 数 值 对 。 如 果 你 想 合 并 数 组 和 散 列 符号 , 使 用 一 个 真 的 伪 散 列 。package PsychoHash;use overload '%{}' => \&as_hash;sub as_hash {my ($x) = shift;return { @$x };}340

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!