是否有从Perl创建的文本文件的行长度限制? [英] Is there a line length limit for text files created from Perl?

查看:267
本文介绍了是否有从Perl创建的文本文件的行长度限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在写一个Perl脚本的时候,我需要在文件的一行中用逗号分隔来写用户名。



这就是为什么我想知道.txt文件中行的最大尺寸是否有任何限制。

解决方案

文本文件就像任何其他文件一样文件和换行符就像任何其他字符一样,所以只有通常的文件大小限制适用(在旧文件系统的4Gb大小限制,文件必须适合在磁盘等)。

除非您逐行读取,否则读取和写入时不会遇到任何问题,否则可能会遇到内存不足或遇到缓冲区溢出问题。这可能发生在任何文本编辑器或文本处理程序(如sed或awk)中,因为与操作系统内核不同,在这些行分隔事项中,我建议保留一个用户每行,因为它是更自然的阅读,并且当你用外部程序处理文件时,更容易出错。


While writing a Perl script, I got a requirement to write the user names with comma separation in only one line of the file.

That's why I would like to know is there any restriction on the maximum size of the line in the .txt file.

解决方案

Text files are just like any other files and newline character is like any othe character, so only the usual filesize restrictions apply (4Gb size limit on older file systems, file must fit on the disk etc.)

You won't encounter any problem reading and writing it, unless you're reading it line by line—you can run out of memory then or encounter a buffer overflow of sorts. This may happen in any text editor or text processing program (such as sed or awk), because, unlike OS kernel, in those line separation matters

I would suggest keeping one user per line, as it's more natural to read and less error-prone when you process the file with an external program.

这篇关于是否有从Perl创建的文本文件的行长度限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