untitled

(ff) #1

254 10 Transforming with Traditional Programming Languages


<MotifData>
[% FOREACH label IN MotifData.keys.sort %]
<Motif id=’[% label %]’>
[% FOREACH position IN MotifData.$label %]
<DNA>
<A>[% position.A %]</A>
<C>[% position.C %]</C>
<T>[% position.T %]</T>
<G>[% position.G %]</G>
</DNA>
[% END %]
</Motif>
[% END %]
</MotifData>

Template 10.3 Perl template for formatting Perl hashes and arrays

<MotifData>
[% FOREACH label IN MotifData.keys.sort -%]
<Motif id=’[% label %]’>
[% FOREACH position IN MotifData.$label -%]
<DNA>
<A>[% position.A %]</A>
<C>[% position.C %]</C>
<T>[% position.T %]</T>
<G>[% position.G %]</G>
</DNA>
[% END -%]
</Motif>
[% END -%]
</MotifData>

Template 10.4 Perl template that avoids unnecessary blank lines
Free download pdf