INABA Hitoshi > Char-EUCJP > Char::Eeucjp



Annotate this POD

View/Report Bugs
Module Version: 0.96   Source  


Char::Eeucjp - Run-time routines for Char/


  use Char::Eeucjp;


  # "no Char::Eeucjp;" not supported






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


INABA Hitoshi <>






Split string
  @split = Char::Eeucjp::split(/pattern/,$string,$limit);
  @split = Char::Eeucjp::split(/pattern/,$string);
  @split = Char::Eeucjp::split(/pattern/);
  @split = Char::Eeucjp::split('',$string,$limit);
  @split = Char::Eeucjp::split('',$string);
  @split = Char::Eeucjp::split('');
  @split = Char::Eeucjp::split();
  @split = Char::Eeucjp::split;

  are determined by repeated pattern matching, using the regular expression given
  at all, Char::Eeucjp::split returns the original string as a single substring, If it

  skipping any leading whitespace.

  use otherwise.

  String of any length can be split:

  @chars  = Char::Eeucjp::split(//,  $word);
  @fields = Char::Eeucjp::split(/:/, $line);
  @words  = Char::Eeucjp::split(" ", $paragraph);
  @lines  = Char::Eeucjp::split(/^/, $buffer);

  wherever it matches the null string between characters; nonnull matches will
  width.) For example:

  print join(":" => Char::Eeucjp::split(/ */, "hi there"));

  Char::Eeucjp::split's pattern is exempt from that wrinkle.)

  The $limit parameter splits only part of a string:

  my ($login, $passwd, $remainder) = Char::Eeucjp::split(/:/, $_, 3);


  returned. Here's a simple example:

  Char::Eeucjp::split(/([-,])/, "1-10,20");

  which produces the list value:


  if you say:

  Char::Eeucjp::split(/(-)|(,)/, "1-10,20");

  you get the value:


  once, use /$variable/o.

  splits on whitespace just as Char::Eeucjp::split with no arguments does. Thus,
  Char::Eeucjp::split(" ") can be used to emulate awk's default behavior. In contrast,
  Char::Eeucjp::split(/ /) will give you as many null initial fields as there are
  string and to collapse intervaning stretches of whitespace into a single

  $string = join(" ", Char::Eeucjp::split(" ", $string));

  The following example splits an RFC822 message header into a hash containing

  %head = ("FRONTSTUFF", Char::Eeucjp::split(/^(\S*?):\s*/m, $header));


  open(PASSWD, "/etc/passwd");
  while (<PASSWD>) {
      chomp; # remove trailing newline.

  word-frequency hash.

  while (<>) {
      for my $word (Char::Eeucjp::split()) {

  The inverse of Char::Eeucjp::split is join, except that join can only join with the
  fields, use unpack.

  $tr = Char::Eeucjp::tr($variable,$bind_operator,$searchlist,$replacementlist,$modifier);

  This is the transliteration (sometimes erroneously called translation) operator,
  everybody's humble opinion.

  This subroutine scans a EUC-JP string character by character and replaces all
  occurrences of the characters found in $searchlist with the corresponding character
  If no EUC-JP 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.
  r          Return transliteration and leave the original string untouched.


  print Char::Eeucjp::tr('bookkeeper','=~','boep','peob','r'); # prints 'peekkoobor'
Chop string
  $chop = Char::Eeucjp::chop(@list);
  $chop = Char::Eeucjp::chop();
  $chop = Char::Eeucjp::chop;

  character chopped. The Char::Eeucjp::chop subroutine is used primary to remove the newline
  since Char::Eeucjp::chop always shortens the string no matter what's there, and chomp

  You cannot Char::Eeucjp::chop a literal, only a variable. If you Char::Eeucjp::chop a list of
  variables, each string in the list is chopped:

  @lines = `cat myfile`;

  You can Char::Eeucjp::chop anything that is an lvalue, including an assignment:

  Char::Eeucjp::chop($cwd = `pwd`);
  Char::Eeucjp::chop($answer = <STDIN>);

  This is different from:

  $answer = Char::Eeucjp::chop($tmp = <STDIN>); # WRONG

  which puts a newline into $answer because Char::Eeucjp::chop returns the character
  intended here is with substr:


  But this is more commonly written as:


  In the most general case, Char::Eeucjp::chop can be expressed using substr:

  $last_code = Char::Eeucjp::chop($var);

  Char::Eeucjp::chop more than one character, use substr as an lvalue, assigning a null

  substr($caravan, -5) = '';

  form of substr, creating something of a quintuple Char::Eeucjp::chop;


Index string
  $byte_pos = Char::Eeucjp::index($string,$substr,$byte_offset);
  $byte_pos = Char::Eeucjp::index($string,$substr);


  $byte_pos = -1;
  while (($byte_pos = Char::Eeucjp::index($string, $lookfor, $byte_pos)) > -1) {
      print "Found at $byte_pos\n";
Reverse index string
  $byte_pos = Char::Eeucjp::rindex($string,$substr,$byte_offset);
  $byte_pos = Char::Eeucjp::rindex($string,$substr);

  This subroutine works just like Char::Eeucjp::index except that it returns the byte
  position of the last occurrence of $substring in $string (a reverse Char::Eeucjp::index).
  string backward, say:

  $byte_pos = length($string);
  while (($byte_pos = Char::EUCJP::rindex($string, $lookfor, $byte_pos)) >= 0) {
      print "Found at $byte_pos\n";
Lower case string
  $lc = Char::Eeucjp::lc($string);
  $lc = Char::Eeucjp::lc_;

  This subroutine returns a lowercased version of EUC-JP $string (or $_, if
  in double-quoted strings.

  You can use the Char::Eeucjp::fc subroutine for case-insensitive comparisons via Char::EUCJP
Lower case first character of string
  $lcfirst = Char::Eeucjp::lcfirst($string);
  $lcfirst = Char::Eeucjp::lcfirst_;

  This subroutine returns a version of EUC-JP $string with the first character
  implementing the \l escape in double-quoted strings.
Upper case string
  $uc = Char::Eeucjp::uc($string);
  $uc = Char::Eeucjp::uc_;

  This subroutine returns an uppercased version of EUC-JP $string (or $_, if
  in interpolated strings. For titlecase, use Char::Eeucjp::ucfirst instead.

Upper case first character of string
  $ucfirst = Char::Eeucjp::ucfirst($string);
  $ucfirst = Char::Eeucjp::ucfirst_;

  double-quoted strings.

  to lowercase, use:

  $titlecase = Char::Eeucjp::ucfirst(substr($word,0,1)) . Char::Eeucjp::lc(substr($word,1));



  Do not use:

  $do_not_use = Char::Eeucjp::ucfirst(Char::Eeucjp::lc($word));

  certain characters. The titlecase of something that's been lowercased doesn't
  always produce the same thing titlecasing the original produces.

  every character in a string.

  See also P.287 A Case of Mistaken Identity
  in Chapter 6: Unicode
Fold case string
  P.860 fc
  in Chapter 27: Functions

  $fc = Char::Eeucjp::fc($string);
  $fc = Char::Eeucjp::fc_;

  New to Char::EUCJP software, this subroutine returns the full Unicode-like casefold of
  EUC-JP $string (or $_, if omitted). This is the internal subroutine implementing
  the \F escape in double-quoted strings.



  Char::Eeucjp::fc($a) eq Char::Eeucjp::fc($b)

  modifier, because Char::EUCJP software has always used casefolding semantics for
  comparisons like this:

  sub fc_eq ($$) {
      my($a,$b) = @_;
Make ignore case string
  @ignorecase = Char::Eeucjp::ignorecase(@string);

Make capture number
  $capturenumber = Char::Eeucjp::capture($string);

Make character
  $chr = Char::Eeucjp::chr($code);
  $chr = Char::Eeucjp::chr_;

  This subroutine returns a programmer-visible character, character represented by
  that $code in the character set. For example, Char::Eeucjp::chr(65) is "A" in either
  ASCII or EUC-JP, not Unicode. For the reverse of Char::Eeucjp::chr, use Char::EUCJP::ord.
Filename expansion (globbing)
  @glob = Char::Eeucjp::glob($string);
  @glob = Char::Eeucjp::glob_;

  subroutine implementing the <*> and glob operator.


  of the pattern by perl.

  The Char::Eeucjp::glob subroutine grandfathers the use of whitespace to separate multiple
  by an "f", use either of:

  @spacies = <"*e f*">;
  @spacies = Char::Eeucjp::glob('"*e f*"');
  @spacies = Char::Eeucjp::glob(q("*e f*"));


  @spacies = Char::Eeucjp::glob("'*${var}e f*'");
  @spacies = Char::Eeucjp::glob(qq("*${var}e f*"));

  Another way on MSWin32

  # relative path

  # absolute path

syntax highlighting: