[sf-perl] help with matching?

Paul Makepeace Paul.Makepeace at realprogrammers.com
Mon Jul 12 11:47:29 PDT 2010


Here's a simplification,

perl -lne 'print "$1, $2, $3" if
/(\d+\.\d+\.\d+\.\d+)\s+([-\w]+(?:\.[-\w]+)+)\s+([-\w]+(?:\.[-\w]+)+)/'
10.80.15.14     srwd15abx001.srwd15.com   srwd15hst001.srwd15.com
10.80.15.14, srwd15abx001.srwd15.com, srwd15hst001.srwd15.com

I personally tend to go liberal on the parser rather than trying to match
the matcher to the input precisely.

CPAN advocates would say, "Use http://search.cpan.org/dist/Regexp-Common/ !"
:-)

HTH,
Paul

On Mon, Jul 12, 2010 at 11:30, David Alban <extasia at extasia.org> wrote:

> 10.80.15.14     srwd15abx001.srwd15.com   srwd15hst001.srwd15.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/sanfrancisco-pm/attachments/20100712/e2c16e39/attachment.html>


More information about the SanFrancisco-pm mailing list