Steve Massey wrote:
>
> my problem is one of progam concept, a data file is as below,
> my code (which is not doing what I want it to do is below)
>
> I want to parse a file with a known 3 blank lines to number 1,
> then for each other number it could be either 3 or 4 blank lines.
> Each number has to be checked to see it's valid ie in sequence,
> and the next number follows with again a 3 or 4 increment
>
> Has anyone got any ideas on how I could get this code to work ???
> I am stumped ...

Hi Steve.

Setting the record-separator to a null-string

  $/ = ''

will make Perl treat one or more blank lines
as a delimiter. This makes for a very concise solution
as below.

HTH,

Rob




my @data;

{
  local $/ = '';
  chomp (@data = <DATA>);
}

print "<@data>\n";

__DATA__



1



2




3



4

** OUTPUT **

<1 2 3 4>




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to