Tildes abused.
Surprised? Amused?
use strict; die'TILDE',@~; sub CHECK{@~=$~=~m~(.)~g,unshift@~, splice@~,2,3;unshift@~,pop@~,*{H},; push@~,*{PAR}=>;($~[$#{~}],$~[$#{~} +-1])=($~[$#{~}+-1].$/=>$~[$#{~}]); for(@{~}){s~.*:~~;s~$~ ~ if$?++%2}}
Update:Tiny change to fix problem on Windows...
Per request, commented version below. And actually, it was a BrowserUK post last Friday that got me reading perlvar and perlmod, so thanks!
use strict;no warnings; sub CHECK{ # Who knew? CHECK blocks get called after compilation, # before execution! See perlmod @~ = $~ =~ m~(.)~g; # @~ is a valid but odd array name, eh? # $~ is the default output file handle, "STDOUT" # and so @~ = qw(S T D O U T) unshift @~, splice @~, 2, 3; # rearrange @~ to qw(D O U S T T) unshift @~, pop @~, *{H}; # rearrange further: pop@~ is "T", and *{H} # is "*main::H" (which would yield a warning) # so @~ is now qw(T *main::H D O U S T) push @~, *{PAR}; # now @~ is qw(T *main::H D O U S T *main::PAR); ($~[$#{~}],$~[$#{~}+-1])=($~[$#{~}+-1].$/=>$~[$#{~}]); # that gibberish swaps the last two elements, and # then appends a newline to the (new) last element, # so @~ is qw(T *main::H D O U S *main::PAR T\n); for(@{~}){ s~.*:~~; # delete "*main::", leaving qw(T H D O U S PAR T\n) s~$~ ~ if ($?++%2) # append a space to each odd element, so we have # ("T", "H ", "D", "O ", "U", "S ", "PAR", "T\n ") } } die 'TILDE', @~; # die with @~ in scalar form: # [TILDE][T][H ][D][O ][U][S ][PAR][T\n ]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: TILDE COWS COME HOME?
by NateTut (Deacon) on Feb 24, 2009 at 20:49 UTC | |
by ikegami (Patriarch) on Feb 24, 2009 at 20:58 UTC | |
by NateTut (Deacon) on Feb 24, 2009 at 21:05 UTC | |
by Fletch (Bishop) on Feb 24, 2009 at 21:12 UTC | |
by NateTut (Deacon) on Feb 24, 2009 at 21:14 UTC |