Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Ruby (and earlier, Perl) formalised this with the __END__ section: https://www.honeybadger.io/blog/data-and-end-in-ruby/



Back in the day I made a Perl script that would use an inline encryption algorithm to decode a payload and execute it in memory so it would never hit the disk. Data after the __DATA__ line.


While applying for new job once I made a self-unpacking CV in ruby using this trick; whole binary content was compressed with zlib, I also added some blank padding to get some 'nice' numbers, so I could stuff like DATA.seek(1337 * 32, IO::SEEK_CUR); needless to say either nobody appreciated the idea, then again, what I was expecting? :D


Are you sure that Perl took it from ruby and not the other way around?

(edit: a subsequent correction has obsoleted this comment)


They said "earlier, Perl".


yup. after that you can use the global var DATA to access the data injected after the __END__


When I was first learning Ruby knowing Perl rather well, it was discovering that it supported DATA/__END__ that made me feel like I was at home ...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: