[27556] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 9102 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 29 11:05:49 2006

Date: Wed, 29 Mar 2006 08:05:05 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 29 Mar 2006     Volume: 10 Number: 9102

Today's topics:
    Re: Accesing lexical vars from XSUB (Anno Siegel)
    Re: Buffered socket I/O with sysread-style blocking? xhoster@gmail.com
    Re: Concise idiom sought Tim Kazner
    Re: Concise idiom sought (Anno Siegel)
    Re: Concise idiom sought Tim Kazner
    Re: file renamer... request feedback <tadmc@augustmail.com>
        Find duplicates in a dat file Tami@des.com
    Re: Find duplicates in a dat file (Anno Siegel)
    Re: Find duplicates in a dat file Tami@des.com
    Re: Find duplicates in a dat file <1usa@llenroc.ude.invalid>
    Re: Find duplicates in a dat file axel@white-eagle.invalid.uk
    Re: Find duplicates in a dat file Tami@des.com
        Help calling perl from gnu make on windows <Random@Task.be>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 29 Mar 2006 08:08:12 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Accesing lexical vars from XSUB
Message-Id: <48utjcFlt62hU1@news.dfncis.de>

Ferry Bolhar <bol@adv.magwien.gv.at> wrote in comp.lang.perl.misc:
> Anno Siegel:
> 
> >> Or, generally spoken, how to access the contents of a scatch pad from a
> XSUB?
> >
> > I don't know the answer, but PadWalker (on CPAN) does that (within the
> > scope of the caller).  Its code should be instructive.
> 
> Did you ever look at PadWalkers source? I did. Lots of code.

Why should I?  But yes, I did.  It's lots of code.

> I do not want re-ivent PadWalker in its entirety just to get the value of a
> single lexical variable, defined in the current scope!

You don't have to re-invent it, just understand enough of it to
duplicate what you want to do.

> So, perhaps someone can provide code to accomplish this?

Code, eh?  Good luck!

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


------------------------------

Date: 29 Mar 2006 15:46:46 GMT
From: xhoster@gmail.com
Subject: Re: Buffered socket I/O with sysread-style blocking?
Message-Id: <20060329105558.488$Ww@newsreader.com>

Uri Guttman <uri@stemsystems.com> wrote:
> >>>>> "x" == xhoster  <xhoster@gmail.com> writes:
>
>   >> the OP knows that select loops exist
>   >> but my impression is that he doesn't know how they work. in fact
>   >> they are easy to use and can work with buffered i/o as long as you
>   >> only do buffered reads using <>.
>
>   x> Right, but they are only semi-nonblocking (and the semi part of it
>   x> is not in the way the OP wants, or thinks we wants.)
>
> semi-nonblocking? huh??

Yeah.  You don't block on the <> while waiting for a message to start,
because using select you know not to call <> until at least one character
(or eof) has been sent.  But once at least one character has been sent and
you do call <>, then you do block until $/ is received.  You don't block
waiting for the start of a message, but you do block waiting for the end
of it.  The OP wants to do the opposite.

>
>   >> mixing <> and sysread is the danger, not the
>   >> blocking or select loop stuff.
>
>   x> <> isn't the only thing he uses, he also uses read, which does not
>   x> work well in a select loop.  And <> doesn't mix with O_NONBLOCK.
>
> <> doesn't mix with sysread. you can do nonblocking i/o with <> but it
> makes little sense.

The reason is makes little sense is because it doesn't work the way you
think it does.  If it did work like you say, then it would sometimes make
sense to use it that way.

> <> will read until it hits a newline, blocking or
> not. it just keeps in a read loop.

No it doesn't.  Under non-blocking, it returns with whatever chunk
of string it happens to get handed, whether it is terminated by $/
(or eof condition) or not.

> so the non-blocking shouldn't even
> affect <> (but i am not going to test it).

I will.

$ cat server.pl
#!/usr/bin/perl -wl
use strict;
use IO::Socket;
use IO::Handle;
use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK);
my $remote = IO::Socket::INET->new(
        Proto=>"tcp",LocalPort=>9001,Listen=>1,Reuse=>SO_REUSEADDR,
    ) or die $!;
