avatar
f*y
1
【 以下文字转载自 Programming 讨论区 】
【 原文由 ferry 所发表 】
I got a text file like this:
avatar
z*u
2
if you cannot figure this out from books by yourself, you probably need to go
through some formal training...

【在 f***y 的大作中提到】
: 【 以下文字转载自 Programming 讨论区 】
: 【 原文由 ferry 所发表 】
: I got a text file like this:

avatar
f*y
3
there sure is a lot i need to learn :)
actually i had ideas for most of my questions..
i was just trying to look for better ways, seek
guru's (well, anyone who's better than me in any way
can be a guru for me) segguestion..
by that, i learned a lot too..:)

【在 z*****u 的大作中提到】
: if you cannot figure this out from books by yourself, you probably need to go
: through some formal training...

avatar
z*u
4
sorry i should not have said that...
perl's philosophy is that "there's always a better way to do it..." and of
course, there's always people who know better way to do it. you are absolutely
in the right perl thinking mode. :)
if the file is not too big, i would do this
while(<>) {
foreach $word (split) {
if ($word =~ /^cbo-[0-9]*$/i) {
push @cbo_strings, $word;
}
}
}
print @cbo_strings;
#share with us if you have better idea...

go

【在 f***y 的大作中提到】
: there sure is a lot i need to learn :)
: actually i had ideas for most of my questions..
: i was just trying to look for better ways, seek
: guru's (well, anyone who's better than me in any way
: can be a guru for me) segguestion..
: by that, i learned a lot too..:)

avatar
f*y
5
that's ok, don't worry about it.
I like shishishishi's solution:
if ( $words =~ /cbo-(\d+)/ig ) {
$issues .= "cbo-$1 ";
}
something like that.. maybe i didn't make it clear, a words in the text can
be "cbo-1234,", but i need cbo-1234 too. :)

absolutely
to

【在 z*****u 的大作中提到】
: sorry i should not have said that...
: perl's philosophy is that "there's always a better way to do it..." and of
: course, there's always people who know better way to do it. you are absolutely
: in the right perl thinking mode. :)
: if the file is not too big, i would do this
: while(<>) {
: foreach $word (split) {
: if ($word =~ /^cbo-[0-9]*$/i) {
: push @cbo_strings, $word;
: }

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。