[16213] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3625 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 11 18:15:47 2000

Date: Tue, 11 Jul 2000 15:15:34 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <963353734-v9-i3625@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 11 Jul 2000     Volume: 9 Number: 3625

Today's topics:
        How do I get the contents of a directory on my system i (Rienk)
    Re: How do I get the contents of a directory on my syst <care227@attglobal.net>
    Re: How do I get the contents of a directory on my syst <bwalton@rochester.rr.com>
    Re: How do I get the contents of a directory on my syst (Tad McClellan)
    Re: How do I tell PERL to create a new directory in Win <null@null.com>
    Re: How to display the correct time from a time server  <abcd@abcd.dd>
    Re: Looking for free script (Will England)
        make test problems compiling 5.6 for Solaris 2.7 (Dave Encisco)
    Re: Mechanics of a File Upload? (Malcolm Dew-Jones)
        Method to obfuscate or disguise Perl source code? (Silicon Cowboy)
    Re: Method to obfuscate or disguise Perl source code? (brian d foy)
    Re: Method to obfuscate or disguise Perl source code? <care227@attglobal.net>
    Re: Method to obfuscate or disguise Perl source code? (Abigail)
    Re: Method to obfuscate or disguise Perl source code? (Abigail)
    Re: Method to obfuscate or disguise Perl source code? <uri@sysarch.com>
    Re: Method to obfuscate or disguise Perl source code? (Tad McClellan)
    Re: Method to obfuscate or disguise Perl source code? <care227@attglobal.net>
    Re: Method to obfuscate or disguise Perl source code? (Jerome O'Neil)
    Re: multidimensional associative arrays <phil.rennert@ioip.com>
        Need Help with array (should be easy!) <calvin@namezero.com>
    Re: Need Help with array (should be easy!) (Abigail)
    Re: Need Help with array (should be easy!) <care227@attglobal.net>
    Re: Need Help with array (should be easy!) <mjcarman@home.com>
    Re: Net::SMTP question <iltzu@sci.invalid>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 11 Jul 2000 19:37:49 GMT
From: rikrik31@hotmail.com (Rienk)
Subject: How do I get the contents of a directory on my system into an array?
Message-Id: <396d7855.5838746@news.arnhem.chello.nl>

Hello,

Ik want to make a combobox using Perl CGI with the contents of a
directory on the system that the script runs on as the possible
selections.
Can anyone help me with that?	
B.t.w.: I use CGI.pm, not Mod_Perl.

Thanks in advance for any help!

Gr. Rienk



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

Date: Tue, 11 Jul 2000 15:58:38 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: How do I get the contents of a directory on my system into an array?
Message-Id: <396B7C6E.8B0C7A36@attglobal.net>

Rienk wrote:
> 
> Hello,
> 
> Ik want to make a combobox using Perl CGI with the contents of a
> directory on the system that the script runs on as the possible
> selections.
> Can anyone help me with that?

I can, and so can many others.  But you forgot to show us the 
code you've tried to use and failed with.  (its OK if it doesn't
work, no one will poke fun at you)

Post us a snippet of your code and many will be happy to help you
make it work.  If you aren't sure where to start, check out the 
Perl documentation that comes on your system.

$ perldoc -f readdir is a good place to start.  

Also the File::Find module, if you want to do recursive reads.


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

Date: Tue, 11 Jul 2000 20:04:13 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: How do I get the contents of a directory on my system into an array?
Message-Id: <396B7DFD.65C916FA@rochester.rr.com>

Rienk wrote:
 ...
> Ik want to make a combobox using Perl CGI with the contents of a
> directory on the system that the script runs on as the possible
> selections.
> Can anyone help me with that?
> B.t.w.: I use CGI.pm, not Mod_Perl.
 ...
> Gr. Rienk

One anwser to your title question is:

    @files=<*>;

