tokuhirom / Perl-MinimumVersion-Fast

Other
4 stars 6 forks source link

Detects empty regex as defined-or #7

Closed dagolden closed 10 years ago

dagolden commented 10 years ago

This file is said to require 5.010 because // operator:

use strict;
use warnings;

my $what = <>;
my @chars = split //, $what;
print "@chars\n";
tokuhirom commented 10 years ago

@goccy How do I detect split // regexp or not?

The token is following:

          bless( {
                   'stype' => 0,
                   'kind' => 1,
                   'name' => 'DefaultOperator',
                   'has_warnings' => 0,
                   'data' => '//',
                   'type' => 57,
                   'line' => 5
                 }, 'Compiler::Lexer::Token' ),
dagolden commented 10 years ago

I don't know the details of how it all works, but to be an operator, it needs an expression on both sides:

EXPR // EXPR

If there's a comma or closing symbols, it's either a syntax error or a trivial match on $_

@list = split //, $scalar;
@list = split //;
@list = (split //)[0..2];
{ @list = split // }
[ split // ]
if ( // ) { ... }