slurp


Perl 6 has a built in mode to slurp in files, that is to read the contents of a whole file into a scalar variable.

examples/files/slurp_file.p6
#!/usr/bin/perl6
use v6;

my $filename = 'examples/files/slurp_file.p6';

my $data = slurp $filename;
say $data.bytes;

Copyright 2006, 2007, 2008, 2009, 2010 Gabor Szabo http://szabgab.com/ Index | TOC
If you are interested in on-site trainings by the author, please contact me directly.

Online courses:

Would you like to get
updated when I publish
the next article?

Follow me:

Google Plus Twitter RSS feed