An airport animation
# remember @y = ("smrfnexi', "--", "tjfillx", "ybvwvngwr", " ;-)\r") in the beginning
for ( split $c ) {
print @y if (
select( $/, $,, $<, .1 * rand ) || ( $y += $p++ + &c ) )
... # the range operator
( substr($y[&a], &p, 1) = chr 97 + (ord(substr $y[&a], &p, 1) + c()) % 26);
}
# for the record: the helper subs
sub a { $p % 3 * 2 }
sub p { $y % length $y[&a] }
sub c { length }
- The for loop works on the parts of $_ (which is the
concatenation of %_ values) separated by blocks of space
and theses spaces themselves (there are perentheses in the $c
regex).
- The range operator:
- The left part sleeps for a random time less than one tenth of a second,
and since select returns false (we went to the end of the timeout)
$y is calculated and $p is incremented.
- The right side change the current word ($y[&a])
at letter number &p. The increment is equal to the length
of the current piece of the logo.
- Since both parts are always true, the range operator alternates
between evaluating its left and right sides.
- $y (modulo the lenghth of the word) is used as
an offset inside a word.
- a() returns the number of the current string (either 0, 2 or
4) in @y.
Explanation: The words are changed in a cyclic way. In each
word, one letter is changed at a time. The index of the letter in the
current word, and the offset to get to the next letter are calculated
from the length of the current block.
Naturaly, the initial string was calculated with the current logo
to obtain the message.
Previous | Next
Copyright © 2000-2001, Philippe "BooK" Bruhat.