Re: [Nolug] PERL Question

From: Mark A. Hershberger <mah_at_everybody.org>
Date: Thu, 14 Oct 2004 07:09:33 -0400
Message-ID: <416E5E6D.8070602@everybody.org>

Wimprine, Thomas wrote:
> That works on exact matches however the string I'm trying to match on is
> part of a path "/home/production/servername/configfile.cfg". I'm trying to
> match on the servername part, and it is not always the same path.

So, instead of populating %list like this:

> $list{$_} = 1
> for @list;

use this:

> $list{$_} = 1
> map {m"/home/production/([^/]+)/configfile.cfg"; $1}
> for @list;

@list will be a list of your pathnames.

If you need @list to be a list of pathnames, then change

> @list = grep {$list{$_}} @ARGV;

to

> @list = map {"/home/production/$_/configfile.cfg"}
> grep {$list{$_}} @ARGV;

Mark.
___________________
Nolug mailing list
nolug@nolug.org
Received on 10/14/04

This archive was generated by hypermail 2.2.0 : 12/19/08 EST