aki7002 has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Regular Expression
by Utilitarian (Vicar) on Oct 23, 2010 at 08:09 UTC
    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."
Re: Regular Expression
by Corion (Patriarch) on Oct 23, 2010 at 06:30 UTC

    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.

Re: Regular Expression
by bart (Canon) on Oct 23, 2010 at 10:45 UTC
    my @result = map /^COM USAGE .* (\d+)$/, <>;
    Understanding how it works is left as an exercise for the user.
Re: Regular Expression
by ig (Vicar) on Oct 23, 2010 at 08:00 UTC
Re: Regular Expression
by CountZero (Bishop) on Oct 23, 2010 at 07:47 UTC
    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

Re: Regular Expression
by jwkrahn (Abbot) on Oct 23, 2010 at 11:23 UTC
    my @numbers; while ( <> ) { next unless /^COM USAGE/; push @numbers, ( /\d+/g )[ 1 ]; }