Andrej Kastrin am Montag, 19. Dezember 2005 13.13: > Ing. Branislav Gerzo wrote: > >Andrej Kastrin [AK], on Monday, December 19, 2005 at 10:41 (+0100) > >typed: > > > >AK> 00001 BRCA3 BRCA33|BRCA55 symbol 998 > >AK> 00002 ABCB1 DASH|BASG|AVGA4 symbol 7583 > >AK> In first step I split each row and store it in array; e.g.: > >AK> @array=( '00001', 'BRCA3', 'BRCA33|BRCA55', 'symbol998') > > > >if you want to split use split :) so simple, eh ? > > > >perldoc -f split > > > >I am not sure if split third column and add it to end to array is good > >idea. I would use anonymous hashes for this, or AoA > > So, following code split each line and print it. > > while (<>){ > @column = split(/\t/,$_); # split current line, field separator set > to tab > print OUTPUT "$column[0]\t$column[1]\tt$column[2]\n"; > > If I'm right, I have to split third column and store it to @AoA. But how > to print it (instead of $column[2] in my example?
If you are shure that '|' does not occur in any other columns than the third, you could simly split by '\t' *or* '|' : use strict; use warnings; my $line='00001 BRCA3 BRCA33|BRCA55 symbol 998'; # Note: the first '|' is the OR-operator in a regex my @cols=split /\t|\|/, $line; print join "-", @cols; # gives: 00001-BRCA3-BRCA33-BRCA55-symbol-998 > Additional problem: the length of third element variate. Is that > possible or have you any other suggestion. Not sure what you mean by that. Unless in C, you don't have to think about the length of array items. hth, joe -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>