in reply to Re^3: Perl script to match a regexp in the prior line and other multiple lines
in thread Perl script to match a regexp in the prior line and other multiple lines

Can anyone tell ?

What would be equivalent of the below stated code in the perl 5.10

tr//\0/cr"

Thanks Kshitij

  • Comment on Re^4: Perl script to match a regexp in the prior line and other multiple lines
  • Download Code

Replies are listed 'Best First'.
Re^5: Perl script to match a regexp in the prior line and other multiple lines
by AnomalousMonk (Archbishop) on Dec 15, 2019 at 19:14 UTC

    The  /r modifier was added to  tr/// s/// operators in Perl version 5.14: see Quote Like Operators for  tr/// and Regexp Quote Like Operators for  s/// both in perlop.

    Try the following untested changes:
        my $mask = $3 =~ tr//\0/cr . "\xff";
    to
        (my $mask = $3) =~ tr//\0/c;
        $mask .= "\xff";
    and
        my $column = join '', map +($_ & $mask) =~ tr/\0//dr, split /^/, $pre;
    to
        my $column = join '', map { (my $r = $_ & $mask) =~ tr/\0//d;  $r; } split /^/, $pre;

    (And yes, heed the advice of afoken here; tybalt89 is the Genie of the Regex, and centuries of folk wisdom tell us that deals done with such a being seldom end well. :)


    Give a man a fish:  <%-{-{-{-<