Re: writung to file

2007-06-22 Thread Chas Owens
On 6/21/07, Vahid Moghaddasi <[EMAIL PROTECTED]> wrote: On 6/21/07, Chas Owens <[EMAIL PROTECTED]> wrote: > > Well, first you don't use awk inside of Perl. This is about as useful > as riding a bike on a bus. > Thanks, that worked very well for me. Beside the force of habit, awk was the only way

Re: writung to file

2007-06-21 Thread Vahid Moghaddasi
On 6/21/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: On Jun 21, 1:10 pm, [EMAIL PROTECTED] (Chas Owens) wrote: > print $out $_ unless $h{(split ':')[0]}++; Just curious - why are you coding around possible duplicates? Can a passwd file have duplicate entries? This is a part of a l

Re: writung to file

2007-06-21 Thread yitzle
You can get only the first unique occurance of UID's with a hash. Untested code below. I'm assuming the file has a UID followed by a home path seperated by whitespace. my %data; while(<$fileHandle>) { my($UID, $home) = split /\s/; $data[$UID] = $home if ( ! defined $data[$UID] ); } -- To unsub

Re: writung to file

2007-06-21 Thread usenet
On Jun 21, 1:10 pm, [EMAIL PROTECTED] (Chas Owens) wrote: > print $out $_ unless $h{(split ':')[0]}++; Just curious - why are you coding around possible duplicates? Can a passwd file have duplicate entries? -- The best way to get a good answer is to ask a good question. David Filmer (ht

Re: writung to file

2007-06-21 Thread Vahid Moghaddasi
On 6/21/07, Chas Owens <[EMAIL PROTECTED]> wrote: Well, first you don't use awk inside of Perl. This is about as useful as riding a bike on a bus. Thanks, that worked very well for me. Beside the force of habit, awk was the only way I could get the password file sorted unique and always keep

Re: writung to file

2007-06-21 Thread Chas Owens
On 6/21/07, Vahid Moghaddasi <[EMAIL PROTECTED]> wrote: Hi all, I wrote the following simple code to sort UNIX's password file, it works fine but I can only display the ouput on the stdout. How can I make it write the output to a file? Thanks, #!/bin/perl -w # use strict; open(myFILE, '|-','awk'