Big5HKSCS

 view release on metacpan or  search on metacpan

lib/Big5HKSCS.pm  view on Meta::CPAN

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#
# Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2018, 2019 INABA Hitoshi <ina@cpan.org>
######################################################################
 
use 5.00503;    # Galapagos Consensus 1998 for primetools
# use 5.008001; # Lancaster Consensus 2013 for toolchains
 
# 12.3. Delaying use Until Runtime
# in Chapter 12. Packages, Libraries, and Modules
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
# (and so on)
 
# Version numbers should be boring
# For the impatient, the disinterested or those who just want to follow
# a recipe, my advice for all modules is this:
# our $VERSION = "0.001"; # or "0.001_001" for a dev release
# $VERSION = CORE::eval $VERSION; # No!! because '1.10' makes '1.1'
 
use vars qw($VERSION);

lib/Big5HKSCS.pm  view on Meta::CPAN

78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
sub LOCK_SH() {1}
sub LOCK_EX() {2}
sub LOCK_UN() {8}
sub LOCK_NB() {4}
 
sub unimport {}
sub Big5HKSCS::escape_script;
 
# 6.18. Matching Multiple-Byte Characters
# in Chapter 6. Pattern Matching
# of ISBN 978-1-56592-243-3 Perl Perl Cookbook.
# (and so on)
 
# regexp of character
my $qq_char   = qr/(?> \\c[\x40-\x5F] | \\? (?:[\x81-\xFE][\x00-\xFF] | [\x00-\xFF]) )/oxms;
my  $q_char   = qr/(?> [\x81-\xFE][\x00-\xFF] | [\x00-\xFF] )/oxms;
 
# when this script is main program
if ($0 eq __FILE__) {
 
    # show usage

lib/Big5HKSCS.pm  view on Meta::CPAN

182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
        }
    }
}
 
if (not Ebig5hkscs::e("$filename.e")) {
    my $fh = gensym();
    Ebig5hkscs::_open_a($fh, "$filename.e") or die __FILE__, ": Can't write open file: $filename.e\n";
 
    # 7.19. Flushing Output
    # in Chapter 7. File Access
    # of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
 
    select((select($fh), $|=1)[0]);
 
    if (0) {
    }
    elsif (exists $ENV{'CHAR_NONBLOCK'}) {
 
        # P.419 File Locking
        # in Chapter 16: Interprocess Communication
        # of ISBN 0-596-00027-8 Programming Perl Third Edition.

lib/Big5HKSCS.pm  view on Meta::CPAN

2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
Programming Perl, 4th Edition
By: Tom Christiansen, brian d foy, Larry Wall, Jon Orwant
Publisher: O'Reilly Media
Formats: Print, Ebook, Safari Books Online
Released: March 2012
Pages: 1130
Print ISBN: 978-0-596-00492-7 | ISBN 10: 0-596-00492-3
Ebook ISBN: 978-1-4493-9890-3 | ISBN 10: 1-4493-9890-1
 
Perl Cookbook
By Tom Christiansen, Nathan Torkington
August 1998
Pages: 800
ISBN 10: 1-56592-243-3 | ISBN 13: 978-1-56592-243-3
 
Perl Cookbook, Second Edition
By Tom Christiansen, Nathan Torkington
Second Edition  August 2003
Pages: 964
ISBN 10: 0-596-00313-7 | ISBN 13: 9780596003135
 
Perl in a Nutshell, Second Edition
By Stephen Spainhour, Ellen Siever, Nathan Patwardhan
Second Edition  June 2002
Pages: 760

lib/Big5HKSCS.pm  view on Meta::CPAN

2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
ISBN 10: 0-596-00289-0 | ISBN 13: 9780596002893
 
Mastering Regular Expressions, Third Edition
By Jeffrey E. F. Friedl
Third Edition  August 2006
Pages: 542
ISBN 10: 0-596-52812-4 | ISBN 13:9780596528126
 
Regular Expressions Cookbook
By Jan Goyvaerts, Steven Levithan
May 2009
Pages: 512
ISBN 10:0-596-52068-9 | ISBN 13: 978-0-596-52068-7
 
Regular Expressions Cookbook, 2nd Edition
By Jan Goyvaerts, Steven Levithan
Final Release Date: August 2012
Pages: 612
ISBN: 978-1-4493-1943-4 | ISBN 10:1-4493-1943-2
 
JIS KANJI JITEN
By Kouji Shibano
Pages: 1456
ISBN 4-542-20129-5

lib/Ebig5hkscs.pm  view on Meta::CPAN

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#
# Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2018, 2019 INABA Hitoshi <ina@cpan.org>
######################################################################
 
use 5.00503;    # Galapagos Consensus 1998 for primetools
# use 5.008001; # Lancaster Consensus 2013 for toolchains
 
# 12.3. Delaying use Until Runtime
# in Chapter 12. Packages, Libraries, and Modules
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
# (and so on)
 
# Version numbers should be boring
# For the impatient, the disinterested or those who just want to follow
# a recipe, my advice for all modules is this:
# our $VERSION = "0.001"; # or "0.001_001" for a dev release
# $VERSION = eval $VERSION; # No!! because '1.10' makes '1.1'
 
use vars qw($VERSION);

lib/Ebig5hkscs.pm  view on Meta::CPAN

139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
sub LOCK_NB() {4}
 
# instead of Carp.pm
sub carp;
sub croak;
sub cluck;
sub confess;
 
# 6.18. Matching Multiple-Byte Characters
# in Chapter 6. Pattern Matching
# of ISBN 978-1-56592-243-3 Perl Perl Cookbook.
# (and so on)
 
# regexp of character
my $your_char = q{[\x81-\xFE][\x00-\xFF]|[\x00-\xFF]};
use vars qw($qq_char); $qq_char = qr/\\c[\x40-\x5F]|\\?(?:$your_char)/oxms;
use vars qw($q_char)$q_char  = qr/$your_char/oxms;
 
#
# Big5-HKSCS character range per length
#

lib/Ebig5hkscs.pm  view on Meta::CPAN

1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
    my $s = $_;
    return join '', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg);
}
 
#
# Big5-HKSCS regexp capture
#
{
    # 10.3. Creating Persistent Private Variables
    # in Chapter 10. Subroutines
    # of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
 
    my $last_s_matched = 0;
 
    sub Ebig5hkscs::capture {
        if ($last_s_matched and ($_[0] =~ /\A (?>[1-9][0-9]*) \z/oxms)) {
            return $_[0] + 1;
        }
        return $_[0];
    }

lib/Ebig5hkscs.pm  view on Meta::CPAN

3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
            if (_open_r($fh, $_)) {
                my $r = -r $fh;
                close($fh) or die "Can't close file: $_: $!";
                return $r ? 1 : '';
            }
        }
    }
 
# 10.10. Returning Failure
# in Chapter 10. Subroutines
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
# (and so on)
 
# 2010-01-26 The difference of "return;" and "return undef;"
#
# "Perl Best Practices" recommends to use "return;"*1 to return nothing, but
# it might be wrong in some cases. If you use this idiom for those functions
# which are expected to return a scalar value, e.g. searching functions, the
# user of those functions will be surprised at what they return in list
# context, an empty list - note that many functions and all the methods

lib/Ebig5hkscs.pm  view on Meta::CPAN

4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
# context (keyed by second cxix argument provided by core)
my($expr,$cxix) = @_;
 
# glob without args defaults to $_
$expr = $_ if not defined $expr;
 
# represents the current user's home directory
#
# 7.3. Expanding Tildes in Filenames
# in Chapter 7. File Access
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
#
# and File::HomeDir, File::HomeDir::Windows module
 
# DOS-like system
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) {
    $expr =~ s{ \A ~ (?= [^/\\] ) }
              { my_home_MSWin32() }oxmse;
}
 
# UNIX-like system

lib/Ebig5hkscs.pm  view on Meta::CPAN

4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
        if ($head ne '' and ($head =~ / \G ($q_char) /oxmsg)[-1] ne $pathsep) {
            $head .= $pathsep;
        }
 
        my $pattern = '';
        while ($expr =~ / \G ($q_char) /oxgc) {
            my $char = $1;
 
            # 6.9. Matching Shell Globs as Regular Expressions
            # in Chapter 6. Pattern Matching
            # of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
            # (and so on)
 
            if ($char eq '*') {
                $pattern .= "(?:$your_char)*",
            }
            elsif ($char eq '?') {
                $pattern .= "(?:$your_char)?"# DOS style
#               $pattern .= "(?:$your_char)",   # UNIX style
            }
            elsif ((my $fc = Ebig5hkscs::fc($char)) ne $char) {

lib/Ebig5hkscs.pm  view on Meta::CPAN

5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
# P.359 The Study Function
# in Chapter 7: Perl
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition
 
study $_; # Yes, I studied study yesterday.
 
# while all script
 
# 6.14. Matching from Where the Last Pattern Left Off
# in Chapter 6. Pattern Matching
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
# (and so on)
 
# one member of Tag-team
#
# P.128 Start of match (or end of previous match): \G
# P.130 Advanced Use of \G with Perl
# in Chapter 3: Overview of Regular Expression Features and Flavors
# P.255 Use leading anchors
# P.256 Expose ^ and \G at the front expressions
# in Chapter 6: Crafting an Efficient Expression



( run in 0.292 second using v1.01-cache-2.11-cpan-bf8d7bb2d05 )