Big5HKSCS
view release on metacpan or search on metacpan
lib/Big5HKSCS.pm view on Meta::CPAN
8910111213141516171819202122232425262728#
# 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'
lib/Big5HKSCS.pm view on Meta::CPAN
787980818283848586878889909192939495969798sub
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
182183184185186187188189190191192193194195196197198199200201202
}
}
}
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
2371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398Programming 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
2468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495ISBN 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
8910111213141516171819202122232425262728#
# 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'
lib/Ebig5hkscs.pm view on Meta::CPAN
139140141142143144145146147148149150151152153154155156157158159sub
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]}
;
#
# Big5-HKSCS character range per length
#
lib/Ebig5hkscs.pm view on Meta::CPAN
11151116111711181119112011211122112311241125112611271128112911301131113211331134
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
359235933594359535963597359835993600360136023603360436053606360736083609361036113612
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
430143024303430443054306430743084309431043114312431343144315431643174318431943204321# 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
444344444445444644474448444944504451445244534454445544564457445844594460446144624463
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
588958905891589258935894589558965897589858995900590159025903590459055906590759085909# 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 )