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

NAME

Char::Elatin4 - Run-time routines for Char/Latin4.pm

SYNOPSIS

  use Char::Elatin4;

    Char::Elatin4::split(...);
    Char::Elatin4::tr(...);
    Char::Elatin4::chop(...);
    Char::Elatin4::index(...);
    Char::Elatin4::rindex(...);
    Char::Elatin4::lc(...);
    Char::Elatin4::lc_;
    Char::Elatin4::lcfirst(...);
    Char::Elatin4::lcfirst_;
    Char::Elatin4::uc(...);
    Char::Elatin4::uc_;
    Char::Elatin4::ucfirst(...);
    Char::Elatin4::ucfirst_;
    Char::Elatin4::ignorecase(...);
    Char::Elatin4::capture(...);
    Char::Elatin4::chr(...);
    Char::Elatin4::chr_;
    Char::Elatin4::glob(...);
    Char::Elatin4::glob_;

  # "no Char::Elatin4;" not supported

ABSTRACT

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

BUGS AND LIMITATIONS

Please patches and report problems to author are welcome.

HISTORY

This Char::Elatin4 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 = Char::Elatin4::split(/pattern/,$string,$limit);
  @split = Char::Elatin4::split(/pattern/,$string);
  @split = Char::Elatin4::split(/pattern/);
  @split = Char::Elatin4::split('',$string,$limit);
  @split = Char::Elatin4::split('',$string);
  @split = Char::Elatin4::split('');
  @split = Char::Elatin4::split();
  @split = Char::Elatin4::split;

  Scans a Latin-4 $string for delimiters that match pattern and splits the Latin-4
  $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 Latin-4
  $string on every match. If the pattern doesn't match at all, Char::Elatin4::split returns
  the original Latin-4 $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 Latin-4 $string is omitted, the function splits the $_ Latin-4 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.
Transliteration
  $tr = Char::Elatin4::tr($variable,$bind_operator,$searchlist,$replacementlist,$modifier);
  $tr = Char::Elatin4::tr($variable,$bind_operator,$searchlist,$replacementlist);

  This function scans a Latin-4 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 Latin-4 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 = Char::Elatin4::chop(@list);
  $chop = Char::Elatin4::chop();
  $chop = Char::Elatin4::chop;

  Chops off the last character of a Latin-4 string contained in the variable (or
  Latin-4 strings in each element of a @list) and returns the character chopped.
  The Char::Elatin4::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 = Char::Elatin4::index($string,$substr,$position);
  $pos = Char::Elatin4::index($string,$substr);

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

  Works just like Char::Elatin4::index except that it returns the position of the last
  occurence of $substr in Latin-4 $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 Latin-4 string the function can search.
Lower case string
  $lc = Char::Elatin4::lc($string);
  $lc = Char::Elatin4::lc_;

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

  Returns a version of Latin-4 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 = Char::Elatin4::uc($string);
  $uc = Char::Elatin4::uc_;

  Returns an uppercased version of Latin-4 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 = Char::Elatin4::ucfirst($string);
  $ucfirst = Char::Elatin4::ucfirst_;

  Returns a version of Latin-4 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 = Char::Elatin4::ignorecase(@string);

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

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

  This function returns the character represented by that $code in the character
  set. For example, Char::Elatin4::chr(65) is "A" in either ASCII or Latin-4, and
  Char::Elatin4::chr(0x82a0) is a Latin-4 HIRAGANA LETTER A. For the reverse of Char::Elatin4::chr,
  use Char::Latin4::ord.
Filename expansion (globbing)
  @glob = Char::Elatin4::glob($string);
  @glob = Char::Elatin4::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')>.
binary mode (Perl5.6 emulation on perl5.005)
  Char::Elatin4::binmode(FILEHANDLE, $disciplines);
  Char::Elatin4::binmode(FILEHANDLE);
  Char::Elatin4::binmode($filehandle, $disciplines);
  Char::Elatin4::binmode($filehandle);

  * two arguments

  If you are using perl5.005 other than MacPerl, Char::Latin4 software emulate perl5.6's
  binmode function. Only the point is here. See also perlfunc/binmode for details.

  This function arranges for the FILEHANDLE to have the semantics specified by the
  $disciplines argument. If $disciplines is omitted, ':raw' semantics are applied
  to the filehandle. If FILEHANDLE is an expression, the value is taken as the
  name of the filehandle or a reference to a filehandle, as appropriate.
  The binmode function should be called after the open but before any I/O is done
  on the filehandle. The only way to reset the mode on a filehandle is to reopen
  the file, since the various disciplines may have treasured up various bits and
  pieces of data in various buffers.

  The ":raw" discipline tells Perl to keep its cotton-pickin' hands off the data.
  For more on how disciplines work, see the open function.
