在 qw 中保留空白 [英] Preserving White Space in qw

查看:56
本文介绍了在 qw 中保留空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在 qw 中保留一些空白?例如:

Is there any way to preserve some white space in qw? For example:

my @a=qw(1234 John Smith 123 Main St.);

将产生一个包含 6 个元素的数组.有什么办法,哦,我不知道……逃离空白空间以保留一些?类似的东西:

will produce an array containing 6 elements. Is there any way to, oh I don't know... escape the white space to keep some of it? Something like:

my @a=qw(1234 John\ Smith 123\ Main\ St.);

返回 3 个元素:'1234'、'John Smith'、'123 Main St.'?

to return 3 elements: '1234', 'John Smith', '123 Main St.'?

(仅供参考,我已经尝试了上述方法,也使用了不同的引号组合,但都无济于事)

(FYI, I've tried the above, also with varying combinations of quotes, all to no avail)

推荐答案

以换行符分隔:

my @a = split /\n/, <<'END';
1234
John Smith
123 Main St.
END

这篇关于在 qw 中保留空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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