Re: Manipulating file content
Bolan Meek wrote:
> > this one is for all the regexp, shell, and editing-experts...
>
> How about us perl hackers, hunh?! Got sumpin' g'inst us, buddy!?
Of course not! How could I?! :)
> Well, you could use regexp in sed, or use an awk script, but if
> I had only 3x3 matrices to transform, in text, I'd
> perl -e 'for ($i=0;$i<3;++$i){<>;@entry = split ',';print
> "$i[0],$i[1],$i[2]\n";}'
> with a file directed into it, and stdout redirected to a file.
This ..., well ..., it doesn't work. At first I thought that you meant
@entry[x] in your last line, but that doesn't help either. I always get
3 pairs of commas without the values. Besides, the way I read the code,
it doesn't do anything usefull, because a line with values seperated by
commas, will become exactly the same line. But then again, I don't know
anything about Perl, so this is just guessing.
> Matrixes with unpredetermined columns or rows become slightly
> trickier, but only by 1) keeping track of the length/breadth, and
> 2) nesting another loop.
What about matrixes with a different number of columns and rows (e.g.
4x3 or 123x234)?
MfG Viktor
--
Viktor Rosenfeld
E-Mail: mailto:rosenfel@informatik.hu-berlin.de
HertzSCHLAG: http://www.informatik.hu-berlin.de/~rosenfel/hs/
Reply to: