[mplspm]: RE: Help with a transpose script (included)
Nielsen, Aaron M
aaron.m.nielsen at intel.com
Thu Nov 29 15:10:48 CST 2001
> I'm working on large pattern data in column format and am using the
> following sub to transpose the file so I cant do pattern matching on
> columns. I then call the transpose sub again to return the file to column
> format. The problem I'm running into is that the code is very slow and
> thought it will finish on small patterns it dies on large ones (around
> 10Meg). Any ideas on more efficient transpose scripts or a more efficient
> way to match patterns on column data?
>
> ------------------------------------------------
> transpose($file,$file_transposed);
>
> sub transpose {
>
> package transpose;
> my (@ops) = @_;
> my $linesm1 = undef;
> my @line = undef;
> my $j = undef;
> my $i = undef;
> open (IN, $ops[0]) || die "1 $!\n";
> open (OUT,"> $ops[1]") || die "2 $!\n";
> while ( <IN> ) {
> $j = 0;
> chomp;
> @_ = split //;
> for ( @_ ) {
> if ( $j > $linesm1 ) {
> $line[$j] = " " x $i;
> $linesm1++;
> }
> $line[$j] .= $_;
> $j++;
> }
> for ( $j .. $linesm1 ) {
> $line[$_] .= ' ';
> }
> $i++;
> }
> for ( 0 .. $linesm1 ){
> $line[$_] =~ s/(.)/$1/g;
> print OUT "$line[$_]\n";
> }
> close OUT;
> close IN;
> }
>
> ------------------------------------------------
>
> Thanks
>
>
> Aaron Nielsen PNG/CMO/PE&TE
> 503-712-1822
>
>
--------------------------------------------------
Minneapolis Perl Mongers mailing list
To unsubscribe, send mail to majordomo at pm.org
with "unsubscribe mpls" in the body of the message.
More information about the Mpls-pm
mailing list