Just for kicks I modified A sub named ∃ but added magic so "\x{2203}" =~ /\p{IdContinue}/ would be true and my hoped for character would be recognized as an identifier. I didn't work but it was kind of interesting to both write a source filter this way and to modify perl's idea of what constituted a unicode character class. I thought I'd share.
BEGIN { # Install a function which inserts the two codepoints # 2203;THERE EXISTS;Sm;0;ON;;;;;Y;;;;; # 2204;THERE DOES NOT EXIST;Sm;0;ON;2203 0338;;;;Y;;;;; unshift @INC, sub { my ( $self, $module ) = @_; return unless $module eq 'unicore/lib/gc_sc/IdContin.pl'; # Open the file wherever it exists. my $file; for my $dir (@INC) { my $tst = "$dir/$module"; next unless -f $tst; $file = $tst; } # Slurp the entire file. open my $fh, '<', $file or die "Can't open $file: $!"; my @contents = readline $fh; close $fh; # Find out where the hex region starts. my $start_ix; for ( 0 .. $#contents ) { next unless $contents[$_] =~ /^[\dA-F]+(?:\s+[\dA-F]+\s*)? +$/; $start_ix = $_; last; } # Find out where to insert my 2203/2005 codes. for ( $start_ix .. $#contents ) { my @chars = map hex("0x$_"), $contents[$_] =~ /(\S+)/g or last; my $char = $chars[-1]; next if $char <= 0x2203; # Insert my two codes. splice @contents, $_, 0, "2203\t2204\n"; last; } # Return the modified file. return ( sub { if (@contents) { $_ = shift @contents; return 1; } else { return 0; } } ); }; }
use utf8; use strict; use warnings; use Test::More tests => 2; my @numbers = 1 .. 10; # This works (but not normally) BEGIN { like( "\x{2203}", qr/\p{IdContinue}/, "\N{THERE EXISTS} is an +identifier" ) } # This doesn't.
sub ∃ (&\@) { my $predicate = shift @_; $predicate->() and return 1 for @_; 0 }
ok( ∃ { /\d/ } @numbers, '∃' );
⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊
|
|---|