Re: Searching in a line
- From: it_says_BALLS_on_your forehead <simon.chao@xxxxxxx>
- Date: Wed, 29 Aug 2007 20:51:40 -0000
On Aug 29, 4:45 pm, lerameur <leram...@xxxxxxxxx> wrote:
Hello all,
I want to do a search in a log file. each line has the following
pattern:
34,56,,9,0,0,,,,65;
So there 10 section. How do I parse through different sections?
meaning I want section 4, which is the number 9
if every possible value within a 'section' cannot contain a comma ',',
then you can just split on a comma, and take the 4th section.
my $log = 'log.txt';
open my $fh, '<', $log or die "can't open '$log': $!\n";
while ( <$fh> ) {
my $val = (split /,/)[3];
print $val, "\n";
}
close $fh;
.
- References:
- Searching in a line
- From: lerameur
- Searching in a line
- Prev by Date: why warn on undefined $1?
- Next by Date: Re: why warn on undefined $1?
- Previous by thread: Searching in a line
- Next by thread: Re: Searching in a line
- Index(es):
Relevant Pages
|
|