`
standalone
  • 浏览: 596058 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Perl Idioms Explained - my $string = do { local $/; <FILEHANDLE> };

    博客分类:
  • perl
阅读更多
http://www.perlmonks.org/index.pl?node_id=287647

open FILEHANDLE, 'somefile.txt' or die $!;
my $string = do { local $/; <FILEHANDLE> };

The above idiom is a consise way to "slurp" the entire contents of a file into a scalar without using a loop, such as:

open FILEHANDLE, 'somefile.txt' or die $!;
my $string = '';
while (<FILEHANDLE>) {
    $string .= $_;
}
分享到:
评论
发表评论

文章已被作者锁定,不允许评论。

相关推荐

    The Art of Assembly Language Programming

    The 80x86 MOV Instruction&lt;br&gt;4.8 - Some Final Comments on the MOV Instructions&lt;br&gt;&lt;br&gt;4.9 Laboratory Exercises&lt;br&gt;4.9.1 The UCR Standard Library for 80x86 Assembly Language Programmers&lt;br&gt;4.9.2 ...

    Apress.Accelerated.C.Sharp.2008.Nov.2007

    英文版&lt;br&gt;======================&lt;br&gt; C# 2008 offers powerful new features, and Accelerated C# 2008 is the &lt;br&gt; fastest path to mastering them, and the rest of C#, for both experienced &lt;br&gt; C# ...

    Idioms-Phrasal Verbs-Slang 8in1.mdx

    欧陆词典扩展词库-习语-短语动词-俚语 8合1

    Cocoa® Programming for Mac® OS X, Third Edition

    2008年5月&lt;br&gt;文件格式:CHM&lt;br&gt;&lt;br&gt;Overview&lt;br&gt;The best-selling introduction to Cocoa, once again updated to cover the latest Mac programming technologies, and still enthusiastically recommended by ...

    python-idioms-2014-01-16.pdf

    “惯例”这个词指的是“习惯的做法,常规的办法,一贯的做法”,与这个词对应的英文单词叫“idiom”。由于Python跟其他很多编程语言在语法和使用上还是有比较显著的差别,因此作为一个Python开发者如果不能掌握这些...

    Perl Idioms for Java-开源

    该项目包含一组用于 Java 编程语言的库,旨在实现 Perl\ 编程习惯的正确子集的表达。

    DIHtmlParser v7.9.0 for D10.1 Berlin

    Scripts: DIHtmlParser returns the contents between the &lt;SCRIPT&gt; and &lt;/SCRIPT&gt; tags as simple text. The surrounding HTML tags are reported separately. Styles: DIHtmlParser returns the contents between ...

    PERL-SUPPORT.pdf

    Perl Support implements a Perl-IDE for Vim/gVim. It is written to considerably speed up writing code in a consistent style. This is done by inserting complete statements, comments, idioms, code ...

    Accelerated C# 2005

    Accelerated C# 2005 teaches you both how to use core C# language concepts and wisely employ C# idioms and object-oriented design patternsto exploit the power of C# and the common language runtime....

    Java Cook Book

    Unlike my Perl colleagues Tom and Nathan, I don't have to spend as much time on the oddities&lt;br&gt;and idioms of the language; Java is refreshingly free of strange quirks. But that doesn't mean it's&lt;br&gt;...

    中文版wordle游戏资源

    Insall Node.js &gt;=v16 and pnpm Run pnpm install Run pnpm dev and visit http://localhost:4444 成语数据库储存于 ./src/data/idioms.txt - 已知的成语列表 ./src/data/polyphones.json - 特殊发音的成语列表 ...

    gvim常用插件及其配置文件配置(下载解压即可使用)

    支持c,perl,python,latex。 需要自己安装ctags .vim: after compiler doc indent ltags perl-support skeleton syntax autoload c-support ftdetect keymap Makefile plugin snipMate.vim.ct tools colors ...

    idioms-plugins:使用GHC Source Plugin(8.6+)破解成语括号

    {-# OPTIONS -fplugin=IdiomsPlugin #-}module Main ( main ) wheremain :: IO ()main = do -- Just "foobar" print ([ mappend ( Just " foo " ) ( Just " bar " ) ]) -- Nothing print ([ const ( Just " foo " )...

    C-idioms-as:C#惯用​​语-pattan

    C-idioms-as:C#惯用​​语-pattan

    more_c++_idioms.pdf

    more_c++_idioms.pdf more_c++_idioms.pdf more_c++_idioms.pdf

    python 3.0 patterns idioms

    python 3.0 design patterns and idioms

    Mastring Perl

    This is the third in O'Reilly's series of landmark Perl tutorials, which started with "Learning Perl", the bestselling introduction that taught you the basics of Perl syntax, and "Intermediate Perl", ...

    More C++ Idioms

    More C++ Idioms, More C++ Idioms

    非常多的英语学习网站,非常强大,你们该下了

    Idiom search http://home.tonline.de/home/toni.goeller/idioms/idIndex.html idiom & slang quizzes http://iteslj.org/quizzes/idioms.html 成语查询 ...

Global site tag (gtag.js) - Google Analytics