Arabic

 view release on metacpan or  search on metacpan

lib/Arabic.pm  view on Meta::CPAN

  ---------------------
  use Arabic;
  ---------------------

=head1 Calling 'Earabic::ignorecase()' (Arabic software provides)

Arabic software applies calling 'Earabic::ignorecase()' instead of /i modifier.

  --------------------------------------------------------------------------------
  Before                  After
  --------------------------------------------------------------------------------
  m/...$var.../i          m/...@{[Earabic::ignorecase($var)]}.../
  --------------------------------------------------------------------------------

=head1 Escaping Character Classes (Earabic.pm provides)

The character classes are redefined as follows to backward compatibility.

  ---------------------------------------------------------------
  Before        After
  ---------------------------------------------------------------
   .            ${Earabic::dot}
                ${Earabic::dot_s}    (/s modifier)
  \d            [0-9]              (universally)
  \s            \s
  \w            [0-9A-Z_a-z]       (universally)
  \D            ${Earabic::eD}
  \S            ${Earabic::eS}
  \W            ${Earabic::eW}
  \h            [\x09\x20]
  \v            [\x0A\x0B\x0C\x0D]
  \H            ${Earabic::eH}
  \V            ${Earabic::eV}
  \C            [\x00-\xFF]
  \X            X                  (so, just 'X')
  \R            ${Earabic::eR}
  \N            ${Earabic::eN}
  ---------------------------------------------------------------

Also POSIX-style character classes.

  ---------------------------------------------------------------
  Before        After
  ---------------------------------------------------------------
  [:alnum:]     [\x30-\x39\x41-\x5A\x61-\x7A]
  [:alpha:]     [\x41-\x5A\x61-\x7A]
  [:ascii:]     [\x00-\x7F]
  [:blank:]     [\x09\x20]
  [:cntrl:]     [\x00-\x1F\x7F]
  [:digit:]     [\x30-\x39]
  [:graph:]     [\x21-\x7F]
  [:lower:]     [\x61-\x7A]
                [\x41-\x5A\x61-\x7A]     (/i modifier)
  [:print:]     [\x20-\x7F]
  [:punct:]     [\x21-\x2F\x3A-\x3F\x40\x5B-\x5F\x60\x7B-\x7E]
  [:space:]     [\s\x0B]
  [:upper:]     [\x41-\x5A]
                [\x41-\x5A\x61-\x7A]     (/i modifier)
  [:word:]      [\x30-\x39\x41-\x5A\x5F\x61-\x7A]
  [:xdigit:]    [\x30-\x39\x41-\x46\x61-\x66]
  [:^alnum:]    ${Earabic::not_alnum}
  [:^alpha:]    ${Earabic::not_alpha}
  [:^ascii:]    ${Earabic::not_ascii}
  [:^blank:]    ${Earabic::not_blank}
  [:^cntrl:]    ${Earabic::not_cntrl}
  [:^digit:]    ${Earabic::not_digit}
  [:^graph:]    ${Earabic::not_graph}
  [:^lower:]    ${Earabic::not_lower}
                ${Earabic::not_lower_i}    (/i modifier)
  [:^print:]    ${Earabic::not_print}
  [:^punct:]    ${Earabic::not_punct}
  [:^space:]    ${Earabic::not_space}
  [:^upper:]    ${Earabic::not_upper}
                ${Earabic::not_upper_i}    (/i modifier)
  [:^word:]     ${Earabic::not_word}
  [:^xdigit:]   ${Earabic::not_xdigit}
  ---------------------------------------------------------------

\b and \B are redefined as follows to backward compatibility.

  ---------------------------------------------------------------
  Before      After
  ---------------------------------------------------------------
  \b          ${Earabic::eb}
  \B          ${Earabic::eB}
  ---------------------------------------------------------------

Definitions in Earabic.pm.

  ---------------------------------------------------------------------------------------------------------------------------------------------------------
  After                    Definition
  ---------------------------------------------------------------------------------------------------------------------------------------------------------
  ${Earabic::dot}            qr{(?>[^\x0A])};
  ${Earabic::dot_s}          qr{(?>[\x00-\xFF])};
  ${Earabic::eD}             qr{(?>[^0-9])};
  ${Earabic::eS}             qr{(?>[^\s])};
  ${Earabic::eW}             qr{(?>[^0-9A-Z_a-z])};
  ${Earabic::eH}             qr{(?>[^\x09\x20])};
  ${Earabic::eV}             qr{(?>[^\x0A\x0B\x0C\x0D])};
  ${Earabic::eR}             qr{(?>\x0D\x0A|[\x0A\x0D])};
  ${Earabic::eN}             qr{(?>[^\x0A])};
  ${Earabic::not_alnum}      qr{(?>[^\x30-\x39\x41-\x5A\x61-\x7A])};
  ${Earabic::not_alpha}      qr{(?>[^\x41-\x5A\x61-\x7A])};
  ${Earabic::not_ascii}      qr{(?>[^\x00-\x7F])};
  ${Earabic::not_blank}      qr{(?>[^\x09\x20])};
  ${Earabic::not_cntrl}      qr{(?>[^\x00-\x1F\x7F])};
  ${Earabic::not_digit}      qr{(?>[^\x30-\x39])};
  ${Earabic::not_graph}      qr{(?>[^\x21-\x7F])};
  ${Earabic::not_lower}      qr{(?>[^\x61-\x7A])};
  ${Earabic::not_lower_i}    qr{(?>[^\x41-\x5A\x61-\x7A])}; # Perl 5.16 compatible
