Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw


by OeufMayo (Curate)
on Nov 19, 2001 at 05:20 UTC ( #126195=snippet: print w/replies, xml ) Need Help??

I just saw this boustrophedon text reader project on freshmeat and 10 seconds later, I had this snippet.

For those who are wondering, here's the definition of the word Boustrophedon:

boustrophedon (n.)
  1. an ancient method of writing in which the lines run alternately from right to left and from left to right.

Of course, others have used this ancient method to achieve weird things...

while (<>) {
  print( ( $. % 2 ? $_ : scalar reverse $_ ), "\n" );

Or, for the one-liners/golfers inclined:

perl -npe'chomp;$_=scalar reverse$_ if$.%2;$_.="\n"' file
Replies are listed 'Best First'.
Re: Boustrophedon
by japhy (Canon) on Nov 19, 2001 at 06:25 UTC
    My preferred flip-flop is $|:
    perl -lpe'$_=reverse if--$|'

    Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Re: Boustrophedon
by petral (Curate) on Nov 19, 2001 at 20:32 UTC
    Further pedantry:
    Boustrophedon is greek for "as the ox plows".
    When the alphabet was first borrowed from the right-to-left writing Phoenicians, there was a brief period (c. 8-700 roman bc?) during which this form of writing was actually used by Greek writers before they settled on writing left-to-right.
    The word was borrowed from the classicists when mechanical printers appeared.  These printers could clearly go faster if they started each line where they had ended the previous one (which, of course, is also true of oxen).

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: snippet [id://126195]
and the questions are moot...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2018-05-26 11:00 GMT
Find Nodes?
    Voting Booth?