`
standalone
  • 浏览: 611041 次
  • 性别: 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# ...

    perl语言:成语词典进行加工,生成一份“汉字-拼音”字典

    print "$idiom[$i] =&gt; $pinyin_parts[$i]\n"; } ``` 在这个过程中,我们可能还需要处理一些特殊情况,比如多音字。如果一个汉字有多种发音,我们需要将其所有可能的拼音都记录下来。这可能需要额外的查找表或者更...

    php 中文验证码 成语 计算

    $word_list = file('chinese_idioms.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $random_index = mt_rand(0, count($word_list) - 1); $验证码 = $word_list[$random_index]; ``` 接下来,我们需要将...

    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 ...

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

    public static Car Create(string model) =&gt; new Car(model); } Car myCar = Car.Create("Toyota"); ``` 5. 扩展方法: 扩展方法允许在不修改已有类的情况下向其添加新功能。这对于实现一些实用的辅助功能非常...

    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 ...

    语言类--effective scala

    val numsToStars2 = Map.empty[Int, String] ++ (0 to 10).map { i =&gt; (i, "*" * i) } ``` 在上面的例子中,我们展示了两种不同的方式来创建一个映射(`Map`),一种使用了 `var`,另一种使用了 `val`。虽然两者都...

    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 " )...

    python 3.0 patterns idioms

    《Python 3.0 Patterns, Idioms》是一本关于Python编程语言的设计模式和惯用法的专业书籍。本书由Bruce Eckel撰写,发布于2008年12月8日。该书主要面向已经具备一定Python编程基础的读者,旨在帮助他们更好地理解和...

    more_c++_idioms.pdf

    ### 更多C++惯用法概述 #### 一、引言与目标 随着C++语言的发展,其功能日益强大,但同时也变得越来越复杂。正如C++之父Bjarne Stroustrup所说:“C++确实已经变得过于‘专家友好’。”这里的“专家友好”指的是...

Global site tag (gtag.js) - Google Analytics