open file (Perl5.6 emulation on perl5.005)
  $rc = Char::Elatin4::open(FILEHANDLE, $mode, $expr);
  $rc = Char::Elatin4::open(FILEHANDLE, $expr);
  $rc = Char::Elatin4::open(FILEHANDLE);
  $rc = Char::Elatin4::open(my $filehandle, $mode, $expr);
  $rc = Char::Elatin4::open(my $filehandle, $expr);
  $rc = Char::Elatin4::open(my $filehandle);

  * autovivification filehandle
  * three arguments

  If you are using perl5.005, Char::Latin4 software emulate perl5.6's open function.
  Only the point is here. See also perlfunc/open for details.

  As that example shows, the FILEHANDLE argument is often just a simple identifier
  (normally uppercase), but it may also be an expression whose value provides a
  reference to the actual filehandle. (The reference may be either a symbolic
  reference to the filehandle name or a hard reference to any object that can be
  interpreted as a filehandle.) This is called an indirect filehandle, and any
  function that takes a FILEHANDLE as its first argument can handle indirect
  filehandles as well as direct ones. But open is special in that if you supply
  it with an undefined variable for the indirect filehandle, Perl will automatically
  define that variable for you, that is, autovivifying it to contain a proper
  filehandle reference.

  {
      my $fh;                          # (uninitialized)
      Char::Elatin4::open($fh, ">logfile")     # $fh is autovivified
          or die "Can't create logfile: $!";
          ...                          # do stuff with $fh
  }                                    # $fh closed here

  The my $fh declaration can be readably incorporated into the open:

  Char::Elatin4::open my $fh, ">logfile" or die ...

  The > symbol you've been seeing in front of the filename is an example of a mode.
  Historically, the two-argument form of open came first. The recent addition of
  the three-argument form lets you separate the mode from the filename, which has
  the advantage of avoiding any possible confusion between the two. In the following
  example, we know that the user is not trying to open a filename that happens to
  start with ">". We can be sure that they're specifying a $mode of ">", which opens
  the file named in $expr for writing, creating the file if it doesn't exist and
  truncating the file down to nothing if it already exists:

  Char::Elatin4::open(LOG, ">", "logfile") or die "Can't create logfile: $!";

  With the one- or two-argument form of open, you have to be careful when you use
  a string variable as a filename, since the variable may contain arbitrarily
  weird characters (particularly when the filename has been supplied by arbitrarily
  weird characters on the Internet). If you're not careful, parts of the filename
  might get interpreted as a $mode string, ignorable whitespace, a dup specification,
  or a minus.
  Here's one historically interesting way to insulate yourself:

  $path =~ s#^([ ])#./$1#;
  Char::Elatin4::open (FH, "< $path\0") or die "can't open $path: $!";

  But that's still broken in several ways. Instead, just use the three-argument
  form of open to open any arbitrary filename cleanly and without any (extra)
  security risks:

  Char::Elatin4::open(FH, "<", $path) or die "can't open $path: $!";

  As of the 5.6 release of Perl, you can specify binary mode in the open function
  without a separate call to binmode. As part of the $mode
  argument (but only in the three-argument form), you may specify various input
  and output disciplines.
  To do the equivalent of a binmode, use the three argument form of open and stuff
  a discipline of :raw in after the other $mode characters:

  Char::Elatin4::open(FH, "<:raw", $path) or die "can't open $path: $!";

  Table 1. I/O Disciplines
  -------------------------------------------------
  Discipline      Meaning
  -------------------------------------------------
  :raw            Binary mode; do no processing
  :crlf           Text mode; Intuit newlines
                  (DOS-like system only)
  :encoding(...)  Legacy encoding
  -------------------------------------------------

  You'll be able to stack disciplines that make sense to stack, so, for instance,
  you could say:

  Char::Elatin4::open(FH, "<:crlf:encoding(Char::Latin4)", $path) or die "can't open $path: $!";