That code is a bit tricky, since you're now changing the behaviour of $/
throughout the entire file
A bit safer way to do this would be the following:
open I, "yourfile.txt"; #open a textfile for reading
{ local $/; #undef $/, which is essentially the
same as $/ = ''; we use the 'local' to make sure it's value get's
restored upon exiting the block
my $in = <I>; #put all of the file in $in;
do_stuff_with($in) #do some stuff with the text in $in
} # exit loop, restore $/; NOTE: this
also resets the value of $in... if you dont want that, set the 'my $in'
above the block, rather then in it
hth,
Jos Boumans
Me wrote:
> > Can anyone send me any solution
> > to read the paragraph from a text file?
>
> To read paragraphs (delimited by one or more blank
> lines (really blank, no spaces or tabs)), change the
> record separator from its default (newline) to the
> null string ('').
>
> $/ = '';
>
> while (<>) {
> print;
> }