TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ruby DATA

45 pointsby EzGraphsover 12 years ago

4 comments

edwardover 12 years ago
This is copied from Perl. See <a href="http://stackoverflow.com/questions/161872/hidden-features-of-perl#163700" rel="nofollow">http://stackoverflow.com/questions/161872/hidden-features-of...</a><p><pre><code> my @lines = &#60;DATA&#62;; for (@lines) { print if /bad/; } __DATA__ some good data some bad data more good data more good data</code></pre>
评论 #5031661 未加载
评论 #5032586 未加载
评论 #5031644 未加载
评论 #5032319 未加载
lukeholderover 12 years ago
I learnt about this a while back when sinatra was released, you could have your html template in the same file. great idea for a micro framework.
评论 #5032354 未加载
评论 #5031639 未加载
stevekempover 12 years ago
I wrote a static-site generator, and I wanted to be able to allow users to deploy new instances easily.<p>To do that I wrote some code that parses a __DATA__ block for lines like:<p>mkdir foo create_file foo/bar.txt &#60;&#60;EOF .. This is the file content .. EOF mkdir bar ..<p>The process was very simple and allowed me to bundle up the "master template" files in one simple to understand resource.<p>[1] - <a href="https://github.com/skx/templer" rel="nofollow">https://github.com/skx/templer</a> [2] - <a href="https://raw.github.com/skx/templer/master/lib/Templer/Site/New.pm" rel="nofollow">https://raw.github.com/skx/templer/master/lib/Templer/Site/N...</a>
评论 #5031647 未加载
tragomaskhalosover 12 years ago
I had thought that the ability to do a simple quine by rewinding DATA was some weird implementation bug, so nice to see the rationale here !