[mplspm]: RE: Help with a transpose script (included)

Ken Williams ken at mathforum.org
Thu Nov 29 22:06:51 CST 2001


Aaron,

Can you explain, specifically, what the code is supposed to do?  Perhaps 
an example?  What's the format of the file, i.e. what do you mean by 
"column format"?

By the way, the line "$line[$_] =~ s/(.)/$1/g;" is a very slow way to not 
do anything.  What's its intention?

 -Ken



"Nielsen, Aaron M" <aaron.m.nielsen at intel.com> wrote:

>
>> 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.




--------------------------------------------------
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