Re: Re: Grep uniqueness issue
- From: jason_normandin@xxxxxxxxxxx (Jason Normandin)
- Date: Fri, 29 Jul 2005 11:26:18 -0400
Unfortunately I cannot as this is a cross-platform implementation. I need to avoid using any OS dependant commands.
>
> From: Eric Walker <ewalker@xxxxxxxxxx>
> Date: 2005/07/29 Fri AM 11:19:16 EDT
> To: beginners@xxxxxxxx
> CC: jason_normandin@xxxxxxxxxxx
> Subject: Re: Grep uniqueness issue
>
> can you use the uniq command?
>
> On Friday 29 July 2005 09:03 am, jason_normandin@xxxxxxxxxxx wrote:
> > Hey Guys
> >
> > I am having an odd problem using grep to ensure an array only contains
> > distinct entries.
> >
> > I have a list similar to the following in a file (short example of a much
> > longer list)
> >
> > support01-FastEthernet1/0
> > support01-RH
> > jnormandin-p370-1691-SH-Cpu-2
> > jnormandin-p370-1691-SH
> >
> > These entries may or may not appear multiple times within that list.
> >
> > I am trying to create an ARRAY containing each of these entries only once
> > (a distinct list). I am using a grep statement:
> >
> > push @pingErrorsName, $element if (! grep (/\b$element\b/,
> > @pingErrorsName));
> >
> > * Where $element contains one of the above names in the list and
> > @pingErrorsName is the distinct list of elements.
> >
> > What I am finding is that the array will contain all of the correct entries
> > except: jnormandin-p370-1691-SH. It appears as though the grep is matching
> > jnormandin-p370-1691-SH to the jnormandin-p370-1691-SH-Cpu-2 string (as it
> > is a substring of the second one).
> >
> > Now I am using word boudnary anchors (\b) in the grep so I am confused as
> > to why this is not working.
> >
> > Does anyone have any ideas as to why this is occuring and how I can prevent
> > it?
>
> --
> Eric Walker
> EDA/CAD Engineer
> Work: 208-368-2573
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
> For additional commands, e-mail: beginners-help@xxxxxxxx
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
.
- Prev by Date: Re: Grep uniqueness issue
- Next by Date: Re: Grep uniqueness issue
- Previous by thread: Re: Grep uniqueness issue
- Next by thread: Re: Re: Grep uniqueness issue
- Index(es):
Relevant Pages
|