while (my $connect =$remote->accept) {
  print $connect;
  my $flags = fcntl($connect, F_GETFL, 0) or die $!;
  $flags = fcntl($connect, F_SETFL, $flags | O_NONBLOCK) or die $!;
  WHILE: while (1) {
      $!=0;
      my $foo = <$connect>;
      print "Read ", length ($foo||''), " bytes with $!";
      sleep 1 unless defined $foo;
  };
};
__END__
IO::Socket::INET=GLOB(0x663570)
Read 0 bytes with Resource temporarily unavailable
Read 165456 bytes with Resource temporarily unavailable
Read 0 bytes with Resource temporarily unavailable
Read 200768 bytes with Resource temporarily unavailable
Read 0 bytes with Resource temporarily unavailable
Read 201000 bytes with Resource temporarily unavailable
Read 0 bytes with Resource temporarily unavailable
Read 201000 bytes with Resource temporarily unavailable
Read 0 bytes with Resource temporarily unavailable
Read 201000 bytes with Resource temporarily unavailable
Read 0 bytes with Resource temporarily unavailable
 ....

Driven by
perl -e 'use IO::Socket; my $s=new IO::Socket::INET("localhost:9001") or \
         die $@; print $s "foo"x1000 foreach 1..1000; print $s "\n"'

If you don't set O_NONBLOCK, then you get one read of 3_000_001 characters,
rather than all of those partial, non $/ terminated reads.


> the blocking nature of a
> socket has nothing to do with buffering or how you read it. the mixing
> of read methods (buffered <> vs unbuffered sysread) is the big no-no as
> a sysread after <> may not see any data already read by <> and which is
> sitting in the stdin buffers.

And a select after a <> may also not see any data already read by <>
which is sitting in the buffer.  Usually, this only leads to inefficiency
(Not seeing a message until another message has arrived after it, or eof)
rather than outright errors, but it can cause deadlocks.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


------------------------------

Date: Wed, 29 Mar 2006 04:54:11 -0800
From: Tim Kazner
Subject: Re: Concise idiom sought
Message-Id: <6p0l22pvsehg09h6ro3uvihtmmasvfldmg@4ax.com>

On 29 Mar 2006 07:29:50 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:

> <Tim Kazner> wrote in comp.lang.perl.misc:
>> On Mon, 27 Mar 2006 09:05:37 +0200, "Dr.Ruud" <rvtol+news@isolution.nl> wrote:
>> 
>> >Randal L. Schwartz schreef:
>> >
>> >>         defined $_ or $_ = 1 for $base_ref->{pl};
>> >
>> >Alternatively:
>> >
>> >   { local $_; defined or $_ = 1 for $v }
>> >
>> >   { local $_ = \$v; defined $$_ or $$_ = 1 }
>> 
>> 1. $$v=1 if (!defined $v=\$base_ref->{pl});
>
>What is that supposed to do?
>
>As given it produces a run-time error.  After adding parentheses for
>precedence
>
>$$v=1 if (!defined( $v=\$base_ref->{pl}));
>
>it will set $base_ref{ pl} to 1, no matter what.
>
>> 2. if (!defined $base_ref->{pl}) {
>>         $base_ref->{pl} = 1;
>>    }
>> 
>> Would seem 1. incurrs an overhead assignment
>> that 2. doesen't if $base_ref->{pl} is defined.
>
>Huh?
>
>Anno

Revised, however the conclusion remains the same:

1. $$v=1 if ($v=\$base_ref->{pl} and !defined $$v);
2. if (!defined $base_ref->{pl}) {
        $base_ref->{pl} = 1;
   }

Would seem 1. incurrs an overhead assignment and two de-references
that 2. doesen't if $base_ref->{pl} is defined.

==============================

use strict;
use warnings;

my ($base_ref,$v) = ({});

$$v=1 if ($v=\$base_ref->{pl} and !defined $$v);
print "$$v\n";
 
($base_ref,$v) = ({pl=>8});

$$v=1 if ($v=\$base_ref->{pl} and !defined $$v);
print "$$v\n";

__END__
1
8

Not really sure why this won't work:

$$v=1 if (!defined $($v=\$base_ref->{pl}));




------------------------------

Date: 29 Mar 2006 13:31:11 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Concise idiom sought
Message-Id: <48vggvFls0loU1@news.dfncis.de>

 <Tim Kazner> wrote in comp.lang.perl.misc:
