On 5/9/06, Per Larsson <[EMAIL PROTECTED]> wrote:
snip
ie. get everything that is sitting between two ATOM-identifiers to occur
on the same line. How can I achieve this?

As always, TMTOWTDI:

You can set the input record separator

use strict;
use warnings;
{
local $/ = 'ATOM\n';
<>; #throw away the first instance of ATOM\n since it is a record header
while (<>) {
   my $record = <>;
   chomp $record; #get rid of ATOM\n at the end of the record
   my @fields = split /\n/, $record;
   print "ATOM @fields\n";
}
}

you can remove the newlines from every field and print it plus a
space, and only print newlines before printing the ATOM field
(remember to put the extra print at the end)

while (<>) {
   chomp;
   print "\n" if /^ATOM/ and $. !=  1;
   print "$_ ";
}
print "\n";

I am certain other people could come up with different solutions.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to