in reply to How to display first line of each record using the question code

TIMTOWTDI ... but this works for me:

use strict; use warnings; use feature 'say'; local $/="__data__\n"; while (my $record=<DATA>){ # say "<$record>"; my @lines = split /\n/, $record; say $lines[0]; } __DATA__ 1aaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaa __data__ 1bbbbbbbbbb bbbbbbbbbbb bbbbbbbbbbb __data__ 1cccccccccc ccccccccccc ccccccccccc __data__

output

1aaaaaaaaaa 1bbbbbbbbbb 1cccccccccc

> I need a solution that follows the code question...

what does this mean?

Cheers Rolf

( addicted to the Perl Programming Language)

Replies are listed 'Best First'.
Re^2: How to display first line of each record using the question code
by SatisfyMyStruggles (Initiate) on May 18, 2013 at 17:36 UTC

    My problem is I can't get $/="__Data__\n" to work using my code

      > I can't get $/="__Data__\n" to work

      My code works, so yours must be wrong! :)

      Try to trek down the problem by replacing the "code in question" bit by bit.

      Did you use double-quotes?

      Does "\n" really immediately follow "__Data__" in your data?

      Cheers Rolf

      ( addicted to the Perl Programming Language)

      A reply falls below the community's threshold of quality. You may see it by logging in.