in reply to Re^2: 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 you tweak it?
  • Comment on Re^3: Perl script to match a regexp in the prior line and other multiple lines

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

    Can anyone tell ?

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

    tr//\0/cr"

    Thanks Kshitij

      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:  <%-{-{-{-<