RE: [Nolug] PERL Question

From: Wimprine, Thomas <twimprine_at_stei.com>
Date: Thu, 14 Oct 2004 09:40:10 -0500
Message-ID: <7A727C65F1901E46BBFE6D9C4C5D82FC0255DFBA@lajeffeex02.stewartenterprises.com>

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.

-----Original Message-----
From: owner-nolug@joeykelly.net [mailto:owner-nolug@joeykelly.net] On Behalf
Of Mark A. Hershberger
Sent: Thursday, October 14, 2004 5:21 AM
To: nolug@joeykelly.net
Subject: Re: [Nolug] PERL Question

Wimprine, Thomas wrote:
> Let me clarify something if the $list[$num] does not contain $ARGV[$num]
> then delete;

--- start file.pl ---
#!/usr/bin/perl -w

my @list = qw(one two three);

my %list;

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

@list = grep {$list{$_}} @ARGV;
print join(", ", @list), "\n";
--- end file.pl ---

Sample runs:
$ perl file.pl one
one
$ perl file.pl one two four
one two
$ perl file.pl

$

Is that what you wanted?

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

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