FAQ
Hi,

Am just trying out this bracket checker script but when I ran it, it is
giving errors below.

Just curious to know what the error is about? Please advise. Thanks

Error below:

http://pastebin.com/d8GNL0kx

./123.pl testfile01x.ora
Malformed UTF-8 character (unexpected continuation byte 0xbb) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xbb) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xbb) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xbb) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xbb) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xbb) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xbb) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xbb) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xbb) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xbb) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xab) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xbb) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xbb) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xbb) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xbb) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xbb) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xab) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xbb) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xbb) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xbb) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xbb) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xbb) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xbb) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xbb) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xab) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xbb) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xab) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xbb) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xab) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xab) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xbb) at ./123.plline 8.
Malformed UTF-8 character (unexpected continuation byte 0xbb) at ./123.plline 8.
Sequence (?|...) not recognized before HERE mark in regex m/(?| << HERE
(\()(?&matched)([\}\]..»?>»??]|$) |
(\{)(?&matched)([\)\]..»?>»??]|$) |
(\[)(?&matched)([\)\}..»?>»??]|$) |
(.)(?&matched)([\)\}\].»?>»??]|$) |
(.)(?&matched)([\)\}\].»?>»??]|$) |
(«)(?&matched)([\)\}\]..?>»??]|$) |
(?)(?&matched)([\)\}\]..»>»??]|$) |
(<)(?&matched)([\)\}\]..»?»??]|$) |
(«)(?&matched)([\)\}\]..»?>??]|$) |
(?)(?&matched)([\)\}\]..»?>»?]|$) |
(?)(?&matched)([\)\}\]..»?>»?]|$) | at ./123.pl line 34.


Code below or can be copied from http://pastebin.com/d8GNL0kx

#!/usr/bin/perl

use strict;
use utf8;
binmode STDOUT,":utf8";
use File::Find;

my $checkre = qr/(?|
(\()(?&matched)([\}\]”›»】〉》」』]|$) |
(\{)(?&matched)([\)\]”›»】〉》」』]|$) |
(\[)(?&matched)([\)\}”›»】〉》」』]|$) |
(“)(?&matched)([\)\}\]›»】〉》」』]|$) |
(‹)(?&matched)([\)\}\]”»】〉》」』]|$) |
(«)(?&matched)([\)\}\]”›】〉》」』]|$) |
(【)(?&matched)([\)\}\]”›»〉》」』]|$) |
(〈)(?&matched)([\)\}\]”›»】》」』]|$) |
(《)(?&matched)([\)\}\]”›»】〉」』]|$) |
(「)(?&matched)([\)\}\]”›»】〉》』]|$) |
(『)(?&matched)([\)\}\]”›»】〉》」]|$) |
(^)(?&matched)([\)\}\]”›»】〉》」』]))
(?(DEFINE)(?<matched>(?:
\((?&matched)\) |
\{(?&matched)\} |
\[(?&matched)\] |
“(?&matched)” |
‹(?&matched)› |
«(?&matched)» |
【(?&matched)】 |
〈(?&matched)〉 |
《(?&matched)》 |
「(?&matched)」 |
『(?&matched)』 |
[^\(\{\[“‹«【〈《「『\)\}\]”›»】〉》」』]++)*+))
/sx;

sub check_file {
if(-f && /\.txt$/) {
if(open(my $fh,'<:encoding(UTF-8)',$_)) {
undef $/;
my $data = <$fh>;
if($data =~ $checkre) {
if(!length $2) {
print "File $File::Find::name has unclosed bracket $1 at
position $-[1]\n";
}
elsif(!length $1) {
print "File $File::Find::name has unopened bracket $2 at
position $-[2]\n";
}
else {
print "File $File::Find::name has mismatched brackets $1
$2 at positions $-[1] and $-[2]\n";
}
}
} else {
print STDERR "Cannot open $File::Find::name: $!\n";
}
}
}

@ARGV = ('.') unless @ARGV;
find(\&check_file,@ARGV);

