in reply to switch columns and rows
With the output:#!/bin/perl use warnings; use strict; my @array; my $rows = 0; my $columns = 0; while(<DATA>) { chomp; $rows = length($_); for ( my $j = 0; $j < $rows; $j++ ) { $array[$columns][$j] = substr($_, $j, 1); } $columns++; } for ( my $m = 0; $m < $rows; $m++ ) { for ( my $k = 0; $k < $columns ; $k++ ) { print $array[$k][$m]; } print "\n"; } __DATA__ 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345
But it has to be noted, I think this topic has been touched on at least twice in the last month.C:\Code>perl swap.pl 1111111111111 2222222222222 3333333333333 4444444444444 5555555555555
|
|---|