为什么文件句柄不需要Perl中的sigil?(Why doesn't a filehandle need a sigil in Perl?)

在Perl中,filehandle是一种数据类型,我期望这种类型的变量具有某种类型的sigil前缀。 但是,下面的代码(第二次打开)表明情况并非如此

open my $fileHandle, '>', "out.txt";
open FH, '>', "out2.txt";

我发现第二种形式令人困惑/不一致。 允许第二种形式的原因是什么?


In Perl, filehandle is a data type, and I'd expect a variable of such type has some kind of sigil prefix. However, the following code (2nd open) shows that it's not the case

open my $fileHandle, '>', "out.txt";
open FH, '>', "out2.txt";

I found the 2nd form confusing/inconsistent. What is the reason for allowing the 2nd form?


原文:https://stackoverflow.com/questions/40831471
2020-04-25 16:04

满意答案

你应该开始看看:

ext/standard/string.c line: 2999

这是为PHP 5.4.10。

您可以使用以下方法找到它:

grep -r 'similar_text' PHP_SOURCE_FOLDER

You should start to have a look at:

ext/standard/string.c line: 2999

This is for php 5.4.10.

You can find this out for yourself using:

grep -r 'similar_text' PHP_SOURCE_FOLDER

相关问答

更多

PHP 5.3.6和PHP 5.3.8源代码兼容性(PHP 5.3.6 and PHP 5.3.8 source code compatibility)

PHP开发人员承诺至少对于微版本更新(xyz中的z)具有向后兼容性,因此应该没有问题。 The PHP developers promise backward-compatibility at least for micro-version updates (The z in x.y.z), thus there should be no problem.

similar_text如何工作?(How does similar_text work?)

根据参数顺序,这个函数的确似乎使用了不同的逻辑。 我觉得有两件事要玩。 首先,看这个例子: echo similar_text('test','wert'); // 1 echo similar_text('wert','test'); // 2 似乎是它正在测试“param2中找到了param1中有多少个不同的字符”,因此如果你交换参数,结果会是不同的。 据报道是一个bug ,没有被任何人确认。 现在,上述对于PHP和javascript实现都是一样的 - paremeter命令有影响,所以说...

PHP正在显示我的源代码?(PHP is displaying my source code?)

在5.3 short_open_tag 默认情况下禁用。 所以,如果你使用 <? ?> 代替 <?php ?> 它可能导致将来出现问题(前提是你只需在php.ini中启用该标志)。 据我所知,他们仍然在争论从6岁开始。 In 5.3 short_open_tag is disabled by default. So if you use <? ?> instead of <?php ?> it can cause issues in the future (provided y...

使用php从数据库中选择值,其中条件值类似于输入(Select value from database with php where condition value is similar to input)

您需要使用LIKE关键字 SELECT value FROM table WHERE condition like %x% 编辑: 好像你是levenshtein算法。 看看这里和这里 。 StackOverflow Thread You need make use of the LIKE keyword SELECT value FROM table WHERE condition like %x% EDIT : Seems like you are for levenshtein algo...

在Scala中重写PHP的similar_text(Rewriting PHP's similar_text in Scala)

这是一个提示:仔细观察JavaScript版本的第28行 - 特别是该行的最后一个字符。 这就是你的实现不同的地方。 (对于每对索引,您也不会将l重置为零,但这不是最重要的问题。) 顺便说一下,这是一个无变量的Scala版本: def similarText(x: String, y: String): Int = { val indices = for { (s, p) <- x.tails.zipWithIndex (t, q) <- y.tails.zipWithInde...

PHP的similar_text()和in_array()不能正常工作(PHP's similar_text() and in_array() not working as it seems like they should)

将您的添加更改为行 function addTo($line){ return strtolower(trim($line)); } 并将您的输入更改为 $input = strtolower(trim($_GET['checkSpelling'])); 文件命令有一个令人讨厌的习惯,就是留下尾随的换行符,所以你可能根本不匹配...修剪应该处理它。 其他变化只是为了使它不区分大小写。 Change your add to line to function addTo($line){ ...

如何从源代码中获取PHP版本?(How to get the PHP version from the source code?)

main/php_version.h文件包含您要查找的信息: 例如( https://github.com/php/php-src/blob/master/main/php_version.h ): /* automatically generated by configure */ /* edit configure.in to change version number */ #define PHP_MAJOR_VERSION 5 #define PHP_MINOR_VERSION 5 #de...

类似的文字php mysql(Similar Text php mysql)

我刚用一小组测试条目尝试了你的代码,它工作得很好。 也许你的查询结果很奇怪? 这是代码: $my_word = $_REQUEST['value']; $bestMatch = array('word' => $my_word, 'match' => 2); $result = array("exam", "clinicals", "templates", "reschedule", "crafting", "php", "answer"); $storeArray = Array(); fore...

php源代码中的similar_text(similar_text in php source code)

你应该开始看看: ext/standard/string.c line: 2999 这是为PHP 5.4.10。 您可以使用以下方法找到它: grep -r 'similar_text' PHP_SOURCE_FOLDER You should start to have a look at: ext/standard/string.c line: 2999 This is for php 5.4.10. You can find this out for yourself using: g...

PHP中的类似文本(similar text in PHP)

为了使索引工作,数组$arr必须具有唯一值: $arr = array("foo", "bar", "hallo", "world", "fooo", "bar1", "hall_o", "wor1ld", "bard", "hzallo", "w44orld"); $dexed = array(); foreach ($arr as $key => $value){ $dexed[$key]['val'] = $value; $dexed[$key]['key'] = $key;...

相关文章

更多

Script.NET Perl解释器代码已经在GitHub开源发布

Script.NET Perl解释器的代码已经提交到GitHub网站。GitHub项目地址: http ...

[转]So You Want To Be A Producer

pro-du-cer n. 1. Someone from a game publisher who ...

trouble is a friend

trouble will find you no matter where you go, oh ...

Fading Like a Flower - Roxette

In a time 有一次 Where the sun descends alone, 太阳孤独的降落 ...

Becoming a data scientist

Data Week: Becoming a data scientist Data Pointed, ...

ServletOutputStream cannot be resolved to a type

在使用jsp生成web图片时遇到这个问题,这是源代码中的一条语句,源代码可以执行,可是一将源码放入ec ...

Book Report: THE SOUL OF A NEW MACHINE

Book Report: THE SOUL OF A NEW MACHINE Zhengdong Zh ...

Solr: a custom Search RequestHandler

As you know, I've been playing with Solr lately, tr ...

How to Start a Business in 10 Days

With an executive staffing venture about to open, a ...

A Great List of Windows Tools

Windowsis an extremely effective and a an efficient ...

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本