f



converting vertical text to horizontal text

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.

-- 
I am not an Intel spokesperson.
0
Mike
2/1/2005 9:16:24 PM
comp.lang.perl.misc 33233 articles. 2 followers. brian (1246) is leader. Post Follow

11 Replies
1060 Views

Similar Articles

[PageSpeed] 25

Mike Green (magreen@atintel.com) wrote on MMMMCLXXII September MCMXCIII
in <URL:news:ctorj9$tck$1@news01.intel.com>:
^^  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


It's not at all clear what you want. If I rotate the text, I get:

                             !
      Big  Pain in   the rear
    H                   m    ng
     e         a      s  elti
      l  rmy br      i  s
       p        in    a  wer
       Pe       th     n


So you have 7 columns, which need to be squashed into 3. And some columns
contain letters that go to different lines.



Abigail
-- 
   my $qr =  qr/^.+?(;).+?\1|;Just another Perl Hacker;|;.+$/;
      $qr =~  s/$qr//g;
print $qr, "\n";
0
Abigail
2/1/2005 9:51:36 PM
Mike Green <magreen@atintel.com> wrote in news:ctorj9$tck$1
@news01.intel.com:

> I have file that contains text formated like horizontal

Where does the text come from?

Sinan.
0
A
2/1/2005 10:04:50 PM
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


Mike Green wrote:

> 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.
> 

-- 
I am not an Intel spokesperson.
0
Mike
2/1/2005 10:41:51 PM
Mike Green <magreen@atintel.com> wrote in
news:ctp0jf$vpo$1@news01.intel.com: 

[ 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
0
A
2/1/2005 11:06:25 PM
Mike Green  <magreen@atintel.com> wrote in comp.lang.perl.misc:
> 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
0
anno4000
2/1/2005 11:09:03 PM
Mike Green wrote:

> 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?"
0
Chris
2/1/2005 11:57:53 PM
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.

Mike Green wrote:

> 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
> 
> 
> Mike Green wrote:
> 
>> 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.
>> 
> 

-- 
I am not an Intel spokesperson.
0
Mike
2/2/2005 12:13:29 AM
On Tue, 1 Feb 2005, Mike Green wrote:

> 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
0
Alan
2/2/2005 12:41:47 AM
Mike Green (magreen@atintel.com) wrote on MMMMCLXXIII September MCMXCIII
in <URL:news:ctp5v9$2sb$1@news01.intel.com>:
...  Sorry. The editor I'm using to enter this news message must be screwy.

Then get a better editor. Preferably one that doesn't toppost either.
Until then, goodbye.


*PLONK*


Abigail
-- 
# Perl 5.6.0 broke this.
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi
0
Abigail
2/2/2005 1:02:19 AM
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.

0
Larry
2/2/2005 1:31:22 AM
"Larry" <larry_wallet@yahoo.com> writes:
> 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).
0
Arndt
2/2/2005 8:56:19 AM
Reply: