Rob Dixon wrote:
> 
> If you set the input record separator - $/ - to a null string then it will
> split the input file on one or more blank lines.
> 
> Take a look at the program below.
> 
> #!perl
> use strict;
> use warnings;
> 
> local $/ = '';
> 
> while (<DATA>) {
>   my @data = split /\n/;
>   print join(':', @data), "\n";
> }
> 
> __DATA__
> Date
> Team Name 1
> Team Name 2
> Field1
> Field2
> FieldX
> 
> Date
> Team Name 3
> Team Name 4
> Field 1
> FieldX
> 
> **OUTPUT
> 
> Date:Team Name 1:Team Name 2:Field1:Field2:FieldX
> Date:Team Name 3:Team Name 4:Field 1:FieldX

TMTOWTDI   :-)

#!/usr/bin/perl
use strict;
use warnings;

( $/, $\ ) = ( '', "\n" );
while ( <DATA> ) {
    chomp;
    tr/\n/:/;
    print;
    }

__DATA__
Date
Team Name 1
Team Name 2
Field1
Field2
FieldX

Date
Team Name 3
Team Name 4
Field 1
FieldX



John
-- 
use Perl;
program
fulfillment

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