Char-UHC
view release on metacpan or search on metacpan
lib/Euhc.pm view on Meta::CPAN
print STDERR "\n";
print STDERR @_;
die "\n";
}
1;
__END__
=pod
=head1 NAME
Euhc - Run-time routines for UHC.pm
=head1 SYNOPSIS
use Euhc;
Euhc::split(...);
Euhc::tr(...);
Euhc::chop(...);
Euhc::index(...);
Euhc::rindex(...);
Euhc::lc(...);
Euhc::lc_;
Euhc::lcfirst(...);
Euhc::lcfirst_;
Euhc::uc(...);
Euhc::uc_;
Euhc::ucfirst(...);
Euhc::ucfirst_;
Euhc::fc(...);
Euhc::fc_;
Euhc::ignorecase(...);
Euhc::capture(...);
Euhc::chr(...);
Euhc::chr_;
Euhc::X ...;
Euhc::X_;
Euhc::glob(...);
Euhc::glob_;
Euhc::lstat(...);
Euhc::lstat_;
Euhc::opendir(...);
Euhc::stat(...);
Euhc::stat_;
Euhc::unlink(...);
Euhc::chdir(...);
Euhc::do(...);
Euhc::require(...);
Euhc::telldir(...);
# "no Euhc;" not supported
=head1 ABSTRACT
This module has run-time routines for use UHC 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 UHC 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 Euhc 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 = Euhc::split(/pattern/,$string,$limit);
@split = Euhc::split(/pattern/,$string);
@split = Euhc::split(/pattern/);
@split = Euhc::split('',$string,$limit);
@split = Euhc::split('',$string);
@split = Euhc::split('');
@split = Euhc::split();
@split = Euhc::split;
This subroutine scans a string given by $string for separators, and splits the
string into a list of substring, returning the resulting list value in list
context or the count of substring in scalar context. Scalar context also causes
split to write its result to @_, but this usage is deprecated. The separators
are determined by repeated pattern matching, using the regular expression given
in /pattern/, so the separators may be of any size and need not be the same
string on every match. (The separators are not ordinarily returned; exceptions
are discussed later in this section.) If the /pattern/ doesn't match the string
at all, Euhc::split returns the original string as a single substring, If it
matches once, you get two substrings, and so on. You may supply regular
expression modifiers to the /pattern/, like /pattern/i, /pattern/x, etc. The
//m modifier is assumed when you split on the pattern /^/.
If $limit is specified and positive, the subroutine splits into no more than that
many fields (though it may split into fewer if it runs out of separators). If
lib/Euhc.pm view on Meta::CPAN
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 Euhc::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 Euhc::stat, Euhc::lstat, or Euhc::stat-based file test subroutine
(such as Euhc::r, Euhc::w, and Euhc::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 = (Euhc::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 = Euhc::unlink(@list);
$unlink = Euhc::unlink($file);
$unlink = Euhc::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 = Euhc::chdir($dirname);
$chdir = Euhc::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 = Euhc::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:
Euhc::do('stat.pl');
is rather like:
scalar CORE::eval `cat stat.pl`; # `type stat.pl` on Windows
except that Euhc::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 Euhc::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 Euhc::do can't read the file, it returns undef and sets $! to the error. If
Euhc::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 Euhc::do error checking and raise
an exception if there's a problem. They also offer other benefits: they avoid
duplicate loading, help with object-oriented programming, and provide hints to the
compiler on function prototypes.
But Euhc::do FILE is still useful for such things as reading program configuration
files. Manual error checking can be done this way:
# read in config files: system first, then user
for $file ("/usr/share/proggie/defaults.rc", "$ENV{HOME}/.someprogrc") {
unless ($return = Euhc::do($file)) {
warn "couldn't parse $file: $@" if $@;
warn "couldn't Euhc::do($file): $!" unless defined $return;
warn "couldn't run $file" unless $return;
}
}
A long-running daemon could periodically examine the timestamp on its configuration
file, and if the file has changed since it was last read in, the daemon could use
Euhc::do to reload that file. This is more tidily accomplished with Euhc::do than
with Euhc::require.
=item * Require file
Euhc::require($file);
Euhc::require();
This subroutine asserts a dependency of some kind on its argument. If an argument is
not supplied, $_ is used.
Euhc::require loads and executes the Perl code found in the separate file whose
( run in 2.700 seconds using v1.01-cache-2.11-cpan-99c4e6809bf )