> On 29 Mar 2006 07:29:50 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
> Siegel) wrote:
> > <Tim Kazner> wrote in comp.lang.perl.misc:
> >> On Mon, 27 Mar 2006 09:05:37 +0200, "Dr.Ruud"
> <rvtol+news@isolution.nl> wrote:
> >> >Randal L. Schwartz schreef:
> >> >
> >> >>         defined $_ or $_ = 1 for $base_ref->{pl};

[...]

> use strict;
> use warnings;
> 
> my ($base_ref,$v) = ({});
> 
> $$v=1 if ($v=\$base_ref->{pl} and !defined $$v);
> print "$$v\n";
>  
> ($base_ref,$v) = ({pl=>8});
> 
> $$v=1 if ($v=\$base_ref->{pl} and !defined $$v);
> print "$$v\n";
> 
> __END__
> 1
> 8

What is the advantage over

   defined or $_ = 1 for $base_ref->{pl};

Especially considering that $v is undeclared.  That would also have
to be done somewhere.

> Not really sure why this won't work:
> 
> $$v=1 if (!defined $($v=\$base_ref->{pl}));

That fails because de-referencing doesn't take an arbitrary expression.
You must give it a simple variable or a block:

    $$v=1 unless defined ${ $v=\$base_ref->{pl} };

Again, what is the possible advantage?

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


------------------------------

Date: Wed, 29 Mar 2006 07:07:26 -0800
From: Tim Kazner
Subject: Re: Concise idiom sought
Message-Id: <t17l22956lol73jdbb9otofmo8t4649gnl@4ax.com>

On 29 Mar 2006 13:31:11 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:

> <Tim Kazner> wrote in comp.lang.perl.misc:
>> On 29 Mar 2006 07:29:50 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
>> Siegel) wrote:
>> > <Tim Kazner> wrote in comp.lang.perl.misc:
>> >> On Mon, 27 Mar 2006 09:05:37 +0200, "Dr.Ruud"
>> <rvtol+news@isolution.nl> wrote:
>> >> >Randal L. Schwartz schreef:
>> >> >
>> >> >>         defined $_ or $_ = 1 for $base_ref->{pl};
>
>[...]
>
>> use strict;
>> use warnings;
>> 
>> my ($base_ref,$v) = ({});
>> 
>> $$v=1 if ($v=\$base_ref->{pl} and !defined $$v);
>> print "$$v\n";
>>  
>> ($base_ref,$v) = ({pl=>8});
>> 
>> $$v=1 if ($v=\$base_ref->{pl} and !defined $$v);
>> print "$$v\n";
>> 
>> __END__
>> 1
>> 8
>
>What is the advantage over
>
>   defined or $_ = 1 for $base_ref->{pl};
>
>Especially considering that $v is undeclared.  That would also have
>to be done somewhere.
>
Yes it might be something to benchmark.

Implicit alias for lvalue works too. $_ and $v are both asignments.
Not really sure but 'for' may have more overhead than 'if'
and aliasing may be internal shorthand so that $_ ~ $$v;

Either way, both these 

   defined or $_ = 1 for $base_ref->{pl};
   $$v=1 unless defined ${ $v=\$base_ref->{pl} };

would seem to incurr an overhead asignment that

   if (!defined $base_ref->{pl}) {
        $base_ref->{pl} = 1;
   }

doesen't, if $base_ref->{pl} is defined.



------------------------------

Date: Wed, 29 Mar 2006 09:50:27 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: file renamer... request feedback
Message-Id: <slrne2lb63.50c.tadmc@magna.augustmail.com>

TOC <noone@nowhere.com> wrote:

> I am a total newbie, so if there is something obvious, tell me... I won't 
> be offended.


> sub f


One-character subroutine names suck.

You should try to choose meaningful names.


>    my $o = $_ ;


One-character variable names suck too.

You should try to choose meaningful names.


>    y/A-Z/a-z/;


   $_ = lc $_;  # respects locales, y/// does not


>              s/(.*)/$1_/;


Tacking a character onto the end should *look like* you are
tacking a character onto the end:

   $_ .= '_';


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Wed, 29 Mar 2006 10:49:45 GMT
From: Tami@des.com
Subject: Find duplicates in a dat file
Message-Id: <tehk22tbj9d9tk78gtn41p7j62e1qcgbp8@4ax.com>

Hi

