最奇怪的语言功能 [英] Strangest language feature
本文介绍了最奇怪的语言功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您认为,您遇到的最令人惊讶,奇怪,奇怪或真正的"WTF"语言功能是什么?
What is, in your opinion, the most surprising, weird, strange or really "WTF" language feature you have encountered?
每个答案只能使用一项功能.
推荐答案
Perl的许多内置变量:
Perl’s many built-in variables:
-
$#
-不是评论! -
$0
,$$
和$?
—就像具有相同名称的shell变量 -
$ˋ
,$&
和$'
—奇怪的匹配变量 -
$"
和$,
—用于列表和输出字段分隔符的怪异变量 -
$!
—类似errno
作为数字,但strerror(errno)
作为字符串 -
$_
— 隐蔽变量,始终使用且从未见过 -
$#_
—最后一个子例程参数的索引号...也许 -
@_
—当前函数的(非)名称...也许 -
$@
-上一次引发的异常 -
%::
—符号表 -
$:
,$^
,$~
,$-
和$=
-与输出格式有关 -
$.
和$%
-输入行号,输出页号 -
$/
和$\
-输入和输出记录分隔符 -
$|
—输出缓冲控制器 -
$[
—将基于数组的数组从基于0的更改为基于1的基于42的内容: WHEEE! -
$}
— 一无所有,很奇怪! -
$<
,$>
,$(
,$)
-真实有效的UID和GID -
@ISA
-当前包的直接超类的名称 -
$^T
—脚本启动时间,以纪元秒为单位 -
$^O
-当前操作系统名称 -
$^V
—这是Perl的哪个版本
$#
— not a comment!$0
,$$
, and$?
— just like the shell variables by the same name$ˋ
,$&
, and$'
— weird matching variables$"
and$,
— weird variables for list- and output-field-separators$!
— likeerrno
as a number butstrerror(errno)
as a string$_
— the stealth variable, always used and never seen$#_
— index number of the last subroutine argument... maybe@_
— the (non)names of the current function... maybe$@
— the last-raised exception%::
— the symbol table$:
,$^
,$~
,$-
, and$=
— something to do with output formats$.
and$%
— input line number, output page number$/
and$\
— input and output record separators$|
— output buffering controller$[
— change your array base from 0-based to 1-based to 42-based: WHEEE!$}
— nothing at all, oddly enough!$<
,$>
,$(
,$)
— real and effective UIDs and GIDs@ISA
— names of current package’s direct superclasses$^T
— script start-up time in epoch seconds$^O
— current operating system name$^V
— what version of Perl this is
这些来源更多.在此处阅读完整列表.
There’s a lot more where those came from. Read the complete list here.
这篇关于最奇怪的语言功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文