Char-GBK
view release on metacpan or search on metacpan
lib/Egbk.pm view on Meta::CPAN
elsif (-e $_) {
return wantarray ? (-M _,@_) : -M _;
}
elsif (_MSWin32_5Cended_path($_)) {
if (-d "$_/.") {
return wantarray ? (-M _,@_) : -M _;
}
else {
my $fh = gensym();
if (_open_r($fh, $_)) {
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh;
close($fh) or die "Can't close file: $_: $!";
my $M = ($^T - $mtime) / (24*60*60);
return wantarray ? ($M,@_) : $M;
}
}
}
return wantarray ? (undef,@_) : undef;
}
#
lib/Egbk.pm view on Meta::CPAN
elsif (-e $_) {
return wantarray ? (-A _,@_) : -A _;
}
elsif (_MSWin32_5Cended_path($_)) {
if (-d "$_/.") {
return wantarray ? (-A _,@_) : -A _;
}
else {
my $fh = gensym();
if (_open_r($fh, $_)) {
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh;
close($fh) or die "Can't close file: $_: $!";
my $A = ($^T - $atime) / (24*60*60);
return wantarray ? ($A,@_) : $A;
}
}
}
return wantarray ? (undef,@_) : undef;
}
#
lib/Egbk.pm view on Meta::CPAN
elsif (-e $_) {
return wantarray ? (-C _,@_) : -C _;
}
elsif (_MSWin32_5Cended_path($_)) {
if (-d "$_/.") {
return wantarray ? (-C _,@_) : -C _;
}
else {
my $fh = gensym();
if (_open_r($fh, $_)) {
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh;
close($fh) or die "Can't close file: $_: $!";
my $C = ($^T - $ctime) / (24*60*60);
return wantarray ? ($C,@_) : $C;
}
}
}
return wantarray ? (undef,@_) : undef;
}
#
lib/Egbk.pm view on Meta::CPAN
if (-e $_) {
return -M _;
}
elsif (_MSWin32_5Cended_path($_)) {
if (-d "$_/.") {
return -M _;
}
else {
my $fh = gensym();
if (_open_r($fh, $_)) {
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh;
close($fh) or die "Can't close file: $_: $!";
my $M = ($^T - $mtime) / (24*60*60);
return $M;
}
}
}
return undef;
}
#
lib/Egbk.pm view on Meta::CPAN
if (-e $_) {
return -A _;
}
elsif (_MSWin32_5Cended_path($_)) {
if (-d "$_/.") {
return -A _;
}
else {
my $fh = gensym();
if (_open_r($fh, $_)) {
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh;
close($fh) or die "Can't close file: $_: $!";
my $A = ($^T - $atime) / (24*60*60);
return $A;
}
}
}
return undef;
}
#
lib/Egbk.pm view on Meta::CPAN
if (-e $_) {
return -C _;
}
elsif (_MSWin32_5Cended_path($_)) {
if (-d "$_/.") {
return -C _;
}
else {
my $fh = gensym();
if (_open_r($fh, $_)) {
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh;
close($fh) or die "Can't close file: $_: $!";
my $C = ($^T - $ctime) / (24*60*60);
return $C;
}
}
}
return undef;
}
#
lib/Egbk.pm view on Meta::CPAN
$header =~ s/\n\s+/ /g; # Merge continuation lines.
%head = ("FRONTSTUFF", Egbk::split(/^(\S*?):\s*/m, $header));
The following example processes the entries in a Unix passwd(5) file. You could
leave out the chomp, in which case $shell would have a newline on the end of it.
open(PASSWD, "/etc/passwd");
while (<PASSWD>) {
chomp; # remove trailing newline.
($login, $passwd, $uid, $gid, $gcos, $home, $shell) =
Egbk::split(/:/);
...
}
Here's how process each word of each line of each file of input to create a
word-frequency hash.
while (<>) {
for my $word (Egbk::split()) {
$count{$word}++;
lib/Egbk.pm view on Meta::CPAN
Not available in MSWin32 and MacOS
------------------------------------------------------------------------------
Subroutine and Prototype Meaning
------------------------------------------------------------------------------
Egbk::o(*), Egbk::o_() File or directory is owned by this (effective) user
Egbk::O(*), Egbk::O_() File or directory is owned by this real user
Egbk::p(*), Egbk::p_() Entry is a named pipe (a "fifo")
Egbk::b(*), Egbk::b_() Entry is a block-special file (like a mountable disk)
Egbk::c(*), Egbk::c_() Entry is a character-special file (like an I/O device)
Egbk::u(*), Egbk::u_() File or directory is setuid
Egbk::g(*), Egbk::g_() File or directory is setgid
Egbk::k(*), Egbk::k_() File or directory has the sticky bit set
------------------------------------------------------------------------------
The tests -T and -B takes a try at telling whether a file is text or binary.
But people who know a lot about filesystems know that there's no bit (at least
in UNIX-like operating systems) to indicate that a file is a binary or text file
--- so how can Perl tell?
The answer is that Perl cheats. As you might guess, it sometimes guesses wrong.
This incomplete thinking of file test operator -T and -B gave birth to UTF8 flag
lib/Egbk.pm view on Meta::CPAN
@stat = Egbk::stat(FILEHANDLE);
@stat = Egbk::stat(DIRHANDLE);
@stat = Egbk::stat($expr);
@stat = Egbk::stat_;
In scalar context, this subroutine returns a Boolean value that indicates whether
the call succeeded. In list context, it returns a 13-element list giving the
statistics for a file, either the file opened via FILEHANDLE or DIRHANDLE, or
named by $expr. It's typically used as followes:
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks) = Egbk::stat($expr);
Not all fields are supported on all filesystem types; unsupported fields return
0. Here are the meanings of the fields:
-------------------------------------------------------------------------
Index Field Meaning
-------------------------------------------------------------------------
0 $dev Device number of filesystem
drive number for MSWin32
lib/Egbk.pm view on Meta::CPAN
zero for MSWin32
fileID/dirID for MacOS
2 $mode File mode (type and permissions)
3 $nlink Nunmer of (hard) links to the file
usually one for MSWin32 --- NTFS filesystems may
have a value greater than one
1 for MacOS
4 $uid Numeric user ID of file's owner
zero for MSWin32
zero for MacOS
5 $gid Numeric group ID of file's owner
zero for MSWin32
zero for MacOS
6 $rdev The device identifier (special files only)
drive number for MSWin32
NULL for MacOS
7 $size Total size of file, in bytes
8 $atime Last access time since the epoch
same as $mtime for MacOS
9 $mtime Last modification time since the epoch
since 1904-01-01 00:00:00 for MacOS
Not available in MSWin32 and MacOS
--------------------------------------------------------------------------
Before After Meaning
--------------------------------------------------------------------------
-o Egbk::o File or directory is owned by this (effective) user
-O Egbk::O File or directory is owned by this real user
-p Egbk::p Entry is a named pipe (a "fifo")
-b Egbk::b Entry is a block-special file (like a mountable disk)
-c Egbk::c Entry is a character-special file (like an I/O device)
-u Egbk::u File or directory is setuid
-g Egbk::g File or directory is setgid
-k Egbk::k File or directory has the sticky bit set
--------------------------------------------------------------------------
-w only inspects the read-only file attribute (FILE_ATTRIBUTE_READONLY), which
determines whether the directory can be deleted, not whether it can be written
to. Directories always have read and write access unless denied by
discretionary access control lists (DACLs). (MSWin32)
-R, -W, -X, -O are indistinguishable from -r, -w, -x, -o. (MSWin32)
-g, -k, -l, -u, -A are not particularly meaningful. (MSWin32)
-x (or -X) determine if a file ends in one of the executable suffixes. -S is
( run in 1.614 second using v1.01-cache-2.11-cpan-5735350b133 )