| 1 | package BLOB; | ||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use Carp qw(carp); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use Exporter (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | # No "our" in Perl 5.0 | ||||||||||
| 7 | 1 | ▶ | use vars qw(@ISA $VERSION @EXPORT); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 1 | $VERSION = '1.01'; | |||||||||
| 10 | 1 | @ISA = qw(Exporter); | |||||||||
| 11 | 1 | @EXPORT = qw(mark_blob is_blob); | |||||||||
| 12 | |||||||||||
| 13 | # Fallback for Perl < 5.8 | ||||||||||
| 14 | 0 | ▶ | *utf8::downgrade = sub { 1 } if not defined &utf8::downgrade; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
Branch: 1 branch
| |||||||||||
| 15 | |||||||||||
| 16 | # Class method | ||||||||||
| 17 | 2 | ▶ | sub mark { | ||||||||
|
Subroutine
mark: called CC=2 SCAR=7.9
Pod
documented
| |||||||||||
| 18 | 2 | my $class = shift; | |||||||||
| 19 | 2 | my $blob_ref = \shift; | |||||||||
| 20 | 2 | ▶ | if (not utf8::downgrade($$blob_ref, 1)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | 0 | carp "Wide character outside byte range in BLOB, encoding data with UTF-8"; | |||||||||
| 22 | 0 | utf8::encode($$blob_ref); | |||||||||
| 23 | } | ||||||||||
| 24 | 2 | bless $blob_ref, $class; | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | # Function | ||||||||||
| 28 | 1 | ▶ | sub mark_blob { | ||||||||
|
Subroutine
mark_blob: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 29 | 1 | BLOB->mark($_[0]); | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | # Function | ||||||||||
| 33 | 6 | ▶ | sub is_blob { | ||||||||
|
Subroutine
is_blob: called CC=3 SCAR=11.6
Pod
documented
| |||||||||||
| 34 | 6 | my $blob_ref = \shift; | |||||||||
| 35 | 6 | ▶ | return undef if not eval { $blob_ref->isa('BLOB') }; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 2 | ▶ | if (not utf8::downgrade($$blob_ref, 1)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | 0 | carp "Wide character outside byte range in BLOB, encoding data with UTF-8"; | |||||||||
| 38 | 0 | utf8::encode($$blob_ref); | |||||||||
| 39 | } | ||||||||||
| 40 | 2 | return 1; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 1 | 1; | |||||||||
| 44 | |||||||||||
| 45 | __END__ | ||||||||||