converting vertical text to horizontal text

M

Mike Green

I have file that contains text formated like horizontal
H
e
B l
i p P
g e
r
m l
P y
a
i b i
n r s
a
i i t
n n h
e

t i
h s a
e n
m s
r e w
e l e
a t r
r i
! n
g

Does anyone have a good way to convert this to horizontal text like such
below? Thanks.

Big Pain in the rear!

Help my brain is melting

Perl is the answer

I've search CPAN and found some Text modules to rotate the text, but I'm
stuck trying to figure out how to read this text in. I'm thinking using
unconstrainted 2D array. Thank you.
 
M

Mike Green

This works:

chomp(@lines = <FILEHANDLE>);
print join("", map { s/(.)//s ? $1 : " " } @lines), "\n" while length
+ join "", @lines;

I found the solution here: http://www.perlmonks.org/index.pl?node_id=46551


It takes what you see below:

I O
t h

w b
o o
r y
k
s t
h
f i
i s
n
a w
l a
l s
y
h
a
r
d


And prints this

It works finally
Oh boy this was hard
 
A

A. Sinan Unur

[ Please don't top-post ]
This works:

chomp(@lines = <FILEHANDLE>);
print join("", map { s/(.)//s ? $1 : " " } @lines), "\n" while length
+ join "", @lines;
....

I O
t h

But you changed the data!!!

Are you just toying with people here?

Here is what I get when I run the code above on your original data:

D:\Home\asu1\UseNet\clpmisc> cat f.pl
use strict;
use warnings;

chomp(my @lines = <DATA>);
print join("", map { s/(.)//s ? $1 : " " } @lines), "\n" while length
+ join "", @lines;

__DATA__
H
e
B l
i p P
g e
r
m l
P y
a
i b i
n r s
a
i i t
n n h
e

t i
h s a
e n
m s
r e w
e l e
a t r
r i
! n
g


D:\Home\asu1\UseNet\clpmisc> f
Warning: Use of "length" without parentheses is ambiguous at
D:\Home\asu1\UseNet\clpmisc\f.pl line 6.
Big Pain in the rear!
H m g
e a s eltin
l rmy br i s
p in a wer
l is e
Pe th n

Sinan
 
A

Anno Siegel

Mike Green said:
This works:

chomp(@lines = <FILEHANDLE>);
print join("", map { s/(.)//s ? $1 : " " } @lines), "\n" while length
+ join "", @lines;

I found the solution here: http://www.perlmonks.org/index.pl?node_id=46551


It takes what you see below:
[snip]

And prints this

It works finally
Oh boy this was hard

No, it doesn't, and it breaks down entirely with the text you originally
posted. Do you have a point?

Anno
 
C

Chris Mattern

Mike said:
This works:

chomp(@lines = <FILEHANDLE>);
print join("", map { s/(.)//s ? $1 : " " } @lines), "\n" while length
+ join "", @lines;

I found the solution here: http://www.perlmonks.org/index.pl?node_id=46551


It takes what you see below:

I O
t h

w b
o o
r y
k
s t
h
f i
i s
n
a w
l a
l s
y
h
a
r
d


And prints this

It works finally
Oh boy this was hard
And how does it know not to print

It works finally
h hard
Oh boy t is was

or

It workshfinallyhard
Oh boy t is was

?

YOU can do it, because you understand English and
can pull out the phrases that make sense. I think
writing a Perl script that does that is likely to
be a somewhat larger project than you really want
to tackle at the moment...

--
Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
 
M

Mike Green

Sorry. The editor I'm using to enter this news message must be screwy.
Assume the two columns of text line up perfectly, then try the snipet of
code below.
 
A

Alan J. Flavell

Sorry. The editor I'm using to enter this news message must be screwy.

Wake us up again when you've done the news.newusers.questions thing,
and have got yourself into a position to post something coherent.

bye
 
L

Larry

I tried writing a script that would collect all of the letters together
and feed them into a web based anagram solver. Maybe the anagram site
I chose was no good, but it couldn't solve it. You might need a
customized anagram solver that can make intelligent choices based on
the partial order of the text.
 
A

Arndt Jonasson

Larry said:
I tried writing a script that would collect all of the letters together
and feed them into a web based anagram solver. Maybe the anagram site
I chose was no good, but it couldn't solve it. You might need a
customized anagram solver that can make intelligent choices based on
the partial order of the text.

Dear google-poster, do try to find a configuration when posting through
google that keeps the context information of what you're replying to.
Subject and reference numbers are there, but not the most immediate thing
people want to see, namely the actual text you are referring to (including
its author).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top