Otogi has asked for the wisdom of the Perl Monks concerning the following question:

I have seperated text from a file during input using $/="--", then put each seperated block in $line. The problem is the seperated text is more than one line (a block) and i cant seem to be able to seperate it further using the split function with \n or " " as a delimiter into lines. How can I go about separating the block further?

Replies are listed 'Best First'.
Re: how to split blocks of text
by b10m (Vicar) on Nov 08, 2005 at 11:19 UTC

    Why isn't split working for you?

    $text=<<"EOT"; Line 1 Line 2 Line 3 EOT foreach ( split(/\n/, $text) ) { print "* $_\n"; }
    --
    b10m

    All code is usually tested, but rarely trusted.

      Or even

      foreach ( split(/^/, $text) ) { print "* $_"; }
Re: how to split blocks of text
by TedPride (Priest) on Nov 08, 2005 at 11:22 UTC
    One possibility is that your file uses \r as well as \n for line delimiters. As you can see from the following, there should be no problems with the split itself:
    $/ = "--"; while (<DATA>) { chomp; @_ = split /\n/, $_; print "Second Line: $_[1]\n"; } __DATA__ multi line--data goes here