The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Ebig5plus - Run-time routines for Big5Plus.pm

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::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

ABSTRACT

This module is a run-time routines of the Big5Plus.pm. Because the Big5Plus.pm automatically uses this module, you need not use directly.

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.

HISTORY

This Ebig5plus module first appeared in ActivePerl Build 522 Built under MSWin32 Compiled at Nov 2 1999 09:52:28

AUTHOR

INABA Hitoshi <ina@cpan.org>

This project was originated by INABA Hitoshi. For any questions, use <ina@cpan.org> so we can share this file.

LICENSE AND COPYRIGHT

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See 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.

EXAMPLES

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;

  Scans a Big5Plus $string for delimiters that match pattern and splits the Big5Plus
  $string into a list of substrings, returning the resulting list value in list
  context, or the count of substrings in scalar context. The delimiters are
  determined by repeated pattern matching, using the regular expression given in
  pattern, so the delimiters may be of any size and need not be the same Big5Plus
  $string on every match. If the pattern doesn't match at all, Ebig5plus::split returns
  the original Big5Plus $string as a single substring. If it matches once, you get
  two substrings, and so on.
  If $limit is specified and is not negative, the function splits into no more than
  that many fields. If $limit is negative, it is treated as if an arbitrarily large
  $limit has been specified. If $limit is omitted, trailing null fields are stripped
  from the result (which potential users of pop would do well to remember).
  If Big5Plus $string is omitted, the function splits the $_ Big5Plus string.
  If $patten is also omitted, the function splits on whitespace, /\s+/, after
  skipping any leading whitespace.
  If the pattern contains parentheses, then the substring matched by each pair of
  parentheses is included in the resulting list, interspersed with the fields that
  are ordinarily returned.
  Unlike Perl4, you cannot force the split into @_ by using ?? as the pattern
  delimiters, it only returns the list value.
Transliteration
  $tr = Ebig5plus::tr($variable,$bind_operator,$searchlist,$replacementlist,$modifier);
  $tr = Ebig5plus::tr($variable,$bind_operator,$searchlist,$replacementlist);

  This function scans a Big5Plus string character by character and replaces all
  occurrences of the characters found in $searchlist with the corresponding character
  in $replacementlist. It returns the number of characters replaced or deleted.
  If no Big5Plus string is specified via =~ operator, the $_ variable is translated.
  $modifier are:

  ------------------------------------------------------
  Modifier   Meaning
  ------------------------------------------------------
  c          Complement $searchlist
  d          Delete found but unreplaced characters
  s          Squash duplicate replaced characters
  ------------------------------------------------------
Chop string
  $chop = Ebig5plus::chop(@list);
  $chop = Ebig5plus::chop();
  $chop = Ebig5plus::chop;

  Chops off the last character of a Big5Plus string contained in the variable (or
  Big5Plus strings in each element of a @list) and returns the character chopped.
  The Ebig5plus::chop operator is used primarily to remove the newline from the end of
  an input record but is more efficient than s/\n$//. If no argument is given, the
  function chops the $_ variable.
Index string
  $pos = Ebig5plus::index($string,$substr,$position);
  $pos = Ebig5plus::index($string,$substr);

  Returns the position of the first occurrence of $substr in Big5Plus $string.
  The start, if specified, specifies the $position to start looking in the Big5Plus
  $string. Positions are integer numbers based at 0. If the substring is not found,
  the Ebig5plus::index function returns -1.
Reverse index string
  $pos = Ebig5plus::rindex($string,$substr,$position);
  $pos = Ebig5plus::rindex($string,$substr);

  Works just like Ebig5plus::index except that it returns the position of the last
  occurence of $substr in Big5Plus $string (a reverse index). The function returns
  -1 if not found. $position, if specified, is the rightmost position that may be
  returned, i.e., how far in the Big5Plus string the function can search.
Lower case string
  $lc = Ebig5plus::lc($string);
  $lc = Ebig5plus::lc_;

  Returns a lowercase version of Big5Plus string (or $_, if omitted). This is the
  internal function implementing the \L escape in double-quoted strings.
Lower case first character of string
  $lcfirst = Ebig5plus::lcfirst($string);
  $lcfirst = Ebig5plus::lcfirst_;

  Returns a version of Big5Plus string (or $_, if omitted) with the first character
  lowercased. This is the internal function implementing the \l escape in double-
  quoted strings.
Upper case string
  $uc = Ebig5plus::uc($string);
  $uc = Ebig5plus::uc_;

  Returns an uppercased version of Big5Plus string (or $_, if string is omitted).
  This is the internal function implementing the \U escape in double-quoted
  strings.
Upper case first character of string
  $ucfirst = Ebig5plus::ucfirst($string);
  $ucfirst = Ebig5plus::ucfirst_;

  Returns a version of Big5Plus string (or $_, if omitted) with the first character
  uppercased. This is the internal function implementing the \u escape in double-
  quoted strings.
Make ignore case string
  @ignorecase = Ebig5plus::ignorecase(@string);

  This function is internal use to m/ /i, s/ / /i, split / /i and qr/ /i.