Winxp pro

I have a  cgi/perl script that stores data in a  folder called users.

It is stored like


zac                                 #user name
test@tets.com                  #email
john Smith                       #full name
23 smith street                 #address
test                                #city
essex                             #county
xx 233                             #zip
uk                                   #country
123456                            #phone
23                                   #age
                                       #blank
1                                     #id2
2                                     #id3
12321456                        #user id

What I want is a script that I can run to check inside this dat file to find  any duplicates
emails then list them.

Is there any where I can see how I would write this code please.

Or could some kind person show me how this would be done.

Thank you

Tami











------------------------------

Date: 29 Mar 2006 11:02:29 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Find duplicates in a dat file
Message-Id: <48v7q5FlqipsU2@news.dfncis.de>

 <Tami@des.com> wrote in comp.lang.perl.misc:
> Hi
> 
> Winxp pro
> 
> I have a  cgi/perl script that stores data in a  folder called users.
> 
> It is stored like
> 
> 
> zac                                 #user name
> test@tets.com                  #email
> john Smith                       #full name
> 23 smith street                 #address
> test                                #city
> essex                             #county
> xx 233                             #zip
> uk                                   #country
> 123456                            #phone
> 23                                   #age
>                                        #blank
> 1                                     #id2
> 2                                     #id3
> 12321456                        #user id
> 
> What I want is a script that I can run to check inside this dat file to
> find  any duplicates
> emails then list them.

Your example data doesn't contain any duplicates.

What is a duplicate entry?  Does the comment-like thing on the right
margin count?  Does it matter how many blanks are between the entry
proper and the comment?

> Is there any where I can see how I would write this code please.
> 
> Or could some kind person show me how this would be done.

Look up "perldoc -q duplicate".  It discusses duplicate entries in
an array, not a file, but the methods still apply.

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


------------------------------

Date: Wed, 29 Mar 2006 12:00:56 GMT
From: Tami@des.com
Subject: Re: Find duplicates in a dat file
Message-Id: <l6mk22dp7od8f2qmfnead3i1jm17473tc0@4ax.com>

Hi Thank you for getting back to me

Please see below comments

On 29 Mar 2006 11:02:29 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:

> <Tami@des.com> wrote in comp.lang.perl.misc:
>> Hi
>> 
>> Winxp pro
>> 
>> I have a  cgi/perl script that stores data in a  folder called users.
>> 
>> It is stored like
>> 
>> 
>> zac                                 #user name
>> test@tets.com                  #email
>> john Smith                       #full name
>> 23 smith street                 #address
>> test                                #city
>> essex                             #county
>> xx 233                             #zip
>> uk                                   #country
>> 123456                            #phone
>> 23                                   #age
>>                                        #blank
>> 1                                     #id2
>> 2                                     #id3
>> 12321456                        #user id
>> 
>> What I want is a script that I can run to check inside this dat file to
>> find  any duplicates
>> emails then list them.
>
>Your example data doesn't contain any duplicates.

No it will NOT show any duplicates as each dat file has its own info so it would look like

users/zac.dat  test.dat  tom.dat  etc etc  inside each one of those dat files is information
about the user as above.

So I could have zac.dat with a email as test@tets.com inside that dat file
ALSO I could have test.dat with a email as test@tets.com inside that dat file.

SO what I wanted to do is search in all the dat files for any duplicate  emails.
HTH
==========================================
>What is a duplicate entry?

as above
=========================
> Does the comment-like thing on the right margin count?

NO I only put the comment in to show what each one is
==========================================
> Does it matter how many blanks are between the entry
>proper and the comment?

As Above
======================================
>
>> Is there any where I can see how I would write this code please.
>> 
>> Or could some kind person show me how this would be done.
>
>Look up "perldoc -q duplicate".  It discusses duplicate entries in
>an array, not a file, but the methods still apply.
>
>Anno



------------------------------

Date: Wed, 29 Mar 2006 13:08:38 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Find duplicates in a dat file
Message-Id: <Xns979552F82E47Dasu1cornelledu@127.0.0.1>

Tami@des.com wrote in news:l6mk22dp7od8f2qmfnead3i1jm17473tc0@4ax.com:

