view release on metacpan or search on metacpan
5855865875885895905915925935945955965975985996006016026036046050.31 2009-01-29 00:00:00
- create test data file on execute test.pl
- rewrite all about
"split"
logic
- created by INABA Hitoshi
0.30 2009-01-04 00:00:00
- support context
when
calling
lc
(),
lc
,
uc
(),
uc
- support
chr
(0x5C) ended path on MSWin32
- file test operators
- functions
lstat
(),
opendir
(),
stat
(), and
unlink
()
-
glob
() and <WILDCARD>
- remove pl2ebat.bat, jperl55.bat, jperl58.bat, and jperl510.bat
- merge esjis.pl into Sjis.pm
- matched variables $1,$2,$3,...
after
s/// came to function as it was a description
- support function of
chr
,
ord
, and
reverse
again
- add test filetest, pathdir, pathfile, and perlmemo
- created at kanmi-kissa Hahaso in Chichibu
0.29 2008-11-20 00:00:00
- remove \G from
$your_gap
lib/Ehp15.pm view on Meta::CPAN
334335336337338339340341342343344345346347348349350351352353354355356357sub
Ehp15::u_();
sub
Ehp15::g_();
sub
Ehp15::k_();
sub
Ehp15::T_();
sub
Ehp15::B_();
sub
Ehp15::M_();
sub
Ehp15::A_();
sub
Ehp15::C_();
sub
Ehp15::
glob
($);
sub
Ehp15::glob_();
sub
Ehp15::
lstat
(*);
sub
Ehp15::lstat_();
sub
Ehp15::
opendir
(*$);
sub
Ehp15::
stat
(*);
sub
Ehp15::stat_();
sub
Ehp15::
unlink
(@);
sub
Ehp15::
chdir
(;$);
sub
Ehp15::
do
($);
sub
Ehp15::
require
(;$);
sub
Ehp15::
telldir
(*);
sub
HP15::
ord
(;$);
sub
HP15::ord_();
sub
HP15::
reverse
(@);
lib/Ehp15.pm view on Meta::CPAN
459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626
# For example, "nobody"-like users might use /nonexistant
if
(
defined
$home
and ! Ehp15::d(
$home
)) {
$home
=
undef
;
}
return
$home
;
}
#
# HP-15 file lstat (with parameter)
#
sub
Ehp15::
lstat
(*) {
local
$_
=
shift
if
@_
;
if
(-e
$_
) {
return
CORE::
lstat
_;
}
elsif
(_MSWin32_5Cended_path(
$_
)) {
# Even if ${^WIN32_SLOPPY_STAT} is set to a true value, Ehp15::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
;
}
lib/Ehp15.pm view on Meta::CPAN
4673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706
if
(CORE::
opendir
$dh
,
"$_[1]/."
) {
return
1;
}
}
return
undef
;
}
#
# HP-15 file stat (with parameter)
#
sub
Ehp15::
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, Ehp15::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
;
}
lib/Ehp15.pm view on Meta::CPAN
50915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113}
else
{
$realfilename
=
"$prefix/$filename"
;
}
if
(Ehp15::f(
$realfilename
)) {
my
$script
=
''
;
if
(Ehp15::e(
"$realfilename.e"
)) {
my
$e_mtime
= (Ehp15::
stat
(
"$realfilename.e"
))[9];
my
$mtime
= (Ehp15::
stat
(
$realfilename
))[9];
my
$module_mtime
= (Ehp15::
stat
(__FILE__))[9];
if
((
$e_mtime
<
$mtime
) or (
$mtime
<
$module_mtime
)) {
Ehp15::
unlink
"$realfilename.e"
;
}
}
if
(Ehp15::e(
"$realfilename.e"
)) {
my
$fh
= gensym();
if
(_open_r(
$fh
,
"$realfilename.e"
)) {
if
($^O eq
'MacOS'
) {
CORE::
eval
q{
lib/Ehp15.pm view on Meta::CPAN
53235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345else
{
$realfilename
=
"$prefix/$_"
;
}
if
(Ehp15::f(
$realfilename
)) {
$INC
{
$_
} =
$realfilename
;
my
$script
=
''
;
if
(Ehp15::e(
"$realfilename.e"
)) {
my
$e_mtime
= (Ehp15::
stat
(
"$realfilename.e"
))[9];
my
$mtime
= (Ehp15::
stat
(
$realfilename
))[9];
my
$module_mtime
= (Ehp15::
stat
(__FILE__))[9];
if
((
$e_mtime
<
$mtime
) or (
$mtime
<
$module_mtime
)) {
Ehp15::
unlink
"$realfilename.e"
;
}
}
if
(Ehp15::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{
lib/Ehp15.pm view on Meta::CPAN
113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399
Ehp15::fc(...);
Ehp15::fc_;
Ehp15::ignorecase(...);
Ehp15::capture(...);
Ehp15::
chr
(...);
Ehp15::chr_;
Ehp15::X ...;
Ehp15::X_;
Ehp15::
glob
(...);
Ehp15::glob_;
Ehp15::
lstat
(...);
Ehp15::lstat_;
Ehp15::
opendir
(...);
Ehp15::
stat
(...);
Ehp15::stat_;
Ehp15::
unlink
(...);
Ehp15::
chdir
(...);
Ehp15::
do
(...);
Ehp15::
require
(...);
Ehp15::
telldir
(...);
# "no Ehp15;" not supported
=head1 ABSTRACT
lib/Ehp15.pm view on Meta::CPAN
1199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014
# 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 = Ehp15::lstat($file);
@lstat = Ehp15::lstat_;
Like Ehp15::stat, returns information on file, except that if file is a symbolic
link, Ehp15::lstat returns information about the link; Ehp15::stat returns
information about the file pointed to by the link. If symbolic links are
unimplemented on your system, a normal Ehp15::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.
lib/Ehp15.pm view on Meta::CPAN
120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052
$rc
= Ehp15::
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 = Ehp15::stat(FILEHANDLE);
$stat = Ehp15::stat(DIRHANDLE);
$stat = Ehp15::stat($expr);
$stat = Ehp15::stat_;
@stat = Ehp15::stat(FILEHANDLE);
@stat = Ehp15::stat(DIRHANDLE);
@stat = Ehp15::stat($expr);
@stat = Ehp15::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) = Ehp15::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
lib/Ehp15.pm view on Meta::CPAN
1208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110
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 Ehp15::
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
Ehp15::
stat
, Ehp15::
lstat
, or Ehp15::
stat
-based file test subroutine
(such as Ehp15::r, Ehp15::w, and Ehp15::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
= (Ehp15::
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 = Ehp15::unlink(@list);
$unlink = Ehp15::unlink($file);
$unlink = Ehp15::unlink;
lib/HP15.pm view on Meta::CPAN
166167168169170171172173174175176177178179180181182183184185186187
#
# Filter >
# Source >>>
# Escape >>>>> executable without re-escape
#
# Filter >>>
# Source >
# Escape >>>>> executable without re-escape
#----------------------------------------------------
my
$mtime_filter
= (Ehp15::
stat
(__FILE__ ))[9];
my
$mtime_source
= (Ehp15::
stat
(
$filename
))[9];
my
$mtime_escape
= (Ehp15::
stat
(
"$filename.e"
))[9];
if
((
$mtime_escape
<
$mtime_source
) or (
$mtime_escape
<
$mtime_filter
)) {
Ehp15::
unlink
"$filename.e"
;
}
}
}
if
(not Ehp15::e(
"$filename.e"
)) {
my
$fh
= gensym();
Ehp15::_open_a(
$fh
,
"$filename.e"
) or
die
__FILE__,
": Can't write open file: $filename.e\n"
;
lib/HP15.pm view on Meta::CPAN
222223224225226227228229230231232233234235236237238239240241242
else
{
CORE::
eval
q{ flock($fh, LOCK_EX) }
;
}
CORE::
eval
q{ truncate($fh, 0) }
;
seek
(
$fh
, 0, 0) or
die
__FILE__,
": Can't seek file: $filename.e\n"
;
my
$e_script
= HP15::escape_script(
$filename
);
{
$fh
}
$e_script
;
my
$mode
= (Ehp15::
stat
(
$filename
))[2] & 0777;
chmod
$mode
,
"$filename.e"
;
close
(
$fh
) or
die
"Can't close file: $filename.e: $!"
;
}
my
$fh
= gensym();
Ehp15::_open_r(
$fh
,
"$filename.e"
) or
die
__FILE__,
": Can't read open file: $filename.e\n"
;
if
(0) {
}
lib/HP15.pm view on Meta::CPAN
207220732074207520762077207820792080208120822083208420852086208720882089209020912092=item * Unicode Properties (aka Character Properties) of Regular Expression
Unicode properties (aka character properties) of regexp are not available.
Also (?[]) in regexp of Perl 5.18 is not available. There is no plans to currently
support these.
=item * ${^WIN32_SLOPPY_STAT} is ignored
Even if ${^WIN32_SLOPPY_STAT} is set to a true value, file test functions Ehp15::*(),
Ehp15::lstat(), and Ehp15::stat() on Microsoft Windows open the file for the path
which has chr(0x5c) at end.
=item * Delimiter of String and Regexp
qq//, q//, qw//, qx//, qr//, m//, s///, tr///, and y/// can't use a wide character
as the delimiter.
=item * \b{...} Boundaries in Regular Expressions
Following \b{...} available starting in v5.22 are not supported.
t/HP15/207_stat.t view on Meta::CPAN
29303132333435363738394041424344454647484950515253545556575859606162636465666768close
(FILE);
open
(FILE,
'>D‹@”\/c.txt'
) ||
die
"Can't open file: D‹@”\/c.txt\n"
;
FILE
"1\n"
;
close
(FILE);
open
(FILE,
'>D‹@”\/F‹@”\') || die "Can'
t
open
file: D‹@”\/F‹@”\\n";
FILE
"1\n"
;
close
(FILE);
mkdir
('D‹@”\/D‹@”\', 0777);
$_
= 'F‹@”\';
if
(
@_
=
stat
(
$_
)) {
"ok - 1 $^X $__FILE__\n"
;
}
else
{
"not ok - 1 $^X $__FILE__\n"
;
}
$_
= 'D‹@”\';
if
(
@_
=
stat
(
$_
)) {
"not ok - 2 $^X $__FILE__\n"
;
}
else
{
"ok - 2 $^X $__FILE__\n"
;
}
unlink
('F‹@”\');
rmdir
('D‹@”\/D‹@”\');
unlink
(
'D‹@”\/a.txt'
);
unlink
(
'D‹@”\/b.txt'
);
unlink
(
'D‹@”\/c.txt'
);
unlink
('D‹@”\/F‹@”\');
rmdir
('D‹@”\');
__END__
Perlƒƒ‚/Windows‚ł̃tƒ@ƒCƒ‹ƒpƒX
ƒtƒ@ƒCƒ‹ŠÖ˜AƒRƒ}ƒ“ƒh‚Ì“®ìŠm”F
u‹@”\v‚Æ‚¢‚¤•¶Žš—ñ‚ð•Ï”$_‚É“ü‚êAstat($_)‚Æ‚µ‚Ä‚à•Ô‚è’l‚ª‚È‚¢
t/HP15/215_lstat.t view on Meta::CPAN
1415161718192021222324252627282930313233if
(
$chcp
!~ /932/oxms) {
"ok - 1 # SKIP $^X $0\n"
;
exit
;
}
open
(FILE,
'>F‹@”\') || die "Can'
t
open
file: F‹@”\\n";
FILE
"1\n"
;
close
(FILE);
# lstat
if
(
lstat
('F‹@”\')) {
"ok - 1 lstat $^X $__FILE__\n"
;
}
else
{
"not ok - 1 lstat: $! $^X $__FILE__\n"
;
}
unlink
('F‹@”\');
__END__
t/HP15/220_stat.t view on Meta::CPAN
1415161718192021222324252627282930313233if
(
$chcp
!~ /932/oxms) {
"ok - 1 # SKIP $^X $0\n"
;
exit
;
}
open
(FILE,
'>F‹@”\') || die "Can'
t
open
file: F‹@”\\n";
FILE
"1\n"
;
close
(FILE);
# stat
if
(
stat
('F‹@”\')) {
"ok - 1 stat $^X $__FILE__\n"
;
}
else
{
"not ok - 1 stat: $! $^X $__FILE__\n"
;
}
unlink
('F‹@”\');
__END__