or

    @files=</path/from/root/*>;

See perldoc perlop, the section on I/O operators.

If you don't like that, look at 

    perldoc -f glob
    perldoc -f opendir
    perldoc -f readdir

I assume you can handle the rest.
-- 
Bob Walton


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

Date: Tue, 11 Jul 2000 15:14:23 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: How do I get the contents of a directory on my system into an array?
Message-Id: <slrn8mmsgf.4fa.tadmc@magna.metronet.com>

On Tue, 11 Jul 2000 19:37:49 GMT, Rienk <rikrik31@hotmail.com> wrote:

> Subject: How do I get the contents of a directory on my system into an array?


   perldoc -f opendir

   perldoc -f readdir

and maybe

   perldoc -f -X

too.


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Tue, 11 Jul 2000 13:04:58 -0700
From: "Dilbert" <null@null.com>
Subject: Re: How do I tell PERL to create a new directory in Win32?
Message-Id: <146255076@NEWS.SAIC.COM>

Thanks Lauren.

It turns out that I _DO_ have to include the UNIX-esque "0777" permission
specifications even though I'm running the script on NT.

Dilbert

"Lauren Smith" <lauren_smith13@hotmail.com> wrote in message
news:8k2s1f$ia$1@brokaw.wa.com...
>
> Dilbert <null@null.com> wrote in message news:145643484@NEWS.SAIC.COM...
> > Can anyone tell me how to get PERL for Win32 to create a new directory?
> The
> > 'mkdir()' function doesn't seem to work.  Possibly because it issues a
> UNIX
> > command?
>
> Possibly you aren't reading the error messages?
>
> #!perl -w
> mkdir "MyDir", '0777' or die "MyDir: $!";
>
> perldoc -f mkdir
>
> Lauren
>
>
>




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

Date: Tue, 11 Jul 2000 23:47:50 +0200
From: "Lou" <abcd@abcd.dd>
Subject: Re: How to display the correct time from a time server on a page?
Message-Id: <8kg4u5$act$2@sunce.iskon.hr>

"Abigail" <abigail@delanet.com> wrote in message
news:slrn8mmjv3.am3.abigail@alexandra.delanet.com...
>
> Hell, no, I ain't no hacker. I herd goats.

How you behave, that just fits you.

> Why should I have to know anything about Perl? You posted this in the
> javascript group, so Perl would be off-topic there.

I just pressed reply button, like you did. If it is off-topic why are you
answering it with stupid comments, can you just say this question is not for
this news group, or something like that instead of your unsuitable comments?

> Oh, I am very proud. I pet myself on my shoulders every day. And twice on
> Fridays.

You should, like I said, with that kind of attitude you have, people here
can really see, what kind of a person you are. Really nice, just keep on
going, your counter of indecency is growing every minute.

> Of course I know. It serve three purposes. It's a small little table. It's
> also a stove to bake eggs on. And finally, it's a device to communicate
> with space aliens.
>

Like I said your behave is really of what can people learn here, what they
should not do. Just continue with your comments and you'll have (you already
have it, silly me:) bad reputation.

You could put in your signature:
------------------------
Notorious Abigail.
------------------------
That might help you in that, that you don't have any friends. And everyone
will saying: hey look that's Notorious Abigail, cool, she is cold old lady.



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

Date: Tue, 11 Jul 2000 18:07:50 GMT
From: will@mylanders.com (Will England)
Subject: Re: Looking for free script
Message-Id: <slrn8mmom9.81n.will@mylanders.com>

On Tue, 11 Jul 2000 10:59:03 -0400, Bill Sneddon 
<sneddonb@whiteoaksemi.com> wrote:

>Okay I might get flamed but... 

Well, not by me.  I will point you to comp.lang.postscript tho . . .

>I have done some looking with no luck.

Try google and deja -- 30 seconds for your answer.

>I was looking for a perl program that strips out the PostScript
>formating chars and created a nice looking document.   Any 
>suggestion on where I might look? 

It may not be totally nice looking, but it should be readable.
See http://www.postscript.org/FAQs/language/node36.html for why.

Also lists a few scripts to look for, inlcuding ps2a, ps2ascii, 
ps2txt, ps2ascii.ps or ps2ascii.pl.

Again, search at Google.com for each or all of those scripts; you
should be able to find them in a few minutes.

Will

-- 
  "If Al Gore invented the Internet, then I invented spellcheck!"
      Dan Quayle, quoted at the National Press Club, 8/3/1999 
         pgpkey at http://will.mylanders.com/pub_pgp.asc 
  Recovery page: http://will.mylanders.com/    will@mylanders.com 


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

Date: 11 Jul 00 20:50:58 GMT
From: dencisco@eos.arc.nasa.gov (Dave Encisco)
Subject: make test problems compiling 5.6 for Solaris 2.7
Message-Id: <dencisco.963348658@eos.arc.nasa.gov>

Hi,

I'm having one of those frustrating days getting perl to compile with
minimal "dubious(es)" when I run make test. All the lib/db stuff,
lib/gdbm and lib/ndbm gives me the message: test program seems to have
generated a core.

I had previously installed db-3.1.14 and gdbm-1.8.0 and have since
reinstalled older versions, but to no avail. I've configured perl to
look in the /usr/local/include and /usr/local/lib...nota.

What obvious thing am I missing?

Thanks!
Dave

dencisco@eos.arc.nasa.gov
--
===========================================
	Dave Encisco
	dencisco@eos.arc.nasa.gov
===========================================


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

Date: 11 Jul 2000 13:48:02 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Mechanics of a File Upload?
Message-Id: <396b8802@news.victoria.tc.ca>

Jeff Boes (jboes@eoexchange.com) wrote:
: Matthew Jochum wrote:
: > 
: > Hey All,
: >     I was wondering how the file upload process works?  What protocol
: > the server uses to read the file on a remote computer.  How the bytes
: > are transfered, etc etc...


: I think it's important to note (beyond things pointed out elsewhere in
: this thread) that the browser and the web server are doing the work, not
: so much the CGI program. You can build a form like this:

: <html><head></head><body>
: <form action="/cgi-bin/nosuchscript.cgi">
: <input type="file"><input type="submit"></form>
: </body></html>

: Then load up this page, select a 20 meg file from your hard drive, and
: submit it. The browser will grind away for whatever time it takes to
: upload the file, then the server will store it in some temp directory.
: Finally, the specified program gets called. And of course in this
: example, there's no program found, so it bombs. Your program never gets
: control of the upload process until the point where the file is already
: on the server. This is important, because the second question people ask
: (after #1, "how do I do a file upload?") is usually, "How do I prevent
: the user from uploading a large file/a binary file/a file I already
: have?" And you can't, at least not from your CGI program. Oh, you can
: refuse to accept it from the server, but by the time your code is
: running, the file is already uploaded, and has eaten up whatever
: bandwidth it's going to eat, and occupies space on your server (and
: we'll assume that your server is correctly configured to reclaim this at
: some point).

This doesn't sound correct.

There are two possibilities, either file is uploaded via POST or GET.

If uploaded via POST (the normal way) then the CGI script gets control
before the POST data has been read from STDIN.  Meanwhile the network
software block, waiting for the receiving program (the CGI script) to suck
in the data. The network software on the client (i.e. the browser end)
will not be able to finish sending its data until the server unpauses, or
at least if it does send the data then the server will ignore it. 

If the data is sent via GET (which you would have to set up yourself) then
conceivably the HTTP GET line could be very big and take up lots of
virtual memory.  I rather suspect that servers have a predefined maximum
that they will accept on a single line of the protocol.  In any case the
server is not saving any kind of temporary file when this happens, though
if the entire request where to be logged then the data would go into the
log file (though again I suspect there are maximum sizes defined for the
data being logged).




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

Date: Tue, 11 Jul 2000 18:12:35 GMT
From: siliconcowboy@home.com (Silicon Cowboy)
Subject: Method to obfuscate or disguise Perl source code?
Message-Id: <slrn8mmpda.nq.siliconcowboy@erato.bigredrockeater.com>


I'm looking for a program that would obfuscate, disguise, or camouflage
Perl source code.

What I'm looking for could be a script that I can run over my Perl
source code to remove all syntactically unnecessary whitespace, strip
out comments, change function and variable names to unintelligible
names, etc.  I searched through the CPAN archives for something like
that but without success.  Has anyone written something like that
for Perl?

I also saw the bytecode compiler but it is described as experimental.
Is there a solid version yet?

And I also looked at the Perl Filter module that could be used to
self-encrypt Perl source code and decrypt it into memory when it's run.
The module uses some XS code that must be compiled for each platform
on which it is to be run.  But I'd rather have a more portable method
since I don't even have a C compiler for some platforms I want my
programs to run on (like Windows/NT).

My purpose is to protect some proprietary algorithms in the source code
of a commercial Perl program.  I realize the futility of protecting code
against reverse engineering by determined programmers, but I do want to
make at least some effort.

Thanks for any ideas.



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

Date: Tue, 11 Jul 2000 14:39:21 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Method to obfuscate or disguise Perl source code?
Message-Id: <brian-ya02408000R1107001439210001@news.panix.com>

In article <slrn8mmpda.nq.siliconcowboy@erato.bigredrockeater.com>, siliconcowboy@home.com posted:

> I'm looking for a program that would obfuscate, disguise, or camouflage
> Perl source code.

the problem is that thre are Perl beautifiers that are easy to use
and will undo all of your work to obfuscate the code.

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>


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

Date: Tue, 11 Jul 2000 14:40:32 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Method to obfuscate or disguise Perl source code?
Message-Id: <396B6A20.5F52E46@attglobal.net>

Silicon Cowboy wrote:
> 
> I'm looking for a program that would obfuscate, disguise, or camouflage
> Perl source code.

I find spilled Coca-Cola on a printout does a nice job of 
camouflage.  YMMV.
 
> What I'm looking for could be a script that I can run over my Perl
> source code to remove all syntactically unnecessary whitespace, strip
> out comments, change function and variable names to unintelligible
> names, etc.  I searched through the CPAN archives for something like
> that but without success.  Has anyone written something like that
> for Perl?

$ perldoc -q hide

> I also saw the bytecode compiler but it is described as experimental.
> Is there a solid version yet?

Still experimental last I read.  (read it in the Beta chapter for 
the 3rd edition of the Camel.)
 
> My purpose is to protect some proprietary algorithms in the source code
> of a commercial Perl program.  

Copyright or patent the idea.  (IIRC algorithms can be patented, but I 
may be wrong).  Really, even with a compiled language a determined, 
well funded attacker is hard to stop.  The only thing thats near 100%
is legal protection and the willingness to jealously guard your rights.


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

Date: 11 Jul 2000 14:44:58 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Method to obfuscate or disguise Perl source code?
Message-Id: <slrn8mmrqo.am3.abigail@alexandra.delanet.com>

Silicon Cowboy (siliconcowboy@home.com) wrote on MMDVI September MCMXCIII
in <URL:news:slrn8mmpda.nq.siliconcowboy@erato.bigredrockeater.com>:
`' 
`' I'm looking for a program that would obfuscate, disguise, or camouflage
`' Perl source code.

You could hire me.

`' What I'm looking for could be a script that I can run over my Perl
`' source code to remove all syntactically unnecessary whitespace, strip
`' out comments, change function and variable names to unintelligible
`' names, etc.  I searched through the CPAN archives for something like
`' that but without success.  Has anyone written something like that
`' for Perl?

Now, why would you?

`' I also saw the bytecode compiler but it is described as experimental.
`' Is there a solid version yet?

Have you read the FAQ?

`' And I also looked at the Perl Filter module that could be used to
`' self-encrypt Perl source code and decrypt it into memory when it's run.
`' The module uses some XS code that must be compiled for each platform
`' on which it is to be run.  But I'd rather have a more portable method
`' since I don't even have a C compiler for some platforms I want my
`' programs to run on (like Windows/NT).

Again, what is the purpose?

`' My purpose is to protect some proprietary algorithms in the source code
`' of a commercial Perl program.  I realize the futility of protecting code
`' against reverse engineering by determined programmers, but I do want to
`' make at least some effort.

Hire a lawyer. Or don't sell to crooks in the first place.



Abigail
-- 
sub J::FETCH{Just   }$_.='print+"@{[map';sub J::TIESCALAR{bless\my$J,J}
sub A::FETCH{Another}$_.='{tie my($x),$';sub A::TIESCALAR{bless\my$A,A}
sub P::FETCH{Perl   }$_.='_;$x}qw/J A P';sub P::TIESCALAR{bless\my$P,P}
sub H::FETCH{Hacker }$_.=' H/]}\n"';eval;sub H::TIESCALAR{bless\my$H,H}


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

Date: 11 Jul 2000 14:45:53 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Method to obfuscate or disguise Perl source code?
Message-Id: <slrn8mmrsf.am3.abigail@alexandra.delanet.com>

brian d foy (brian@smithrenaud.com) wrote on MMDVI September MCMXCIII in
<URL:news:brian-ya02408000R1107001439210001@news.panix.com>:
,, In article <slrn8mmpda.nq.siliconcowboy@erato.bigredrockeater.com>, siliconcowboy@home.com posted:
,, 
,, > I'm looking for a program that would obfuscate, disguise, or camouflage
,, > Perl source code.
,, 
,, the problem is that thre are Perl beautifiers that are easy to use
,, and will undo all of your work to obfuscate the code.


The beautifiers add comments and pick sensible variable names?
Now, that's what I call impressive.



Abigail
-- 
echo "==== ======= ==== ======"|perl -pes/=/J/|perl -pes/==/us/|perl -pes/=/t/\
 |perl -pes/=/A/|perl -pes/=/n/|perl -pes/=/o/|perl -pes/==/th/|perl -pes/=/e/\
 |perl -pes/=/r/|perl -pes/=/P/|perl -pes/=/e/|perl -pes/==/rl/|perl -pes/=/H/\
 |perl -pes/=/a/|perl -pes/=/c/|perl -pes/=/k/|perl -pes/==/er/|perl -pes/=/./;


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

Date: Tue, 11 Jul 2000 18:51:40 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Method to obfuscate or disguise Perl source code?
Message-Id: <x7vgyclcuc.fsf@home.sysarch.com>

>>>>> "A" == Abigail  <abigail@delanet.com> writes:

  A> brian d foy (brian@smithrenaud.com) wrote on MMDVI September MCMXCIII in

  A> ,, the problem is that thre are Perl beautifiers that are easy to use
  A> ,, and will undo all of your work to obfuscate the code.


  A> The beautifiers add comments and pick sensible variable names?
  A> Now, that's what I call impressive.

sure:

# multiply b by c giving a
	$a = $b * $c ;

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Tue, 11 Jul 2000 15:25:34 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Method to obfuscate or disguise Perl source code?
Message-Id: <slrn8mmt5e.4fa.tadmc@magna.metronet.com>

On Tue, 11 Jul 2000 14:40:32 -0400, Drew Simonis <care227@attglobal.net> wrote:
>Silicon Cowboy wrote:
>> 
>> I'm looking for a program that would obfuscate, disguise, or camouflage
>> Perl source code.


>> My purpose is to protect some proprietary algorithms in the source code
>> of a commercial Perl program.  
>
>Copyright or patent the idea.


You don't have to "copyright" it.

If you write it, it is already copyrighted by you (you don't have
to "do anything" to get it copyrighted. You may have to do something
to _keep_ the copyright though).

(of course, all of that depends on what country you live in...)


I think "license" is the term Drew was (or should have been anyway)
looking for.


Anyway, such things are discussed in:

   misc.int-property

not here.


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Tue, 11 Jul 2000 16:39:36 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Method to obfuscate or disguise Perl source code?
Message-Id: <396B8608.8AAB5ED8@attglobal.net>

Tad McClellan wrote:
> 
> You don't have to "copyright" it.
> 
> If you write it, it is already copyrighted by you (you don't have
> to "do anything" to get it copyrighted. You may have to do something
> to _keep_ the copyright though).
> 
> (of course, all of that depends on what country you live in...)
> 
> I think "license" is the term Drew was (or should have been anyway)
> looking for.
> 

Neh, I meant copyright.  You are correct, you don't _have_ to 
do anything but author the program to have copyright rights, but 
a copyright in the work of authorship is not legally defendable
in the US.  In order to secure legal protection of a copyright
(the thrust of my post) that copyright _must_ be registered.

http://www.loc.gov/copyright/circs/circ1.html#cr


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

Date: Tue, 11 Jul 2000 23:10:39 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: Method to obfuscate or disguise Perl source code?
Message-Id: <PPNa5.4798$yd.551044@news.uswest.net>

Drew Simonis <care227@attglobal.net> elucidates:
> Tad McClellan wrote:
>> 
>> You don't have to "copyright" it.
>> 
>> If you write it, it is already copyrighted by you (you don't have
>> to "do anything" to get it copyrighted. You may have to do something
>> to _keep_ the copyright though).
>> 
>> (of course, all of that depends on what country you live in...)
>> 
>> I think "license" is the term Drew was (or should have been anyway)
>> looking for.
>> 
> 
> Neh, I meant copyright.  You are correct, you don't _have_ to 
> do anything but author the program to have copyright rights, but 
> a copyright in the work of authorship is not legally defendable
> in the US.  In order to secure legal protection of a copyright
> (the thrust of my post) that copyright _must_ be registered.

The law states that registration prevents an infringer from 
claiming innocence due to ignorance in his defence.  It has
to do with your right to recover damages.  The work is always
protected.

> 
> http://www.loc.gov/copyright/circs/circ1.html#cr


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

Date: Tue, 11 Jul 2000 14:22:37 -0400
From: Philip Rennert <phil.rennert@ioip.com>
Subject: Re: multidimensional associative arrays
Message-Id: <396B65ED.C1F2E55E@ioip.com>

After

for $i (1..10)
     {
     for $j (1..10)
          {
          $a{$i}{$j}=2*$i+$j;
          }
     }

while ( ($key,$value) = each %{$a{6}}) {print $value."\n"}

as you said will print the numbers 13 .. 22 in some order, since the first index $i
is fixed at the value 6 and $j varies between 1 and 10.

How do you print the even numbers from 8 to 26, which you get if $j is fixed at 6
and $i varies between 1 and 10?
(Sorry I didn't state it more clearly.)



Abigail wrote:

> Philip Rennert (phil.rennert@ioip.com) wrote on MMDVI September MCMXCIII
> in <URL:news:396B19AD.904FEF90@ioip.com>:
> '' Okay, thanks, but how do you fix the second index ?
> '' (Say $a is two-dimensional and I want all elements of the form $a{whatever}{6
>
> You ask a question before the context. Now, I am confused, and cannot
> answer.



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

Date: Tue, 11 Jul 2000 11:46:56 -0700
From: "Calvin Crutchfield" <calvin@namezero.com>
Subject: Need Help with array (should be easy!)
Message-Id: <tTJa5.10$%c7.28282@news.pacbell.net>

Hello all, I need some assistance badly!

I have very large log files.  sometimes upwards of 200mb

I am having trouble reading a field into an array, because of memory
limitations (1gbRam) Sun Netra T1 ...  It would be 1,000,000 + items.  (I am
dealing with a large list of domain names ).  So I have to process one line
at a time.  But now I want to know how many of these 1million plus names are
unique.  If I could suck them in to an array, I could sort the array and
then find out how many are unique (but how??).  Now throw in the fact the
data is too large, what do I do?

So, how do you sort an array AND count ONLY the unique items in it?
how do you do the same if you cant get them into an array?

Please respond to the email below.

THANKS!!!!!!
_______________________
Calvin Crutchfield
Unix Systems Administrator
www.Namezero.com
590 Forest Ave.
Palo Alto, CA  94301
650.688.6483 voice
425.922.7017 cell
calvin@namezero.com





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

Date: 11 Jul 2000 14:49:08 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Need Help with array (should be easy!)
Message-Id: <slrn8mms2i.am3.abigail@alexandra.delanet.com>

Calvin Crutchfield (calvin@namezero.com) wrote on MMDVI September
MCMXCIII in <URL:news:tTJa5.10$%c7.28282@news.pacbell.net>:
`` Hello all, I need some assistance badly!
`` 
`` I have very large log files.  sometimes upwards of 200mb
`` 
`` I am having trouble reading a field into an array, because of memory
`` limitations (1gbRam) Sun Netra T1 ...  It would be 1,000,000 + items.  (I am
`` dealing with a large list of domain names ).  So I have to process one line
`` at a time.  But now I want to know how many of these 1million plus names are
`` unique.  If I could suck them in to an array, I could sort the array and
`` then find out how many are unique (but how??).  Now throw in the fact the
`` data is too large, what do I do?

For a pure Perl solution, you would not sort the array, but use the
suggested method from the FAQ. Except that you tie your hash to a
dbm file.

But if the purpose is just to get a list of unique names, you might
just ditch Perl and use sort(1).



Abigail
-- 
perl -wle '$, = " "; print grep {(1 x $_) !~ /^(11+)\1+$/} 2 .. shift'


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

Date: Tue, 11 Jul 2000 14:58:24 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Need Help with array (should be easy!)
Message-Id: <396B6E50.7231E688@attglobal.net>

Calvin Crutchfield wrote:

> So, how do you sort an array AND count ONLY the unique items in it?

http://www.perl.com/pub/doc/manual/html/pod/perlfaq4.html

Check the text under the headings:

How can I extract just the unique elements of an array? -and-
How do I sort an array by (anything)?

(I think someone hasn't read their documentation yet...)

> how do you do the same if you cant get them into an array?

Thats a problem.  Buy more memory?  

A question to the Experts who might read this: would tie() help 
here?  Maybe create a tied array? I dunno.  Never played with 
that function. 

> Please respond to the email below.

Generally thats not a good request.  You've posted in a NG, you 
need to follow your post in that NG.  I'll email this one time.


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

Date: Tue, 11 Jul 2000 14:20:58 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Need Help with array (should be easy!)
Message-Id: <396B7399.7CB34462@home.com>

Calvin Crutchfield wrote:
> 
> Hello all, I need some assistance badly!
> 
> I have very large log files.  sometimes upwards of 200mb
> [...]
> So I have to process one line at a time.

As you almost certainly should be.

> But now I want to know how many of these 1 million plus names are
> unique.  If I could suck them in to an array, I could sort the array
> and then find out how many are unique (but how??).

You didn't look at the FAQ, did you? Tsk, tsk.

perlfaq4: How can I extract just the unique elements of an array?

The answers there aren't right for you, though, because using an array
isn't really the right way to go about it. The last line from that entry
hints at what you should be using: a hash.

#!/usr/local/bin/perl -w
use strict;
my %domain_count;

while (<DATA>) {
    chomp;
    $domain_count{$_}++;
}

print "Unique domains are:\n";
foreach (sort keys %domain_count) {
    print "$_\n";
}

__DATA__
foo.com
bar.com
baz.com
bar.com

Prints:
Unique domains are:
bar.com
baz.com
foo.com

-mjc


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

Date: 11 Jul 2000 21:53:27 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Net::SMTP question
Message-Id: <963352245.24028@itz.pp.sci.fi>

In article <8kff3i$nor$1@nnrp1.deja.com>, yong321@yahoo.com wrote:
>In article <963304657.28169@itz.pp.sci.fi>,
>  Ilmari Karonen <usenet11149@itz.pp.sci.fi> wrote:
>>
>> Don't wonder, check if it does.  And then take a look at the Net::SMTP
>> docs, especially the part about "SkipBad"..
>
>I can't find the word "skip", "skipbad", "bad" by case-insensitive
>search in the perldoc. (perdoc Net::SMTP | col -b > SMTP.man; vi
>SMTP.man). You're not joking, are you? This SkipBad thing is very
>interesting to me. Thanks.

The issue was already settled in e-mail, but in case anyone else wants
to know, the solution is to get the latest version of Net::SMTP.

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method."  -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.



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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 3625
**************************************


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