> On 29 Mar 2006 11:02:29 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
> Siegel) wrote: 
> 
>> <Tami@des.com> wrote in comp.lang.perl.misc:
>>> Hi
>>> 
>>> Winxp pro
>>> 
>>> I have a  cgi/perl script that stores data in a  folder called
>>> users. 
>>> 
>>> It is stored like
>>> 
>>> 
>>> zac                                 #user name
>>> test@tets.com                  #email
>>> john Smith                       #full name
>>> 23 smith street                 #address
>>> test                                #city
>>> essex                             #county
>>> xx 233                             #zip
>>> uk                                   #country
>>> 123456                            #phone
>>> 23                                   #age
>>>                                        #blank
>>> 1                                     #id2
>>> 2                                     #id3
>>> 12321456                        #user id
>>> 
>>> What I want is a script that I can run to check inside this dat file
>>> to find  any duplicates emails then list them.
>>
>>Your example data doesn't contain any duplicates.
> 
> No it will NOT show any duplicates as each dat file has its own info
> so it would look like 
> 
> users/zac.dat  test.dat  tom.dat  etc etc  inside each one of those
> dat files is information about the user as above.
> 
> So I could have zac.dat with a email as test@tets.com inside that dat
> file ALSO I could have test.dat with a email as test@tets.com inside
> that dat file. 

So, you are using the file system as a database. That has its uses, but 
then checking constraints across entries is not straightforward as you 
are discovering.

One way to do it is to parse each file into a hash, and keep track of 
emails seen in another hash. This should scale better than the 
alternative of comparin each record to all other records.

> SO what I wanted to do is search in all the dat files for any
> duplicate  emails. HTH

You should attempt to solve the problem on your own first. Here is an 
untested implementation of my idea above:

D:\Home\asu1\UseNet\clpmisc\dat> cat bac.dat
bac
test@tets.com
john Smith
23 smith street
test
essex
xx 233
uk
123456
23

1
2
12321456


D:\Home\asu1\UseNet\clpmisc\dat> cat zac.dat
zac
test@tets.com
john Smith
23 smith street
test
essex
xx 233
uk
123456
23

1
2
12321456

D:\Home\asu1\UseNet\clpmisc\dat> cat datcmp.pl
#!/usr/bin/perl

use strict;
use warnings;

use File::Find;
use File::Spec::Functions qw( catfile );

my $dir = shift || '.';

opendir my $dir_h, $dir
    or die "Cannot open directory: '$dir': $!";

my @dat_files = grep { /\.dat$/i } readdir $dir_h;

closedir $dir_h;

my %seen_emails;

DAT_FILES: for my $dat ( @dat_files ) {
    my $fn = catfile $dir, $dat;

    my $dat_h;

    unless ( open $dat_h, '<', $fn ) {
        warn "Cannot open '$fn' for reading: $!";
        next DAT_FILES;
    }

    my $user  = <$dat_h>;
    $user =~ s/\s+$//;

    my $email = <$dat_h>;
    $email =~ s/\s+$//;

    push @{ $seen_emails{$email} }, $user;

    close $dat_h;
}

my @duplicates = grep {
    scalar @{ $seen_emails{$_} } > 1
} keys %seen_emails;

for my $dup ( @duplicates ) {
    print "$dup -> @{ $seen_emails{$dup}}\n";
}

__END__

D:\Home\asu1\UseNet\clpmisc\dat> datcmp.pl
test@tets.com -> bac zac

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html



------------------------------

Date: Wed, 29 Mar 2006 14:43:02 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: Find duplicates in a dat file
Message-Id: <W1xWf.44155$wl.29344@text.news.blueyonder.co.uk>

Tami@des.com wrote:
>>> I have a  cgi/perl script that stores data in a  folder called users.

>>> It is stored like
 
>>> zac                                 #user name
>>> test@tets.com                  #email
>>> john Smith                       #full name
>>> 23 smith street                 #address
>>> test                                #city
>>> essex                             #county
>>> xx 233                             #zip
>>> uk                                   #country
>>> 123456                            #phone
>>> 23                                   #age
>>>                                        #blank
>>> 1                                     #id2
>>> 2                                     #id3
>>> 12321456                        #user id
 
>>> What I want is a script that I can run to check inside this dat file to
>>> find  any duplicates
>>> emails then list them.

>>Your example data doesn't contain any duplicates.
 
> No it will NOT show any duplicates as each dat file has its own info so it would look like
 
