in reply to Re: output difference between backtic and open().
in thread output difference between backtic and open().

In the first case, you're splitting on a single space ("my @trace = split("\s", ...").

Actually, it's split-ing on the letter 's' because the  \ (backslash) is an escape in a double-quoted string. The escape is unrecognized but passed through, a fact that Perl would have mentioned had warnings been enabled.

c:\@Work\Perl\monks>perl -wMstrict -le "my $str = 'the rain in spain falls mainly'; ;; my @ra = split \"\s\", $str; printf qq{'$_' } for @ra; print ''; ;; @ra = split '\s', $str; printf qq{'$_' } for @ra; " Unrecognized escape \s passed through at -e line 1. 'the rain in ' 'pain fall' ' mainly' 'the' 'rain' 'in' 'spain' 'falls' 'mainly'

Replies are listed 'Best First'.
Re^3: output difference between backtic and open().
by kcott (Archbishop) on Feb 26, 2014 at 12:19 UTC

    ++ Well spotted. I've updated my post.

    -- Ken