【 以下文字转载自 Programming 讨论区 】 【 原文由 ferry 所发表 】 I got a text file like this:
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:
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...
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..:)
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; : }