Make capture number
  $capturenumber = Ebig5plus::capture($string);

  This function is internal use to m/ /, s/ / /, split / / and qr/ /.
Make character
  $chr = Ebig5plus::chr($code);
  $chr = Ebig5plus::chr_;

  This function returns the character represented by that $code in the character
  set. For example, Ebig5plus::chr(65) is "A" in either ASCII or Big5Plus, not Unicode,
  and Ebig5plus::chr(0x82a0) is a Big5Plus HIRAGANA LETTER A. For the reverse of
  Ebig5plus::chr, use Big5Plus::ord.
File test operator -X
  A file test operator is an unary operator that tests a pathname or a filehandle.
  If $string is omitted, it uses $_ by function Ebig5plus::r_.
  The following functions function when the pathname ends with chr(0x5C) on MSWin32.

  $test = Ebig5plus::r $string;
  $test = Ebig5plus::r_;

  Returns 1 when true case or '' when false case.
  Returns undef unless successful.

  ------------------------------------------------------------------------------
  Function and Prototype     Meaning
  ------------------------------------------------------------------------------
  Ebig5plus::r(*), Ebig5plus::r_()   File is readable by effective uid/gid
  Ebig5plus::w(*), Ebig5plus::w_()   File is writable by effective uid/gid
  Ebig5plus::x(*), Ebig5plus::x_()   File is executable by effective uid/gid
  Ebig5plus::o(*), Ebig5plus::o_()   File is owned by effective uid
  Ebig5plus::R(*), Ebig5plus::R_()   File is readable by real uid/gid
  Ebig5plus::W(*), Ebig5plus::W_()   File is writable by real uid/gid
  Ebig5plus::X(*), Ebig5plus::X_()   File is executable by real uid/gid
  Ebig5plus::O(*), Ebig5plus::O_()   File is owned by real uid
  Ebig5plus::e(*), Ebig5plus::e_()   File exists
  Ebig5plus::z(*), Ebig5plus::z_()   File has zero size
  Ebig5plus::f(*), Ebig5plus::f_()   File is a plain file
  Ebig5plus::d(*), Ebig5plus::d_()   File is a directory
  Ebig5plus::l(*), Ebig5plus::l_()   File is a symbolic link
  Ebig5plus::p(*), Ebig5plus::p_()   File is a named pipe (FIFO)
  Ebig5plus::S(*), Ebig5plus::S_()   File is a socket
  Ebig5plus::b(*), Ebig5plus::b_()   File is a block special file
  Ebig5plus::c(*), Ebig5plus::c_()   File is a character special file
  Ebig5plus::u(*), Ebig5plus::u_()   File has setuid bit set
  Ebig5plus::g(*), Ebig5plus::g_()   File has setgid bit set
  Ebig5plus::k(*), Ebig5plus::k_()   File has sticky bit set
  ------------------------------------------------------------------------------

  Returns 1 when true case or '' when false case.
  Returns undef unless successful.

  The Ebig5plus::T, Ebig5plus::T_, Ebig5plus::B and Ebig5plus::B_ work as follows. The first block
  or so of the file is examined for strange chatracters such as
  [\000-\007\013\016-\032\034-\037\377] (that don't look like Big5Plus). If more
  than 10% of the bytes appear to be strange, it's a *maybe* binary file;
  otherwise, it's a *maybe* text file. Also, any file containing ASCII NUL(\0) or
  \377 in the first block is considered a binary file. If Ebig5plus::T or Ebig5plus::B is
  used on a filehandle, the current input (standard I/O or "stdio") buffer is
  examined rather than the first block of the file. Both Ebig5plus::T and Ebig5plus::B
  return 1 as true on an empty file, or on a file at EOF (end-of-file) when testing
  a filehandle. Both Ebig5plus::T and Ebig5plus::B deosn't work when given the special
  filehandle consisting of a solitary underline.

  ------------------------------------------------------------------------------
  Function and Prototype     Meaning
  ------------------------------------------------------------------------------
  Ebig5plus::T(*), Ebig5plus::T_()   File is a text file
  Ebig5plus::B(*), Ebig5plus::B_()   File is a binary file (opposite of -T)
  ------------------------------------------------------------------------------

  Returns useful value if successful, or undef unless successful.

  $value = Ebig5plus::s $string;
  $value = Ebig5plus::s_;

  ------------------------------------------------------------------------------
  Function and Prototype     Meaning
  ------------------------------------------------------------------------------
  Ebig5plus::s(*), Ebig5plus::s_()   File has nonzero size (returns size in bytes)
  Ebig5plus::M(*), Ebig5plus::M_()   Age of file (at startup) in days since modification
  Ebig5plus::A(*), Ebig5plus::A_()   Age of file (at startup) in days since last access
  Ebig5plus::C(*), Ebig5plus::C_()   Age of file (at startup) in days since inode change
  ------------------------------------------------------------------------------
Filename expansion (globbing)
  @glob = Ebig5plus::glob($string);
  @glob = Ebig5plus::glob_;

  Performs filename expansion (DOS-like globbing) on $string, returning the next
  successive name on each call. If $string is omitted, $_ is globbed instead.
  This function function when the pathname ends with chr(0x5C) on MSWin32.

  For example, C<<..\\l*b\\file/*glob.p?>> on MSWin32 or UNIX will work as
  expected (in that it will find something like '..\lib\File/DosGlob.pm'
  alright).
  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.
  A tilde ("~") expands to the current user's home directory.

  Spaces in the argument delimit distinct patterns, so C<glob('*.exe *.dll')> globs
  all filenames that end in C<.exe> or C<.dll>. If you want to put in literal spaces
  in the glob pattern, you can escape them with either double quotes.
  e.g. C<glob('c:/"Program Files"/*/*.dll')>.
  @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 $_.
  This function function when the filename ends with chr(0x5C) on MSWin32.
Open directory handle
  $rc = Ebig5plus::opendir(DIR,$dir);

  Opens a directory for processing by readdir, telldir, seekdir, rewinddir and
  closedir. The function returns true if successful.
  This function function when the directory name ends with chr(0x5C) on MSWin32.
Statistics about file
  @stat = Ebig5plus::stat($file);
  @stat = Ebig5plus::stat_;

  Returns a 13-element list giving the statistics for a file, indicated by either
  a filehandle or an expression that gives its name. It's typically used as
  follows:

  ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
      $atime,$mtime,$ctime,$blksize,$blocks) = Ebig5plus::stat($file);

  Not all fields are supported on all filesystem types. Here are the meanings of
  the fields:

  -----------------------------------------------------------------
  Field     Meaning
  -----------------------------------------------------------------
  dev       Device number of filesystem
  ino       Inode number
  mode      File mode (type and permissions)
  nlink     Nunmer of (hard) links to the file
  uid       Numeric user ID of file's owner
  gid       Numeric group ID of file's owner
  rdev      The device identifier (special files only)
  size      Total size of file, in bytes
  atime     Last access time since the epoch
  mtime     Last modification time since the epoch
  ctime     Inode change time (not creation time!) since the epoch
  blksize   Preferred blocksize for file system I/O
  blocks    Actual number of blocks allocated
  -----------------------------------------------------------------

  $dev and $ino, token together, uniquely identify a file. The $blksize and
  $blocks are likely defined only on BSD-derived filesystem. The $blocks field
  (if defined) is reported in 512-byte blocks.
  If stat is passed the special filehandle consisting of an underline, no
  actual stat is done, but the current contents of the stat structure from the
  last stat or stat-based file test (the -x operators) is returned.
  If file is omitted, returns information on file given in $_.
  This function function when the filename ends with chr(0x5C) on MSWin32.
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 function returns the number of files
  successfully deleted.
  This function function when the filename ends with chr(0x5C) on MSWin32.
