Xref: utzoo alt.sources.wanted:14 comp.sources.wanted:9371 comp.unix.questions:17585 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!littlei!omepd!merlyn From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: alt.sources.wanted,comp.sources.wanted,comp.unix.questions Subject: Re: matrix invert routine Message-ID: <5174@omepd.UUCP> Date: 10 Nov 89 19:53:50 GMT References: <1612@xn.LL.MIT.EDU> Sender: news@omepd.UUCP Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Followup-To: alt.sources.wanted Organization: Stonehenge; netaccess via Intel, Hillsboro, Oregon, USA Lines: 38 In-reply-to: rkc@XN.LL.MIT.EDU (rkc) In article <1612@xn.LL.MIT.EDU>, rkc@XN (rkc) writes: | I have "spreadsheet-like" data that looks like this: | a1 b1 c1 | a2 b2 c2 | a3 b3 c3 | and I want to get it in a form like: | a1 a2 a3 | b1 b2 b3 | c1 c2 c3 | Before I re-invent the wheel, does anyone have anything that will do this? Is | there perhaps a unix tool that does this sort of thing? Perl, anyone? (Eeekkk... it's the Perl monster!) #!/usr/bin/perl while (<>) { @F = split; $fn = 0; for $f (@F) { $final{++$fn} .= "$f "; } $maxfn = $fn if $maxfn < $fn; } for ($fn = 1; $fn <= $maxfn; $fn++) { ($_ = $final{$fn}) =~ s/ $//; print "$_\n"; } There, not quite one line, but it'll do. :-) Just another Perl hacker, -- /== Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ====\ | on contract to Intel's iWarp project, Hillsboro, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!uunet!iwarp.intel.com!merlyn | \== Cute Quote: "Welcome to Oregon... Home of the California Raisins!" ==/