(? <= ) 后看声名

(? <= ) 后看声名

我的perl不支持,v5.8.5


[Copy to clipboard] [ - ]
CODE:
use strict;
use warnings;

my $string1 = "i be hungry.";
my $string2 = "we be here.";
my $string3 = "he be where?";

conjugate($string1);
conjugate($string2);
conjugate($string3);

sub conjugate
{
        my $string = shift;
        print "$string\n";
        $string =~s/(? <=i )be/am/;
        $string =~s/(? <=we )be/are/;
        $string =~s/(? <=he )be/is/;

你想说什么?
try this

sub conjugate
{
    my $string = shift;
    print "$string\n";
    $string =~ s/(?<=i )be/am/;
    $string =~ s/(?<=we )be/are/;
    $string =~ s/(?<=he )be/is/;
    say $string;
}


lz你在哪找的这段代码?我依稀记得这个syntax,但是忘了怎么用了