in reply to Position in seek() confusion

It's not at all clear to me how B::Deparse makes it obvious for people not familiar with seek... OTOH, Devel::Peek does. This is on Linux:
open my $fh, '>', 'junk.dat' or die $!; for ( 1 .. 4 ) { seek $fh, $_ * 80, 0; print $fh $_ x 78, "\r\n"; } open $fh, '<', 'junk.dat' or die $!; while ( <$fh> ) { use Devel::Peek; Dump $_; }
output:
SV = PV(0x189fd70) at 0x18c0a38 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x18a4610 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 +\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ +0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0001111111111111111111111111111 +11111111111111111111111111111111111111111111111111\r\n"\0 CUR = 160 LEN = 200 SV = PV(0x189fd70) at 0x18c0a38 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x18a4610 "2222222222222222222222222222222222222222222222222222 +22222222222222222222222222\r\n"\0 CUR = 80 LEN = 200 SV = PV(0x189fd70) at 0x18c0a38 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x18a4610 "3333333333333333333333333333333333333333333333333333 +33333333333333333333333333\r\n"\0 CUR = 80 LEN = 200 SV = PV(0x189fd70) at 0x18c0a38 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x18a4610 "4444444444444444444444444444444444444444444444444444 +44444444444444444444444444\r\n"\0 CUR = 80 LEN = 200
So, when you seek past the end of file, it's as if the filesystem fills that part of file (0 .. 79 bytes in our case) with zero bytes (actually it creates a 'hole' in the file, which, when read, returns zeros - apparently NTFS also does that?). These zero bytes are then actually printed, just not displayed on the terminal:
$ perl -E 'say "\0\0\0ABC" ABC $ perl -E 'say "\0\0\0ABC"' | perl -nE 'printf "%vx\n", $_' 0.0.0.41.42.43.a