textarea如何定义换行符? (perl的) [英] How does textarea define newline? (perl)

查看:71
本文介绍了textarea如何定义换行符? (perl的)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

发生了什么?


文本输入到HTML textarea输入:


field1 = 1

field2 = 2

field3 = 3

此数据存储在文本文件中:

what''s going on?

text entered into an HTML textarea input:

field1=1
field2=2
field3=3

this data gets stored in a text file:

展开 | 选择 | Wrap | 行号

推荐答案

发布此类问题时,最好发布一个简短但完整的脚本和HTML代码来演示此问题这样我们就可以运行它而无需编写可能与您的情况不符的代码。


我需要运行测试,但您看到的问题可能是由于Windows(\\\\ n)和unix(\ n)行结尾之间的差异。您可以使用* nix od命令查看和验证行结尾。


使用Data :: Dumper模块查看var包含的内容也是个好主意。


您是否真的在同一个脚本中写入和读取data.txt?如果是这样,那并不是很有意义,并且是处理表单提交数据的一种非常尴尬的方式。


你的getParam()子也是一种奇怪而低效的方法。 br />

以下是您的代码的一些问题。

1)使用bareword文件句柄

2)使用2 arg而不是3 arg形式的公开电话

3)打开电话没有错误处理

4)引用时使用@而不是
When posting questions like this, it''s best to post a short but complete script and html code that demonstrates the issue so that we can run it without having to make up our own code which may not match your situation.

I will need to run a test but the issue you''re seeing may be due to the difference between Windows (\r\n) and unix (\n) line endings. You can use the *nix od command to view and verify the line endings.

It''s also a good idea to use the Data::Dumper module to see what a var contains.

Are you really writing to and reading from data.txt in the same script? If so, that doesn''t make mush sense and is a very awkward way to handle the form submission data.

Your getParam() sub is also an odd and inefficient approach.

Here are some of the issues with your code.
1) Using bareword filehandles
2) Using 2 arg instead of 3 arg form of the open call
3) No error handling on the open calls
4) Using @ instead of


数组元素

5)当它更合适时无法使用push
when referencing array element
5) Failure to use push when it''s more appropriate


问题在于你的子程序。它正在放弃第一行(field1)。


我现在正在查看它以找出原因和修复,但你真的应该放弃那个并使用CGI模块提供的方法。
The problem is with your subroutine. It''s dropping the first row (field1).

I''m looking over it now to find out why and the fix, but you really should drop that sub and use the methods provided by the CGI module.


这篇关于textarea如何定义换行符? (perl的)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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