Search Discussions

  • Timothy adigun at Jul 29, 2011 at 9:33 am
    Hi newbie01 perl,

    The code you posted worked fine, if only you save your perl
    file (e.g exec2.pl - it doesn't matter the name of ur perl file),
    using UTF-8 Encoding.
    ###### HOW TO SAVE USING UTF-8 ENCODING ##########
    Copy the codes into notepad and give it any name you like
    but you must end with ".pl" or ".plx", on the File name
    then on Save as type: change to "All Files",
    then Encoding: use "UTF-8" (or any other,except ANSI), instead of using
    default "ANSI".

    My experience:Some times one gets error like ds when codes are copied
    directly from pdf e-books.
    -- happy coding!
    On Thu, Jul 28, 2011 at 11:25 PM, newbie01 perl wrote:

    Hi,

    Am just trying out this bracket checker script but when I ran it, it is
    giving errors below.

    Just curious to know what the error is about? Please advise. Thanks

    Error below:

    http://pastebin.com/d8GNL0kx

    ./123.pl testfile01x.ora
    Malformed UTF-8 character (unexpected continuation byte 0xbb) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xbb) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xbb) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xbb) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xbb) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xbb) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xbb) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xbb) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xbb) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xbb) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xab) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xbb) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xbb) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xbb) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xbb) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xbb) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xab) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xbb) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xbb) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xbb) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xbb) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xbb) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xbb) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xbb) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xab) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xbb) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xab) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xbb) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xab) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xab) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xbb) at
    ./123.plline 8.
    Malformed UTF-8 character (unexpected continuation byte 0xbb) at
    ./123.plline 8.
    Sequence (?|...) not recognized before HERE mark in regex m/(?| << HERE
    (\()(?&matched)([\}\]..»?>»??]|$) |
    (\{)(?&matched)([\)\]..»?>»??]|$) |
    (\[)(?&matched)([\)\}..»?>»??]|$) |
    (.)(?&matched)([\)\}\].»?>»??]|$) |
    (.)(?&matched)([\)\}\].»?>»??]|$) |
    («)(?&matched)([\)\}\]..?>»??]|$) |
    (?)(?&matched)([\)\}\]..»>»??]|$) |
    (<)(?&matched)([\)\}\]..»?»??]|$) |
    («)(?&matched)([\)\}\]..»?>??]|$) |
    (?)(?&matched)([\)\}\]..»?>»?]|$) |
    (?)(?&matched)([\)\}\]..»?>»?]|$) | at ./123.pl line 34.


    Code below or can be copied from http://pastebin.com/d8GNL0kx

    #!/usr/bin/perl

    use strict;
    use utf8;
    binmode STDOUT,":utf8";
    use File::Find;

    my $checkre = qr/(?|
    (\()(?&matched)([\}\]”›»】〉》」』]|$) |
    (\{)(?&matched)([\)\]”›»】〉》」』]|$) |
    (\[)(?&matched)([\)\}”›»】〉》」』]|$) |
    (“)(?&matched)([\)\}\]›»】〉》」』]|$) |
    (‹)(?&matched)([\)\}\]”»】〉》」』]|$) |
    («)(?&matched)([\)\}\]”›】〉》」』]|$) |
    (【)(?&matched)([\)\}\]”›»〉》」』]|$) |
    (〈)(?&matched)([\)\}\]”›»】》」』]|$) |
    (《)(?&matched)([\)\}\]”›»】〉」』]|$) |
    (「)(?&matched)([\)\}\]”›»】〉》』]|$) |
    (『)(?&matched)([\)\}\]”›»】〉》」]|$) |
    (^)(?&matched)([\)\}\]”›»】〉》」』]))
    (?(DEFINE)(?<matched>(?:
    \((?&matched)\) |
    \{(?&matched)\} |
    \[(?&matched)\] |
    “(?&matched)” |
    ‹(?&matched)› |
    «(?&matched)» |
    【(?&matched)】 |
    〈(?&matched)〉 |
    《(?&matched)》 |
    「(?&matched)」 |
    『(?&matched)』 |
    [^\(\{\[“‹«【〈《「『\)\}\]”›»】〉》」』]++)*+))
    /sx;

    sub check_file {
    if(-f && /\.txt$/) {
    if(open(my $fh,'<:encoding(UTF-8)',$_)) {
    undef $/;
    my $data = <$fh>;
    if($data =~ $checkre) {
    if(!length $2) {
    print "File $File::Find::name has unclosed bracket $1 at
    position $-[1]\n";
    }
    elsif(!length $1) {
    print "File $File::Find::name has unopened bracket $2 at
    position $-[2]\n";
    }
    else {
    print "File $File::Find::name has mismatched brackets $1
    $2 at positions $-[1] and $-[2]\n";
    }
    }
    } else {
    print STDERR "Cannot open $File::Find::name: $!\n";
    }
    }
    }

    @ARGV = ('.') unless @ARGV;
    find(\&check_file,@ARGV);

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupbeginners @
categoriesperl
postedJul 28, '11 at 10:26p
activeJul 29, '11 at 9:33a
posts2
users2
websiteperl.org

2 users in discussion

Timothy adigun: 1 post Newbie01 perl: 1 post

People

Translate

site design / logo © 2021 Grokbase