Search code examples
perlslurp

How does the Perl's Slurp module work?


I had a look at the source of Slurp and I would love to understand how does slurp() work:

sub slurp { 
    local( $/, @ARGV ) = ( wantarray ? $/ : undef, @_ ); 
    return <ARGV>;
}

Where is the file even opened?


Solution

  • See ARGV and $/ in perldoc perlvar.

    See also Path::Class:File::slurp.