Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: text formatting in columns with hash?

by toolic (Bishop)
on Jul 03, 2013 at 19:46 UTC ( #1042268=note: print w/replies, xml ) Need Help??


in reply to text formatting in columns with hash?

This works if you have an even number of lines after the header, as your output does (your input has an odd number for some reason):
use warnings; use strict; my @lines = <DATA>; chomp @lines; my $head = shift @lines; print "$head $head\n"; my $count = @lines / 2; for my $i (0 .. $count-1) { print "$lines[$i] $lines[$i+$count]\n"; } __DATA__ a b c 0 0 d 0 1 d 0 1 d 0 2 d 0 2 d 1 0 d 1 0 d 1 1 d 1 2 d 1 2 d

Replies are listed 'Best First'.
Re^2: text formatting in columns with hash?
by BillKSmith (Parson) on Jul 03, 2013 at 19:54 UTC
    The requirements seem a bit more complicated. In the output, only the 'a' value is different between the two columns. The string which does not fit that pattern is skipped.
    UPDATE: My description of the output is wrong! I cannot figure out t +he real requirement.
    Bill

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1042268]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2018-07-17 07:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (357 votes). Check out past polls.

    Notices?