in reply to Re: Un-obfuscate me
in thread Un-obfuscate me

Not true, wise chipmunk. The .. operator in scalar context 'is bistable' and is false until the first condition is met, then is true until the second condition is met and then is false. A fun toy that is better explained in perlop.

It is far beyond my meager skills, though, to figure out what this is supposed to do. Is it typed in correctly? I cannot make this snippet output anything. <P mikfire
mikfire

Replies are listed 'Best First'.
Re: Re: Re: Un-obfuscate me
by chipmunk (Parson) on Dec 19, 2000 at 01:52 UTC
    I know that .. is a flip-flop operator in scalar context. However, note that perlop goes on to say:
    If either operand of scalar ".." is a constant expression, that operand is implicitly compared to the $. variable, the current line number.
    That's why I said that \"aString" .. __ doesn't do anything useful in scalar context. :) I should have clarified that I was referring to that expression specifically, rather than to scalar context .. in general.

      Wouldn't \"aString" .. __ essentially be the same as 1 .. 1 in this context? If so, then the string "1E0" would be returned when the first line of data is read ("1" for first line counted, "E0" for last line counted.)

        Hehe... I figured out a use for \"aString"..__ after all. Note that it is not equivalent to 1..1. (Hint: '__' != 1)
        #!/usr/local/bin/perl $t = tell DATA; while (<DATA>) { if ($r = \"aString" .. __) { last if $r =~ /E/; print; $. = -1; } seek DATA, $t, 0; } __END__ Just another Perl hacker,
        If you run this script, you might want to do so in the background. It takes a while to finish...
Re: Re: Re: Un-obfuscate me
by Anonymous Monk on Dec 19, 2000 at 02:49 UTC

    You're right! I did type it incorrectly when I first asked the question. The original is this:

    @^T = qw, 3( 2 9 6); 21_PENGUINS, and print map {(lc((split//=>\"\"=>")[$^T>1])..__)[$_]}@^ +T

    Which, of course, answers my third question: it is obvious that split is operating on \"aString".

    While I was searching for the orignial, I also found some commentary on this little proggie. In fact, it looks like somebody else had the same problem I did, the __. How does 'c' .. __ create an alphabet generator? What's going on?

      Okay, now we're back to .. in a list context. This makes a lot more sense!

      Looking in perlop, I find that 'c' .. '__' will generate all the strings from 'c' to 'zz', because:

      If the final value specified is not in the sequence that the magical increment would produce, the sequence goes until the next value would be longer than the final value specified.
      The next string after 'zz' is 'aaa'; length('aaa') is greater than length('__'), so the sequence ends.

      The map is used to generate this list of strings and select a certain string five times; those five strings are printed to produce the author's name.