in reply to two regexes in one function call

I can confirm your results on AS 5.10; and (maybe) point out that it does not appear to be conflict between the regexes as I get similar disparate results using tr to count the newlines:

use Data::Dump qw{dump}; $data = do { local $/ = undef; <DATA> }; # in single call dump [ scalar( $data =~ tr[\n][\n] ), scalar($data =~ s/\n/\n/g), scalar($data =~ s/(\w+)/\1/g), length($data) ]; # in multiple calls dump [ scalar( $data =~ tr[\n][\n] ) ]; dump [ scalar($data =~ s/\n/\n/g) ]; dump [ scalar($data =~ s/(\w+)/\1/g) ]; dump [ length($data) ]; __DATA__ Line1 Word Something Line2 Other Word

Gives:

c:\test>783947.pl [6, 6, 6, 38] [2] [2] [6] [38]

Update: Another set of conflicting results I cannot immediately explain?

#! perl -sw use 5.010; $data = do { local $/ = undef; <DATA> }; say join ':', scalar( $data =~ tr[\n][\n] ), scalar($data =~ s/\n/\n/g), scalar($data =~ s/(\w+)/$1/g), length($data) ; my $x = [ scalar( $data =~ tr[\n][\n] ), scalar($data =~ s/\n/\n/g), scalar($data =~ s/(\w+)/$1/g), length($data) ]; say "@$x"; __DATA__ Line1 Word Something Line2 Other Word

Gives:

c:\test>783947.pl Use of uninitialized value in join or string at ... 6::6:38 6 6 6 38

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP PCW

Replies are listed 'Best First'.
Re^2: two regexes in one function call
by bobr (Monk) on Jul 28, 2009 at 16:39 UTC
    I noticed the tr as well, because I originally had it there. I have same result on both AS and strawberry.

    It looks like both having similar compile-time options:

    MULTIPLICITY PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS PERL_MALLOC_WRAP PL_OP_SLAB_ALLOC USE_ITHREADS USE_LARGE_FILES USE_PERLIO
    AS has also USE_SITECUSTOMIZE specified.