in reply to !~ /\w/ challenge, anyone?

Alrighty
perl -lpe '++($_=(()=<>))' < file
update: ack just noticed the $_ :-/
HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: !~ /\w/ challenge, anyone?
by John M. Dlugosz (Monsignor) on Feb 05, 2003 at 17:03 UTC
    Can you do it without the "_" character? I think finding ways to stick something in there implicitly will be one of the essential skills of this kind of challange.

    Is it necessary to redirect file to the script instead of letting <> read the argument?

    I see that the ++ compensates for the fact that one line was already read via -p. Cute.

    —John

      Is it necessary to redirect file to the script instead of letting <> read the argument?
      Yep, otherwise it'll just hang waiting on STDIN.

      Here's a solution that adheres to the rules but is awful sneaky

      shell> cat > obfuwc.pl #!/usr/bin/perl -lp -s ++(${$::{$-}}=()=<>) ^D shell> chmod +x obfuwc.pl shell> ./obfuwc.pl --=_ < file
      So the actual code passes the /\w/ but sneaks through the rules by passing in _. I can't say I'm proud ;)
      HTH

      _________
      broquaint

        Why would it wait on STDIN, instead of opening and reading from file?