Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things


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]
[Corion]: A good weekstart to everybody!

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2018-06-18 08:14 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (109 votes). Check out past polls.