Skip to Content
Perl语言入门
book

Perl语言入门

by Randal L. Schwartz, brian d foy, Tom Phoenix
August 2018
Beginner to intermediate
382 pages
7h 14m
Chinese
Southeast University Press
Content preview from Perl语言入门
226
12
$atime
$mtime
$ctime
三种表示从纪元(
epoch
)算起的秒数的时间戳。在
Unix
与某些其他系统中,
纪元从公元
1970
年世界标准时间的午夜算起。某些文件系统上会有所不同,比
ext2
,会禁用
atime
以改善性能。
对符号链接名调用
stat
函数将会返回符号链接指向对象的信息,而非符号链接本身
的信息(除非该链接指向的对象目前无法访问)。若你需要符号链接本身的信息(多
半没用),你可以用
lstat
(它会返回同样顺序、同样意义的内容)来代替
stat
。如
lstat
的参数不是符号链接,它会和
stat
一样返回空列表。
就像文件测试操作符一样,
stat
lstat
的默认操作数是
$_
。也就是说,底层
stat
系统调用会对标量变量
$_
里的文件名进行操作。
模块
File::stat
提供了兼容
stat
且更为友好的操作界面
localtime
函数
你能获得的时间戳值(比如从
stat
函数返回的时间戳)看起来通常会像
1454133253
这样的形式。对大多数人来说,这样的数字实在不太方便,除非你想通过减法来比较
两个时间戳大小。所以,你可能需要将它转换成比较容易阅读的形式,比如
Sat Jan
30 00:54:13 2016
这样的字符串。
Perl
可以在标量上下文中使用
localtime
函数完成
这种转换:
my $timestamp = 1454133253;
my $date = localtime ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

计算机科学导论:跨学科方法

计算机科学导论:跨学科方法

罗伯特 塞奇威克, 凯文 韦恩
Perl语言入门(第8版)

Perl语言入门(第8版)

Randal L. Schwartz, brian d foy, Tom Phoenix

Publisher Resources

ISBN: 9787564177911