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

I've loaded a file into an array using Tie::File and I'm using grep load arrays with matching lines. This works fine for the various lines I want to extract, but not for one set of lines where I need just the second part of the lines that have a colon but not the colon nor what comes before it. Is there a way to use ${^POSTMATCH} to solve this problem?

I'm using...
@lines = grep (/:/, @array);
My current output looks like...
Date: 1 Mon 2007 Operator: Bill Manufacturer: Harris Corporation
But what I need is...
1 Mon 2007 Bill Harris Corporation
Thank you for your time and effort.

Replies are listed 'Best First'.
Re: Can I Postmatch an array element?
by ikegami (Patriarch) on Mar 20, 2010 at 03:32 UTC
    my @lines = map { /:\s*(.*)/ ? $1 : () } @array;
    Of course, Tie::File is totally useless here. You can use
    my @lines = map { /:\s*(.*)/ ? $1 : () } <$fh>;
Re: Can I Postmatch an array element?
by Anonymous Monk on Mar 20, 2010 at 03:34 UTC

    You can use map to solve that problem:

    my @lines = map /:\s*(.+)/, @array;
Re: Can I Postmatch an array element?
by softserve (Initiate) on Mar 20, 2010 at 05:43 UTC
    Thank you all for your help. Map did the trick.