Hi aki,
A couple of points, you should use <code> </code> tags around code and data also if you want to post a job spec there are several sites where you can pay people to code it for you.
If however you want to learn Perl try coding up the following and then come back to us with problems you are having, this way you learn and we get a warm happy smug feeling, a win win :)
- open your file
- while there are lines in the file:
- if the current line starts with COM, has some characters and a space followed by some digits at the end of the line, capture those digits. Take a read through The regular expression documentation paying particular attention to beginning of line and end of line anchors, capturing part of an expression and character classes.
- push the captured digits onto the array in question
- Do whatever with your array
print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."
| [reply] [d/l] |
Hello and welcome! This is not a script writing service. We will help you with concrete Perl problems you have. Please post the code you have written, some relevant input data and output data, and also the exact problem you have with the code. This helps us to help you better.
| [reply] |
my @result = map /^COM USAGE .* (\d+)$/, <>;
Understanding how it works is left as an exercise for the user. | [reply] [d/l] |
| [reply] |
It will also help if you put the data in <code> ... </code> tags so we know where a line starts and ends.
CountZero A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
| [reply] [d/l] |
my @numbers;
while ( <> ) {
next unless /^COM USAGE/;
push @numbers, ( /\d+/g )[ 1 ];
}
| [reply] [d/l] |