# ${Earabic::not_lower_i}    qr{(?>[\x00-\xFF])};                   # older Perl compatible
  ${Earabic::not_print}      qr{(?>[^\x20-\x7F])};
  ${Earabic::not_punct}      qr{(?>[^\x21-\x2F\x3A-\x3F\x40\x5B-\x5F\x60\x7B-\x7E])};
  ${Earabic::not_space}      qr{(?>[^\s\x0B])};
  ${Earabic::not_upper}      qr{(?>[^\x41-\x5A])};
  ${Earabic::not_upper_i}    qr{(?>[^\x41-\x5A\x61-\x7A])}; # Perl 5.16 compatible
# ${Earabic::not_upper_i}    qr{(?>[\x00-\xFF])};                   # older Perl compatible
  ${Earabic::not_word}       qr{(?>[^\x30-\x39\x41-\x5A\x5F\x61-\x7A])};
  ${Earabic::not_xdigit}     qr{(?>[^\x30-\x39\x41-\x46\x61-\x66])};
  
  # This solution is not perfect. I beg better solution from you who are reading this.
  ${Earabic::eb}             qr{(?:\A(?=[0-9A-Z_a-z])|(?<=[\x00-\x2F\x40\x5B-\x5E\x60\x7B-\xFF])(?=[0-9A-Z_a-z])|(?<=[0-9A-Z_a-z])(?=[\x00-\x2F\x40\x5B-\x5E\x60\x7B-\xFF]|\z))};
  ${Earabic::eB}             qr{(?:(?<=[0-9A-Z_a-z])(?=[0-9A-Z_a-z])|(?<=[\x00-\x2F\x40\x5B-\x5E\x60\x7B-\xFF])(?=[\x00-\x2F\x40\x5B-\x5E\x60\x7B-\xFF]))};
  ---------------------------------------------------------------------------------------------------------------------------------------------------------

=head1 Un-Escaping \ of \b{}, \B{}, \N{}, \p{}, \P{}, and \X (Arabic software provides)

Arabic software removes '\' at head of alphanumeric regexp metasymbols \b{}, \B{},
\N{}, \p{}, \P{} and \X. By this method, you can avoid the trap of the abstraction.

See also,
Deprecate literal unescaped "{" in regexes.
http://perl5.git.perl.org/perl.git/commit/2a53d3314d380af5ab5283758219417c6dfa36e9

  ------------------------------------
  Before           After
  ------------------------------------
  \b{...}          b\{...}
  \B{...}          B\{...}
  \N{CHARNAME}     N\{CHARNAME}
  \p{L}            p\{L}
  \p{^L}           p\{^L}
  \p{\^L}          p\{\^L}
  \pL              pL
  \P{L}            P\{L}
  \P{^L}           P\{^L}
  \P{\^L}          P\{\^L}
  \PL              PL
  \X               X
  ------------------------------------

=head1 Escaping Built-in Functions (Arabic software provides)

Insert 'Earabic::' at head of function name. Earabic.pm provides your script Earabic::*
subroutines.

  -------------------------------------------
  Before      After            Works as
  -------------------------------------------
  lc          Earabic::lc        Character
  lcfirst     Earabic::lcfirst   Character
  uc          Earabic::uc        Character
  ucfirst     Earabic::ucfirst   Character
  fc          Earabic::fc        Character
  chr         Earabic::chr       Character
  glob        Earabic::glob      Character
  -------------------------------------------

  ------------------------------------------------------------------------------------------------------------------------
  Before                   After
  ------------------------------------------------------------------------------------------------------------------------
  use Perl::Module;        BEGIN { require 'Perl/Module.pm'; Perl::Module->import() if Perl::Module->can('import'); }
  use Perl::Module @list;  BEGIN { require 'Perl/Module.pm'; Perl::Module->import(@list) if Perl::Module->can('import'); }
  use Perl::Module ();     BEGIN { require 'Perl/Module.pm'; }
  no Perl::Module;         BEGIN { require 'Perl/Module.pm'; Perl::Module->unimport() if Perl::Module->can('unimport'); }
  no Perl::Module @list;   BEGIN { require 'Perl/Module.pm'; Perl::Module->unimport(@list) if Perl::Module->can('unimport'); }
  no Perl::Module ();      BEGIN { require 'Perl/Module.pm'; }
  ------------------------------------------------------------------------------------------------------------------------



( run in 1.917 second using v1.01-cache-2.11-cpan-9581c071862 )