> users/zac.dat  test.dat  tom.dat  etc etc  inside each one of those dat files is information
> about the user as above.
 
> So I could have zac.dat with a email as test@tets.com inside that dat file
> ALSO I could have test.dat with a email as test@tets.com inside that dat file.

If you concatenated all the files into a single file, this should work

#!/usr/bin/perl

use strict;
use warnings;

open INFILE, "<", "q1.dat" or die "q1: $!\n";

my %emails;

while (<INFILE>) {
    next unless /@/;
    chomp;
    s/^(\S+).*/$1/;
    $emails{$_}++;
}

for my $i (keys %emails) {
    if ($emails{$i} > 1) {
        print $i, "repeated $emails{$i} times\n";
    }
}
__END__

Or you more easily go for a command line option, e.g.

grep -h @ *.dat | sort | uniq -c

Axel



------------------------------

Date: Wed, 29 Mar 2006 15:32:05 GMT
From: Tami@des.com
Subject: Re: Find duplicates in a dat file
Message-Id: <sr2l22154ou04qir3t9tvkgubf50lvjv1m@4ax.com>

Hi

Thank you for getting back to me

Please see below comments



On Wed, 29 Mar 2006 14:43:02 GMT, axel@white-eagle.invalid.uk wrote:

>Tami@des.com wrote:
>>>> I have a  cgi/perl script that stores data in a  folder called users.
>
>>>> It is stored like
> 
>>>> zac                                 #user name
>>>> test@tets.com                  #email
>>>> john Smith                       #full name
>>>> 23 smith street                 #address
>>>> test                                #city
>>>> essex                             #county
>>>> xx 233                             #zip
>>>> uk                                   #country
>>>> 123456                            #phone
>>>> 23                                   #age
>>>>                                        #blank
>>>> 1                                     #id2
>>>> 2                                     #id3
>>>> 12321456                        #user id
> 
>>>> What I want is a script that I can run to check inside this dat file to
>>>> find  any duplicates
>>>> emails then list them.
>
>>>Your example data doesn't contain any duplicates.
> 
>> No it will NOT show any duplicates as each dat file has its own info so it would look like
> 
>> users/zac.dat  test.dat  tom.dat  etc etc  inside each one of those dat files is information
>> about the user as above.
> 
>> So I could have zac.dat with a email as test@tets.com inside that dat file
>> ALSO I could have test.dat with a email as test@tets.com inside that dat file.






>
>If you concatenated all the files into a single file, this should work

Do you mean that I put all the dat files in one folder?

If the above then they are all in one folder called "users".


If you mean  put all the information from all the dat files inside ONE dat file that would
be impossible, as there are loads of them.

Many thanks

Tami 



>
>#!/usr/bin/perl
>
>use strict;
>use warnings;
>
>open INFILE, "<", "q1.dat" or die "q1: $!\n";
>
>my %emails;
>
>while (<INFILE>) {
>    next unless /@/;
>    chomp;
>    s/^(\S+).*/$1/;
>    $emails{$_}++;
>}
>
>for my $i (keys %emails) {
>    if ($emails{$i} > 1) {
>        print $i, "repeated $emails{$i} times\n";
>    }
>}
>__END__
>
>Or you more easily go for a command line option, e.g.
>
>grep -h @ *.dat | sort | uniq -c
>
>Axel



------------------------------

Date: Wed, 29 Mar 2006 10:28:13 -0500
From: Random Task <Random@Task.be>
Subject: Help calling perl from gnu make on windows
Message-Id: <hIxWf.1701$u15.346687@news20.bellglobal.com>

Hi ...

I think this will take someone here 5 minutes to provide me guidance.

I am calling perl from gnu make on windows and I am having a problem 
with "arguments with spaces".

My build rule looks like this:

CommonComponentImplementation1/CommonComponentImplementation1_Build :
	echo "hey"
	$(CE_PERL) C:/Program Files/jim.pl

My error message looks like this:

"hey"
"C:\Program Files\Zeligsoft\Component Enabler\\perl\bin\perl.exe" 
C:/Program\ Files/jim.pl
Can't open perl script "C:/Program\": No such file or directory
make: *** 
[CommonComponentImplementation1/CommonComponentImplementation1_Build] 
Error 0x2


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 9102
***************************************


home help back first fref pref prev next nref lref last post