Crazy you can do that. Now I'm wondering if it's possible to allocate memory with mmap and run JITed code.
#!/usr/bin/perl
use strict;
use warnings;
use v5.10;
my $syscall_read = 0;
my $syscall_lseek = 8;
my $file = shift // exit;
open my $fh, "<", $file or die "can't open '$file': $!";
my $buf_size = 32*1024;
my $buf = "\x00" x $buf_size;
while (1) {
my $read = syscall($syscall_read, fileno($fh), $buf, $buf_size);
if ($read < 0) {
say STDERR "ERROR: $!";
last;
}
elsif ($read == 0) {
last;
}
else {
print substr($buf, 0, $read);
}
}
close $fh;