#!/usr/bin/perl -w
use strict;
my $format;
while (<DATA>) {
my $line = $_;
# this line has alphbet, try to seperate
if ($line =~ /[a-zA-Z\d]/) {
LINE: while (1) {
# (([\x81-\xfe][\x40-\xfe])*) greedy match on chinese.
# line starts with chinese
if ($line =~ /(([\x81-\xfe][\x40-\xfe])*)/ && $1) {
my $e = $1;
# update line
$line = $';
$format .= ($line=~ /^\s/) ? $e : $e." ";
} elsif ($line =~ /(.*?)([\x81-\xfe][\x40-\xfe])/) {
# line starts with non-chinese chars
my $e = $1;
# the second match eats one chinese char, so get it ba
+ck.
$line = $2.$';
# add space after english char if it isn't ended with
+space.
$format .= ($e=~/\s$/) ? $e : $e." ";
} else {
$format .= $line;
last LINE;
}
}
} else {
$format .= $line;
}
}
print $format;
__DATA__
在 2004 年7月的开源大会时能比CPython更快的执行Python的字节码
“Perl现在生机勃勃
Perl 6被建议不应只作为Perl的新的实现
perl 5.8.x,仍然生机勃勃,Jarkko Hietaniemi今年的早些时候把
在2003年10月,发布了
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|