Changes the working directory.
  $chdir = Ebig5plus::chdir($dirname);
  $chdir = Ebig5plus::chdir;

  Changes the working directory to $dirname, if possible. If $dirname is omitted,
  it changes to the home directory. The function returns 1 upon success, 0
  otherwise (and puts the error code into $!).

  This function can't function when the $dirname ends with chr(0x5C) on perl5.006,
  perl5.008, perl5.010, perl5.012, perl5.014 on MSWin32.
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 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 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
  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 Ebig5plus::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 = Ebig5plus::do($file)) {
          warn "couldn't parse $file: $@" if $@;
          warn "couldn't Ebig5plus::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
  Ebig5plus::do to reload that file. This is more tidily accomplished with Ebig5plus::do than
  with Ebig5plus::require.
require file
  Ebig5plus::require($file);
  Ebig5plus::require();

  This function asserts a dependency of some kind on its argument. If an argument is not
  supplied, $_ is used.

  If the argument is a string, Ebig5plus::require loads and executes the Perl code found in
  the separate file whose name is given by the string. This is similar to performing a
  Ebig5plus::do on a file, except that Ebig5plus::require checks to see whether the library
  file has been loaded already and raises an exception if any difficulties are
  encountered. (It can thus be used to express file dependencies without worrying about
  duplicate compilation.) Like its cousins Ebig5plus::do and use, Ebig5plus::require knows how
  to search the include path stored in the @INC array and to update %INC upon success.

  The file must return true as the last value to indicate successful execution of any
  initialization code, so it's customary to end such a file with 1; unless you're sure
  it'll return true otherwise.

  See also do file.
current position of the readdir
  $telldir = Ebig5plus::telldir(DIRHANDLE);

  This function returns the current position of the readdir routines on DIRHANDLE.
  This value may be given to seekdir to access a particular location in a directory.
  The function has the same caveats about possible directory compaction as the
  corresponding system library routine. This function might not be implemented
  everywhere that readdir is. Even if it is, no calculation may be done with the
  return value. It's just an opaque value, meaningful only to seekdir.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 6175:

=over without closing =back