Char-Big5Plus
view release on metacpan or search on metacpan
lib/Ebig5plus.pm view on Meta::CPAN
sub Ebig5plus::classic_character_class;
sub Ebig5plus::capture;
sub Ebig5plus::chr(;$);
sub Ebig5plus::chr_();
sub Ebig5plus::filetest;
sub Ebig5plus::r(;*@);
sub Ebig5plus::w(;*@);
sub Ebig5plus::x(;*@);
sub Ebig5plus::o(;*@);
sub Ebig5plus::R(;*@);
sub Ebig5plus::W(;*@);
sub Ebig5plus::X(;*@);
sub Ebig5plus::O(;*@);
sub Ebig5plus::e(;*@);
sub Ebig5plus::z(;*@);
sub Ebig5plus::s(;*@);
sub Ebig5plus::f(;*@);
sub Ebig5plus::d(;*@);
sub Ebig5plus::l(;*@);
sub Ebig5plus::p(;*@);
sub Ebig5plus::S(;*@);
sub Ebig5plus::b(;*@);
sub Ebig5plus::c(;*@);
sub Ebig5plus::u(;*@);
sub Ebig5plus::g(;*@);
sub Ebig5plus::k(;*@);
sub Ebig5plus::T(;*@);
sub Ebig5plus::B(;*@);
sub Ebig5plus::M(;*@);
sub Ebig5plus::A(;*@);
sub Ebig5plus::C(;*@);
sub Ebig5plus::filetest_;
sub Ebig5plus::r_();
sub Ebig5plus::w_();
sub Ebig5plus::x_();
sub Ebig5plus::o_();
sub Ebig5plus::R_();
sub Ebig5plus::W_();
sub Ebig5plus::X_();
sub Ebig5plus::O_();
sub Ebig5plus::e_();
sub Ebig5plus::z_();
sub Ebig5plus::s_();
sub Ebig5plus::f_();
sub Ebig5plus::d_();
sub Ebig5plus::l_();
sub Ebig5plus::p_();
sub Ebig5plus::S_();
sub Ebig5plus::b_();
sub Ebig5plus::c_();
sub Ebig5plus::u_();
sub Ebig5plus::g_();
sub Ebig5plus::k_();
sub Ebig5plus::T_();
sub Ebig5plus::B_();
sub Ebig5plus::M_();
sub Ebig5plus::A_();
sub Ebig5plus::C_();
sub Ebig5plus::glob($);
sub Ebig5plus::glob_();
sub Ebig5plus::lstat(*);
sub Ebig5plus::lstat_();
sub Ebig5plus::opendir(*$);
sub Ebig5plus::stat(*);
sub Ebig5plus::stat_();
sub Ebig5plus::unlink(@);
sub Ebig5plus::chdir(;$);
sub Ebig5plus::do($);
sub Ebig5plus::require(;$);
sub Ebig5plus::telldir(*);
sub Big5Plus::ord(;$);
sub Big5Plus::ord_();
sub Big5Plus::reverse(@);
sub Big5Plus::getc(;*@);
sub Big5Plus::length(;$);
sub Big5Plus::substr($$;$$);
sub Big5Plus::index($$;$);
sub Big5Plus::rindex($$;$);
sub Big5Plus::escape(;$);
#
# Regexp work
#
use vars qw(
$re_a
$re_t
$re_n
$re_r
);
#
# Character class
#
use vars qw(
$dot
$dot_s
$eD
$eS
$eW
$eH
$eV
$eR
$eN
$not_alnum
$not_alpha
$not_ascii
$not_blank
$not_cntrl
$not_digit
$not_graph
$not_lower
$not_lower_i
$not_print
$not_punct
$not_space
$not_upper
$not_upper_i
$not_word
$not_xdigit
$eb
$eB
);
lib/Ebig5plus.pm view on Meta::CPAN
#
# via File::HomeDir::Windows 1.00
#
sub my_home_MSWin32 {
# A lot of unix people and unix-derived tools rely on
# the ability to overload HOME. We will support it too
# so that they can replace raw HOME calls with File::HomeDir.
if (exists $ENV{'HOME'} and $ENV{'HOME'}) {
return $ENV{'HOME'};
}
# Do we have a user profile?
elsif (exists $ENV{'USERPROFILE'} and $ENV{'USERPROFILE'}) {
return $ENV{'USERPROFILE'};
}
# Some Windows use something like $ENV{'HOME'}
elsif (exists $ENV{'HOMEDRIVE'} and exists $ENV{'HOMEPATH'} and $ENV{'HOMEDRIVE'} and $ENV{'HOMEPATH'}) {
return join '', $ENV{'HOMEDRIVE'}, $ENV{'HOMEPATH'};
}
return undef;
}
#
# via File::HomeDir::Unix 1.00
#
sub my_home {
my $home;
if (exists $ENV{'HOME'} and defined $ENV{'HOME'}) {
$home = $ENV{'HOME'};
}
# This is from the original code, but I'm guessing
# it means "login directory" and exists on some Unixes.
elsif (exists $ENV{'LOGDIR'} and $ENV{'LOGDIR'}) {
$home = $ENV{'LOGDIR'};
}
### More-desperate methods
# Light desperation on any (Unixish) platform
else {
$home = CORE::eval q{ (getpwuid($<))[7] };
}
# On Unix in general, a non-existant home means "no home"
# For example, "nobody"-like users might use /nonexistant
if (defined $home and ! Ebig5plus::d($home)) {
$home = undef;
}
return $home;
}
#
# Big5Plus file lstat (with parameter)
#
sub Ebig5plus::lstat(*) {
local $_ = shift if @_;
if (-e $_) {
return CORE::lstat _;
}
elsif (_MSWin32_5Cended_path($_)) {
# Even if ${^WIN32_SLOPPY_STAT} is set to a true value, Ebig5plus::lstat()
# on Windows opens the file for the path which has 5c at end.
# (and so on)
local *MUST_BE_BAREWORD_AT_HERE;
if (CORE::open(MUST_BE_BAREWORD_AT_HERE, $_)) {
if (wantarray) {
my @stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; # not CORE::lstat
close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!";
return @stat;
}
else {
my $stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; # not CORE::lstat
close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!";
return $stat;
}
}
}
return wantarray ? () : undef;
}
#
# Big5Plus file lstat (without parameter)
#
sub Ebig5plus::lstat_() {
if (-e $_) {
return CORE::lstat _;
}
elsif (_MSWin32_5Cended_path($_)) {
local *MUST_BE_BAREWORD_AT_HERE;
if (CORE::open(MUST_BE_BAREWORD_AT_HERE, $_)) {
if (wantarray) {
my @stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; # not CORE::lstat
close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!";
return @stat;
}
else {
my $stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; # not CORE::lstat
close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!";
return $stat;
}
}
}
return wantarray ? () : undef;
}
#
# Big5Plus path opendir
#
sub Ebig5plus::opendir(*$) {
my $dh = qualify_to_ref $_[0];
if (CORE::opendir $dh, $_[1]) {
return 1;
}
elsif (_MSWin32_5Cended_path($_[1])) {
if (CORE::opendir $dh, "$_[1]/.") {
return 1;
}
}
return undef;
}
#
# Big5Plus file stat (with parameter)
#
sub Ebig5plus::stat(*) {
local $_ = shift if @_;
my $fh = qualify_to_ref $_;
if (defined fileno $fh) {
return CORE::stat $fh;
}
elsif (-e $_) {
return CORE::stat _;
}
elsif (_MSWin32_5Cended_path($_)) {
# Even if ${^WIN32_SLOPPY_STAT} is set to a true value, Ebig5plus::stat()
# on Windows opens the file for the path which has 5c at end.
# (and so on)
local *MUST_BE_BAREWORD_AT_HERE;
if (CORE::open(MUST_BE_BAREWORD_AT_HERE, $_)) {
if (wantarray) {
my @stat = CORE::stat MUST_BE_BAREWORD_AT_HERE;
close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!";
return @stat;
}
else {
my $stat = CORE::stat MUST_BE_BAREWORD_AT_HERE;
close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!";
return $stat;
}
}
}
return wantarray ? () : undef;
}
#
# Big5Plus file stat (without parameter)
#
sub Ebig5plus::stat_() {
my $fh = qualify_to_ref $_;
if (defined fileno $fh) {
return CORE::stat $fh;
}
elsif (-e $_) {
return CORE::stat _;
}
elsif (_MSWin32_5Cended_path($_)) {
local *MUST_BE_BAREWORD_AT_HERE;
if (CORE::open(MUST_BE_BAREWORD_AT_HERE, $_)) {
if (wantarray) {
my @stat = CORE::stat MUST_BE_BAREWORD_AT_HERE;
close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!";
return @stat;
}
else {
my $stat = CORE::stat MUST_BE_BAREWORD_AT_HERE;
close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!";
return $stat;
}
}
}
return wantarray ? () : undef;
}
#
# Big5Plus path unlink
#
sub Ebig5plus::unlink(@) {
local @_ = ($_) unless @_;
my $unlink = 0;
for (@_) {
if (CORE::unlink) {
lib/Ebig5plus.pm view on Meta::CPAN
$shortleafdir =~ s/ \. [ ]+ \z//oxms;
$shortdir = join '', @subdir[0..$#subdir-1], $shortleafdir;
last;
}
}
}
if ($shortdir eq '') {
return 0;
}
elsif (Ebig5plus::fc($shortdir) eq Ebig5plus::fc($dir)) {
return 0;
}
return CORE::chdir $shortdir;
}
else {
return CORE::chdir $dir;
}
}
#
# Big5Plus chr(0x5C) ended path on MSWin32
#
sub _MSWin32_5Cended_path {
if ((@_ >= 1) and ($_[0] ne '')) {
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) {
my @char = $_[0] =~ /\G (?>$q_char) /oxmsg;
if ($char[-1] =~ / \x5C \z/oxms) {
return 1;
}
}
}
return undef;
}
#
# do Big5Plus file
#
sub Ebig5plus::do($) {
my($filename) = @_;
my $realfilename;
my $result;
ITER_DO:
{
for my $prefix (@INC) {
if ($^O eq 'MacOS') {
$realfilename = "$prefix$filename";
}
else {
$realfilename = "$prefix/$filename";
}
if (Ebig5plus::f($realfilename)) {
my $script = '';
if (Ebig5plus::e("$realfilename.e")) {
my $e_mtime = (Ebig5plus::stat("$realfilename.e"))[9];
my $mtime = (Ebig5plus::stat($realfilename))[9];
my $module_mtime = (Ebig5plus::stat(__FILE__))[9];
if (($e_mtime < $mtime) or ($mtime < $module_mtime)) {
Ebig5plus::unlink "$realfilename.e";
}
}
if (Ebig5plus::e("$realfilename.e")) {
my $fh = gensym();
if (_open_r($fh, "$realfilename.e")) {
if ($^O eq 'MacOS') {
CORE::eval q{
CORE::require Mac::Files;
Mac::Files::FSpSetFLock("$realfilename.e");
};
}
elsif (exists $ENV{'CHAR_NONBLOCK'}) {
# P.419 File Locking
# in Chapter 16: Interprocess Communication
# of ISBN 0-596-00027-8 Programming Perl Third Edition.
# P.524 File Locking
# in Chapter 15: Interprocess Communication
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
# (and so on)
CORE::eval q{ flock($fh, LOCK_SH | LOCK_NB) };
if ($@) {
carp "Can't immediately read-lock the file: $realfilename.e";
}
}
else {
CORE::eval q{ flock($fh, LOCK_SH) };
}
local $/ = undef; # slurp mode
$script = <$fh>;
if ($^O eq 'MacOS') {
CORE::eval q{
CORE::require Mac::Files;
Mac::Files::FSpRstFLock("$realfilename.e");
};
}
close($fh) or die "Can't close file: $realfilename.e: $!";
}
}
else {
my $fh = gensym();
if (_open_r($fh, $realfilename)) {
if ($^O eq 'MacOS') {
CORE::eval q{
CORE::require Mac::Files;
Mac::Files::FSpSetFLock($realfilename);
};
}
elsif (exists $ENV{'CHAR_NONBLOCK'}) {
CORE::eval q{ flock($fh, LOCK_SH | LOCK_NB) };
if ($@) {
carp "Can't immediately read-lock the file: $realfilename";
}
}
lib/Ebig5plus.pm view on Meta::CPAN
# foreach $prefix (@INC) {
# $realfilename = "$prefix/$filename";
# if (-f $realfilename) {
# $INC{$filename} = $realfilename;
# $result = do $realfilename;
# last ITER;
# }
# }
# die "Can't find $filename in \@INC";
# }
# if ($@) {
# $INC{$filename} = undef;
# die $@;
# }
# elsif (!$result) {
# delete $INC{$filename};
# die "$filename did not return true value";
# }
# else {
# return $result;
# }
# }
sub Ebig5plus::require(;$) {
local $_ = shift if @_;
if (exists $INC{$_}) {
return 1 if $INC{$_};
croak "Compilation failed in require: $_";
}
# jcode.pl
# ftp://ftp.iij.ad.jp/pub/IIJ/dist/utashiro/perl/
# jacode.pl
# http://search.cpan.org/dist/jacode/
if (/ \b (?: jcode\.pl | jacode(?>[0-9]*)\.pl ) \z /oxms) {
return CORE::require($_);
}
my $realfilename;
my $result;
ITER_REQUIRE:
{
for my $prefix (@INC) {
if ($^O eq 'MacOS') {
$realfilename = "$prefix$_";
}
else {
$realfilename = "$prefix/$_";
}
if (Ebig5plus::f($realfilename)) {
$INC{$_} = $realfilename;
my $script = '';
if (Ebig5plus::e("$realfilename.e")) {
my $e_mtime = (Ebig5plus::stat("$realfilename.e"))[9];
my $mtime = (Ebig5plus::stat($realfilename))[9];
my $module_mtime = (Ebig5plus::stat(__FILE__))[9];
if (($e_mtime < $mtime) or ($mtime < $module_mtime)) {
Ebig5plus::unlink "$realfilename.e";
}
}
if (Ebig5plus::e("$realfilename.e")) {
my $fh = gensym();
_open_r($fh, "$realfilename.e") or croak "Can't open file: $realfilename.e";
if ($^O eq 'MacOS') {
CORE::eval q{
CORE::require Mac::Files;
Mac::Files::FSpSetFLock("$realfilename.e");
};
}
elsif (exists $ENV{'CHAR_NONBLOCK'}) {
CORE::eval q{ flock($fh, LOCK_SH | LOCK_NB) };
if ($@) {
carp "Can't immediately read-lock the file: $realfilename.e";
}
}
else {
CORE::eval q{ flock($fh, LOCK_SH) };
}
local $/ = undef; # slurp mode
$script = <$fh>;
if ($^O eq 'MacOS') {
CORE::eval q{
CORE::require Mac::Files;
Mac::Files::FSpRstFLock("$realfilename.e");
};
}
close($fh) or croak "Can't close file: $realfilename: $!";
}
else {
my $fh = gensym();
_open_r($fh, $realfilename) or croak "Can't open file: $realfilename";
if ($^O eq 'MacOS') {
CORE::eval q{
CORE::require Mac::Files;
Mac::Files::FSpSetFLock($realfilename);
};
}
elsif (exists $ENV{'CHAR_NONBLOCK'}) {
CORE::eval q{ flock($fh, LOCK_SH | LOCK_NB) };
if ($@) {
carp "Can't immediately read-lock the file: $realfilename";
}
}
else {
CORE::eval q{ flock($fh, LOCK_SH) };
}
local $/ = undef; # slurp mode
$script = <$fh>;
if ($^O eq 'MacOS') {
CORE::eval q{
CORE::require Mac::Files;
Mac::Files::FSpRstFLock($realfilename);
};
}
close($fh) or croak "Can't close file: $realfilename: $!";
lib/Ebig5plus.pm view on Meta::CPAN
$i++;
}
print STDERR CORE::reverse @cluck;
print STDERR "\n";
print STDERR @_;
}
#
# instead of Carp::confess
#
sub confess {
my $i = 0;
my @confess = ();
while (my($package,$filename,$line,$subroutine) = caller($i)) {
push @confess, "[$i] $filename($line) $package::$subroutine\n";
$i++;
}
print STDERR CORE::reverse @confess;
print STDERR "\n";
print STDERR @_;
die "\n";
}
1;
__END__
=pod
=head1 NAME
Ebig5plus - Run-time routines for Big5Plus.pm
=head1 SYNOPSIS
use Ebig5plus;
Ebig5plus::split(...);
Ebig5plus::tr(...);
Ebig5plus::chop(...);
Ebig5plus::index(...);
Ebig5plus::rindex(...);
Ebig5plus::lc(...);
Ebig5plus::lc_;
Ebig5plus::lcfirst(...);
Ebig5plus::lcfirst_;
Ebig5plus::uc(...);
Ebig5plus::uc_;
Ebig5plus::ucfirst(...);
Ebig5plus::ucfirst_;
Ebig5plus::fc(...);
Ebig5plus::fc_;
Ebig5plus::ignorecase(...);
Ebig5plus::capture(...);
Ebig5plus::chr(...);
Ebig5plus::chr_;
Ebig5plus::X ...;
Ebig5plus::X_;
Ebig5plus::glob(...);
Ebig5plus::glob_;
Ebig5plus::lstat(...);
Ebig5plus::lstat_;
Ebig5plus::opendir(...);
Ebig5plus::stat(...);
Ebig5plus::stat_;
Ebig5plus::unlink(...);
Ebig5plus::chdir(...);
Ebig5plus::do(...);
Ebig5plus::require(...);
Ebig5plus::telldir(...);
# "no Ebig5plus;" not supported
=head1 ABSTRACT
This module has run-time routines for use Big5Plus software automatically, you
do not have to use.
=head1 BUGS AND LIMITATIONS
I have tested and verified this software using the best of my ability.
However, a software containing much regular expression is bound to contain
some bugs. Thus, if you happen to find a bug that's in Big5Plus software and not
your own program, you can try to reduce it to a minimal test case and then
report it to the following author's address. If you have an idea that could
make this a more useful tool, please let everyone share it.
=head1 HISTORY
This Ebig5plus module first appeared in ActivePerl Build 522 Built under
MSWin32 Compiled at Nov 2 1999 09:52:28
=head1 AUTHOR
INABA Hitoshi E<lt>ina@cpan.orgE<gt>
This project was originated by INABA Hitoshi.
For any questions, use E<lt>ina@cpan.orgE<gt> so we can share
this file.
=head1 LICENSE AND COPYRIGHT
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself. See L<perlartistic>.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
=head1 EXAMPLES
=over 2
=item * Split string
@split = Ebig5plus::split(/pattern/,$string,$limit);
@split = Ebig5plus::split(/pattern/,$string);
@split = Ebig5plus::split(/pattern/);
@split = Ebig5plus::split('',$string,$limit);
@split = Ebig5plus::split('',$string);
@split = Ebig5plus::split('');
@split = Ebig5plus::split();
@split = Ebig5plus::split;
lib/Ebig5plus.pm view on Meta::CPAN
Available in MSWin32, MacOS, and UNIX-like systems
------------------------------------------------------------------------------
Subroutine and Prototype Meaning
------------------------------------------------------------------------------
Ebig5plus::s(*), Ebig5plus::s_() File or directory exists and has nonzero size
(the value is the size in bytes)
------------------------------------------------------------------------------
=item * Filename expansion (globbing)
@glob = Ebig5plus::glob($string);
@glob = Ebig5plus::glob_;
This subroutine returns the value of $string with filename expansions the way a
DOS-like shell would expand them, returning the next successive name on each
call. If $string is omitted, $_ is globbed instead. This is the internal
subroutine implementing the <*> and glob operator.
This subroutine function when the pathname ends with chr(0x5C) on MSWin32.
For ease of use, the algorithm matches the DOS-like shell's style of expansion,
not the UNIX-like shell's. An asterisk ("*") matches any sequence of any
character (including none). A question mark ("?") matches any one character or
none. A tilde ("~") expands to a home directory, as in "~/.*rc" for all the
current user's "rc" files, or "~jane/Mail/*" for all of Jane's mail files.
Note that all path components are case-insensitive, and that backslashes and
forward slashes are both accepted, and preserved. You may have to double the
backslashes if you are putting them in literally, due to double-quotish parsing
of the pattern by perl.
The Ebig5plus::glob subroutine grandfathers the use of whitespace to separate multiple
patterns such as <*.c *.h>. If you want to glob filenames that might contain
whitespace, you'll have to use extra quotes around the spacy filename to protect
it. For example, to glob filenames that have an "e" followed by a space followed
by an "f", use either of:
@spacies = <"*e f*">;
@spacies = Ebig5plus::glob('"*e f*"');
@spacies = Ebig5plus::glob(q("*e f*"));
If you had to get a variable through, you could do this:
@spacies = Ebig5plus::glob("'*${var}e f*'");
@spacies = Ebig5plus::glob(qq("*${var}e f*"));
Another way on MSWin32
# relative path
@relpath_file = split(/\n/,`dir /b wildcard\\here*.txt 2>NUL`);
# absolute path
@abspath_file = split(/\n/,`dir /s /b wildcard\\here*.txt 2>NUL`);
# on COMMAND.COM
@relpath_file = split(/\n/,`dir /b wildcard\\here*.txt`);
@abspath_file = split(/\n/,`dir /s /b wildcard\\here*.txt`);
=item * Statistics about link
@lstat = Ebig5plus::lstat($file);
@lstat = Ebig5plus::lstat_;
Like Ebig5plus::stat, returns information on file, except that if file is a symbolic
link, Ebig5plus::lstat returns information about the link; Ebig5plus::stat returns
information about the file pointed to by the link. If symbolic links are
unimplemented on your system, a normal Ebig5plus::stat is done instead. If file is
omitted, returns information on file given in $_. Returns values (especially
device and inode) may be bogus.
This subroutine function when the filename ends with chr(0x5C) on MSWin32.
=item * Open directory handle
$rc = Ebig5plus::opendir(DIR,$dir);
This subroutine opens a directory named $dir for processing by readdir, telldir,
seekdir, rewinddir, and closedir. The subroutine returns true if successful.
Directory handles have their own namespace from filehandles.
This subroutine function when the directory name ends with chr(0x5C) on MSWin32.
=item * Statistics about file
$stat = Ebig5plus::stat(FILEHANDLE);
$stat = Ebig5plus::stat(DIRHANDLE);
$stat = Ebig5plus::stat($expr);
$stat = Ebig5plus::stat_;
@stat = Ebig5plus::stat(FILEHANDLE);
@stat = Ebig5plus::stat(DIRHANDLE);
@stat = Ebig5plus::stat($expr);
@stat = Ebig5plus::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) = Ebig5plus::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
vRefnum for MacOS
1 $ino Inode number
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
10 $ctime Inode change time (not creation time!) since the epoch
creation time instead of inode change time for MSWin32
since 1904-01-01 00:00:00 for MacOS
11 $blksize Preferred blocksize for file system I/O
zero for MSWin32
12 $blocks Actual number of blocks allocated
zero for MSWin32
int(($size + $blksize-1) / $blksize) for MacOS
-------------------------------------------------------------------------
$dev and $ino, token together, uniquely identify a file on the same system.
The $blksize and $blocks are likely defined only on BSD-derived filesystems.
The $blocks field (if defined) is reported in 512-byte blocks. The value of
$blocks * 512 can differ greatly from $size for files containing unallocated
blocks, or "hole", which aren't counted in $blocks.
If Ebig5plus::stat is passed the special filehandle consisting of an underline, no
actual stat(2) is done, but the current contents of the stat structure from
the last Ebig5plus::stat, Ebig5plus::lstat, or Ebig5plus::stat-based file test subroutine
(such as Ebig5plus::r, Ebig5plus::w, and Ebig5plus::x) are returned.
Because the mode contains both the file type and its permissions, you should
mask off the file type portion and printf or sprintf using a "%o" if you want
to see the real permissions:
$mode = (Ebig5plus::stat($expr))[2];
printf "Permissions are %04o\n", $mode & 07777;
If $expr is omitted, returns information on file given in $_.
This subroutine function when the filename ends with chr(0x5C) on MSWin32.
=item * Deletes a list of files.
$unlink = Ebig5plus::unlink(@list);
$unlink = Ebig5plus::unlink($file);
$unlink = Ebig5plus::unlink;
Delete a list of files. (Under Unix, it will remove a link to a file, but the
file may still exist if another link references it.) If list is omitted, it
unlinks the file given in $_. The subroutine returns the number of files
successfully deleted.
This subroutine function when the filename ends with chr(0x5C) on MSWin32.
=item * Changes the working directory.
$chdir = Ebig5plus::chdir($dirname);
$chdir = Ebig5plus::chdir;
This subroutine changes the current process's working directory to $dirname, if
possible. If $dirname is omitted, $ENV{'HOME'} is used if set, and $ENV{'LOGDIR'}
otherwise; these are usually the process's home directory. The subroutine returns
true on success, false otherwise (and puts the error code into $!).
chdir("$prefix/lib") || die "Can't cd to $prefix/lib: $!";
This subroutine has limitation on the MSWin32. See also BUGS AND LIMITATIONS.
=item * Do file
$return = Ebig5plus::do($file);
The do FILE form uses the value of FILE as a filename and executes the contents
of the file as a Perl script. Its primary use is (or rather was) to include
subroutines from a Perl subroutine library, so that:
Ebig5plus::do('stat.pl');
is rather like:
scalar CORE::eval `cat stat.pl`; # `type stat.pl` on Windows
except that Ebig5plus::do is more efficient, more concise, keeps track of the current
filename for error messages, searches all the directories listed in the @INC
array, and updates %INC if the file is found.
It also differs in that code evaluated with Ebig5plus::do FILE can not see lexicals in
the enclosing scope, whereas code in CORE::eval FILE does. It's the same, however,
in that it reparses the file every time you call it -- so you might not want to do
this inside a loop unless the filename itself changes at each loop iteration.
If Ebig5plus::do can't read the file, it returns undef and sets $! to the error. If
Ebig5plus::do can read the file but can't compile it, it returns undef and sets an
error message in $@. If the file is successfully compiled, do returns the value of
the last expression evaluated.
Inclusion of library modules (which have a mandatory .pm suffix) is better done
with the use and require operators, which also Ebig5plus::do error checking and raise
( run in 2.304 seconds using v1.01-cache-2.11-cpan-d8267643d1d )