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

Hi, Can anybody please tell me why we have use local with $/(i.e. input record separator or slurp mode). Thanks in advance, SS

Replies are listed 'Best First'.
Re: Perl special variables
by choroba (Cardinal) on Jun 20, 2012 at 08:55 UTC
    Do you mean "why we have used"? I fear it is up to you to know.
    Or, do you mean "why we have to use"? Well, you do not have to. But it is a good practice, because without localizing $/, processing of a different file in a different part of the code can break. See also Perl Idioms Explained - my $string = do { local $/; <FILEHANDLE> };.
      Thanks for providing link. I understood by reading it.

        Thanks for providing link. I understood by reading it.

        Great, maybe you can write and post the answer

Re: Perl special variables
by Anonymous Monk on Jun 20, 2012 at 08:54 UTC

    No, do your own homework, read the documentation for local, and then you'll know

    perldoc -f local

Re: Perl special variables
by Neighbour (Friar) on Jun 20, 2012 at 11:32 UTC
    Because perlcritic will shout at you if you do not :)