Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Boustrophedon

by OeufMayo (Curate)
on Nov 19, 2001 at 05:20 UTC ( [id://126195]=CUFP: 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.)
bou·stro·phe·don
  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...

#!/usr/bin/perl while (<>) { chomp; 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).

      p

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://126195]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-24 12:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found