Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Spliting a file into an array using blank lines as delimiter

by davorg (Chancellor)
on Dec 18, 2000 at 22:41 UTC ( #47238=note: print w/replies, xml ) Need Help??


in reply to How do I split a file into an array using blank lines as delimiter

The secret is to change $/ to the empty string. This will put Perl into 'paragraph mode', where the input record separator is one or more blank lines. Something like this:

#!/usr/bin/perl -w use strict; my @array; { local $/ = ''; @array = <DATA>; } print $array[0]; __END__ blah blah blah blah blahblahblalh oh yeah interesteing no no no nonnono yes yes

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://47238]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2021-05-12 15:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (129 votes). Check out past polls.

    Notices?