in reply to Re: Partial Xor in string
in thread Partial Xor in string

... any % character not preceded by a \ backslash ...

I don't really understand the context of kepler's OPed question, but if that's supposed to be an (s)printf format specifier, shouldn't that be "any % character not preceded by a %"?

c:\@Work\Perl\monks\Denis.Beurive>perl -wMstrict -le "printf qq{\%d x %%d y %d \n}, 123, 543; printf qq{\%0.2f x %%0.2f y %0.2f \n}, 12.34, 54.32; " 123 x %d y 543 12.34 x %0.2f y 54.32


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

Replies are listed 'Best First'.
Re^3: Partial Xor in string
by davido (Cardinal) on Sep 18, 2016 at 23:31 UTC

    Yes, you're correct, I was thinking that % is escaped with a backslash, not another %. Memory lapse.

    In that case the pattern might look like this:

    split /(?<!%)(%[^%\s]+)/

    I'm still a little curious what problem we're really solving. Why parse and encrypt a sprintf format specifier in the first place? A format string should be considered code, not data accepted from the outside world. What's the underlying need here?

    perl -E 'my $f = shift @ARGV; say sprintf $f, "foo"' '%9999999999s'

    (consumes 1.3GB RAM)


    Dave