in reply to Re: Re: Regarding B::Deparse
in thread Regarding B::Deparse

Very interesting indeed. It looks like B::Deparse doesn't fully understand the magic associated with the /x regex modifier. With /x, a literal \n and the two character sequence '\n' are not actually equivalent. B::Deparse isn't making that distinction.

Below, the second regex is the result of running the first one through B::Deparse. As this example shows, they are not the same.

#!/usr/bin/perl -wT use strict; my $v1 = my $v2 = "abcdef"; $v1 =~ s/c d//x; # original pattern: literal \n is gobbled by /x # equivalent to the non-x: s/cd//; $v2 =~ s/c\nd//x; # deparsed version: interpolated "\n" is not touch +ed by /x # equivalent to the non-x: s/c\nd//; print "V1 = '$v1'\n"; print "V2 = '$v2'\n"; =OUTPUT V1 = 'abef' V2 = 'abcdef'

-Blake

Replies are listed 'Best First'.
Re(x4): Regarding B::Deparse
by robin (Chaplain) on Dec 19, 2001 at 18:37 UTC
    I've done a lot of work on B::Deparse since perl 5.6 came out, and the development snapshots of perl have a lot of fixes which aren't in the version that comes with 5.6.

    Unfortunately, B::Deparse is very intimate with the internals of the interpreter, and so you can't upgrade it on its own. But if you're feeling experimental, try downloading the latest development snapshot of perl from here. Go for the one with the biggest number - it indicates the patchlevel. (The latest development snapshot is also called bleadperl, because it's on the leading/bleeding edge.)

    And yes, I did fix the /x bug. Your example works fine with bleadperl. Of course these fixes will all be in perl 5.8 when it's released.