ivo Welch ivo Welch - 3 months ago 22
Perl Question

Perl6::Slurp of DATA

could someone please post a reference example of Perl6::Slurp with the DATA filehandle?

use strict;
use Perl6::Slurp;

my $contents = slurp(*DATA);

__END__
line 1
line 2


fails.

mob mob
Answer

A reference to a typeglob is a suitable argument to Perl6::Slurp::slurp, as the perldoc demonstrates.

use Perl6::Slurp;

$hw = slurp \*DATA;
print $hw;

__DATA__
hello
world
Comments