如何在perl中自动生成的unicode字符范围中跳过保留的unicode字符?

One*_*ace 3 regex unicode perl

我编写了一个perl程序来自动生成perl中的一系列unicode字符.

#!/bin/perl -w

use strict;
use open qw/:std :encoding(UTF-8)/;

my ($beg, $end, $start, $finish, @chars);

print "Enter the beginning Unicode value of your Language's script: ";
chomp( $beg = <> );

print "Enter the last Unicode value of your Language's script: ";
chomp( $end = <> );

$beg =~ s/U\+(.*)/$1/;
$end =~ s/U\+(.*)/$1/;

$start  = hex($beg);
$finish = hex($end);

@chars = ( $start .. $finish );

foreach (@chars) {

    my $char = chr($_);

    next unless ($char);

    print "$char\n";
}
Run Code Online (Sandbox Code Playgroud)

在使用值运行此脚本时U+0B80,U+0BFF我的输出是:

஀஁ஂஃ஄அஆஇஈஉஊ஋஌஍எஏஐ஑ஒஓஔக஖஗஘ஙச஛ஜ஝ஞட஠஡஢ணத஥஦஧நனப஫஬஭மயரற லளழவஶஷஸஹ஺஻஼஽ாிீுூ௃௄௅ெேை௉ொோௌ்௎௏ௐ௑௒௓௔௕௖ௗ௘௙௚௛௜௝௞௟௠௡௢௣ ௤௥0 1 2 3 4 5 6 7 8 9௰௱௲௳௴௵௶௷௸௹௺௻௼௽௾௿

所有这些框字符都是Unicode Block中的保留空格.

我想删除所有这些保留空格.有没有办法在perl中执行此操作?

这条线next unless($char)似乎没有做到这一点,因为即使保留空间似乎也有一个值(框字符).

Aru*_*ngh 6

您只想打印可见的字符.请在此处查看

next unless ($char=~/[[:print:]]/);
Run Code Online (Sandbox Code Playgroud)