> On Tue, 20 Jan 2004 13:39:44 -0500
> "Anthony J Segelhorst" <[EMAIL PROTECTED]> wrote:
> 
> > I have the following output, and each value that is separated by
comma is 
> > a variable:
> > 
> > servera,serverb,109,aix4-r1,server
> > servera,serverb,109,aix4-r1,server
> > servera,serverb,109,aix4-r1,server
> > servera,serverb,109,aix4-r1,server
> > servera,serverb,109,aix4-r1,server
> > servera,serverb,109,hpux10,server
> > servera,serverb,109,solaris2,server
>  
> > 
> > I am trying to set up a counter that would actually output the data
to be:
> > 
> > servera,serverb,109,aix4-r1,server,5
> > servera,serverb,109,hpux10,server,1
> > servera,serverb,109,solaris2,server,10
> > 
> > Does anyone any suggestion on how to set up a counter to count the
lines 
> > until a different line shows up.  I already have the list sorted, so I 
> 
> 
> 
> system ("uniq $file_with_duplicates $file_sans_duplicates");
> 
> Then work on $file_sans_duplicates
> 

Please DON'T do it this way. Shelling out from Perl to a program like
'uniq' should be a last resort. If you are going to suggest such
procedures at least do them justice by using full paths, and doing the
proper amount of error handling, the above is not sufficient and
shouldn't be considered so.  In most cases it is slower, less secure,
and more error prone.  Some will disagree and that is fine, but at the
very least indicate that this is a quick and dirty hack and there are
times that quick and dirty is NOT elegant. Chances are if the OP had to
ask such a question they can't wield 'system' properly.....

http://danconia.org 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to