[10628] in Perl-Users-Digest
Perl-Users Digest, Issue: 4220 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 14 16:07:19 1998
Date: Sat, 14 Nov 98 13:00:34 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 14 Nov 1998 Volume: 8 Number: 4220
Today's topics:
Re: [Q] how to distinguish "0" and 0? (Or: on reading a (M.J.T. Guy)
Cannot get Sprite example query to work! charlie66@my-dejanews.com
compiling modules under Win95 problems (Michael Haertfelder)
download never finishes <ours@casema.net>
Re: download never finishes <splinter@monmouth.com>
Re: download never finishes (Larry Rosler)
Re: File Locking Problems (Andrew M. Langmead)
Re: File Locking Problems <cheers69@email.msn.com>
Hard to match string <splinter@monmouth.com>
HTML editor for perl? <chsu@compaqsucks.com>
Re: HTML editor for perl? <splinter@monmouth.com>
iis 4 problem with perl .... <REMOVETHIS.statis@nettaxi.org>
Re: iis 4 problem with perl .... (Ethan H. Poole)
Re: iis 4 problem with perl .... <palincss@tidalwave.net>
need help with file manipulating <jjpark@home.com>
Re: PLEASE HELP Re: Capture of Web Form Input <rootbeer@teleport.com>
Re: Q: pod inside data structures <uri@sysarch.com>
Re: Reference returned by tie (M.J.T. Guy)
Re: SIMPLE BLOWFISH IN PERL? (brian d foy)
Re: SIMPLE BLOWFISH IN PERL? (Ethan H. Poole)
Re: Sorry Array-Hash-Problem <r28629@email.sps.mot.com>
Why is this quiting out of the subroutine early? (Jason C. Hill)
Why is this routine quiting after only one pass? (Jason C. Hill)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 14 Nov 1998 17:56:48 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: [Q] how to distinguish "0" and 0? (Or: on reading a line from a socket)
Message-Id: <72kg90$p9o$1@pegasus.csx.cam.ac.uk>
In article <y9iiugo64ni.fsf@warren.mpi-sb.mpg.de>, <fis@mpi-sb.mpg.de> wrote:
>
>is there a way in perl to test the contents of a variable $a for
>beeing 0 but not "0"?
($a & "-1") eq 0
is true if $a is 0 and false if $a is "0".
But as the other replies point out, you don't want to do that.
Mike Guy
------------------------------
Date: Sat, 14 Nov 1998 20:20:28 GMT
From: charlie66@my-dejanews.com
Subject: Cannot get Sprite example query to work!
Message-Id: <72komc$r4h$1@nnrp1.dejanews.com>
Ok I did a dejanews search on this ng and found an identical problem to mine
from a few months back. No one answered it, so I hope I fare better!
Trying to get an example from CGI Programming on thw WWW to work. All I am
trying to do is a simple select query from the database. What I should get
back is an array of strings. What I get back in reality is an array of what
seem to be packed strings. Any one had this happen?
Better details are in the previous post on this, message ID:
<6pr1sc$a1i@curly.cc.emory.edu>
--
Regards, CW.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 14 Nov 1998 17:57:00 +0200
From: haert@wharp.rhein-main.de (Michael Haertfelder)
Subject: compiling modules under Win95 problems
Message-Id: <74pUTB7FZZB@wharp.rhein-main.de>
Every time I type in the following at the command prompt (4DOS) of
Windows95:
perl Makefile.PL
I got the error:
Running 'D:\PERL\BIN\perl D:\perl\lib\ExtUtils\xsubpp temp000 2>&1' exits
with status 0 at (eval 18) line 41.
Writing Makefile for Term::Size
This message results for different modules so I assume it's a general
problem.
Yes, I installed V500402 of perl for Windows.
Yes, perl is running fine otherwise.
Yes, the module components are complete.
So what's the problem ?
Performing nmake regardless of the given error message results in a
message:
D:\PERL\BIN\perl -Id:\perl\lib -Id:\perl\lib
D:\perl\lib\ExtUtils/xsubpp -typemap D:\perl\lib\ExtUtils\typemap Size.xs
>Size.tc && D:\PERL\BIN\perl -Id:\perl\lib -Id:\perl\lib
-MExtUtils::Command -e mv Size.tc Size.c
Usage2: xsubpp [-v] [-C++] [-except] [-prototypes] [-noversioncheck] [-
nolinenumbers]
[-s pattern] [-typemap typemap]... file.xs
NMAKE : fatal error U1077: 'D:\PERL\BIN\perl.exe' : return code '0x2'
Stop.
Any help appreciated
Michael
------------- Michael Haertfelder Frankfurt/Main, Germany ----------------
------------- http://odb.rhein-main.de/people/haertfelder/ ----------------
------------------------------
Date: Sat, 14 Nov 1998 18:49:10 +0100
From: "Casema" <ours@casema.net>
Subject: download never finishes
Message-Id: <72kg79$8uh$1@sun4000.casema.net>
how come when printing HTML to a browser, using PERL
the gauge meter never stops?
I mean, "document done" is a message that seems never to appear....
print "content-type: text/html", "\n\n";
print "<HTML><BODY>\n";
print "TEST";
print "</BODY></HTML>";
above the testcode......
is there a "document-done" statement I could/should use?
thanks,
Michel
------------------------------
Date: Sat, 14 Nov 1998 15:25:48 -0500
From: "Matt" <splinter@monmouth.com>
Subject: Re: download never finishes
Message-Id: <72kp8u$bsi$1@news.monmouth.com>
its like this...
print "Content-type: text/html\n\n";
NOT this:
print "Content-type: text/html","\n\n";
-Matt
------------------------------
Date: Sat, 14 Nov 1998 12:42:59 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: download never finishes
Message-Id: <MPG.10b78b30fed5a31989908@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <72kp8u$bsi$1@news.monmouth.com> on Sat, 14 Nov 1998 15:25:48
-0500, Matt <splinter@monmouth.com> says...
> its like this...
>
> print "Content-type: text/html\n\n";
>
> NOT this:
>
> print "Content-type: text/html","\n\n";
What a useful post. :-<
These two statements have *identical* effects. Of course, the one you
prefer is three characters shorter. That makes all the difference.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 14 Nov 1998 18:51:52 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: File Locking Problems
Message-Id: <F2FDqG.C6E@world.std.com>
"Grace Carter" <cheers69@email.msn.com> who refers to himself as Gary writes:
>Also, can anyone help with my file-locking problem I've entered flock
>(FILE,2); to lock and flock (FILE,8); to unlock
>at every open and close in my scripts but it doesn't seem to have helped.
Unlocking files is not appropriate in most situations. Closing the
file automatically removes the lock. Unlocking explicitly may leave
data in perl's I/O buffers unprotected by the locking mechanism.
--
Andrew Langmead
------------------------------
Date: Sat, 14 Nov 1998 20:00:01 -0000
From: "Grace Carter" <cheers69@email.msn.com>
Subject: Re: File Locking Problems
Message-Id: <OW#gWlAE#GA.284@upnetnews02.moswest.msn.net>
>
>Unlocking files is not appropriate in most situations. Closing the
>file automatically removes the lock. Unlocking explicitly may leave
>data in perl's I/O buffers unprotected by the locking mechanism.
>
>--
>Andrew Langmead
Having scrawled through various other flock examples I was curious to know
why so few used some sort of unlock call.
I'll remove all flock (FILE, 8) calls in my scripts and see how I get on
Thanks Andrew
------------------------------
Date: Sat, 14 Nov 1998 13:45:36 -0500
From: "Matt" <splinter@monmouth.com>
Subject: Hard to match string
Message-Id: <72kjcl$8sn$1@news.monmouth.com>
Hi,
I'm having a small deficiency with a match I need to perform. First of all
its all in HTML with symbols such as %#$ or anything else that could be in
there.
I want it to take a block of HTML that I sectioned off (which I did do
successfully) and futher filter it down just to the part of it that I want.
I have the part I want starting with a <STA datehere> lots of html and
symbols and crap here <datehere END>
So I need to get that block above and get it out of HTML which could be on
either side. I've tried matches such as /<STA[.\n]*END>/i , but that
didn't work and I even tried a few on the PERL FAQ which had a LOT of *^$ in
it and it still didn't work. If anyone could help me out it would be
appreciative. Thanks.
-Matt
------------------------------
Date: Sun, 15 Nov 1998 00:35:57 +0800
From: "Clarence Hsu" <chsu@compaqsucks.com>
Subject: HTML editor for perl?
Message-Id: <364dafc4.0@news1.ibm.net>
I tried to use Frontpage to edit the HTML webpage
inside a perl file, but it won't work. Is there
a software that I can use?
Please email me: chsu@edfax.com
Thanks.
------------------------------
Date: Sat, 14 Nov 1998 13:49:39 -0500
From: "Matt" <splinter@monmouth.com>
Subject: Re: HTML editor for perl?
Message-Id: <72kjk8$90p$1@news.monmouth.com>
Are you sure you want to edit a perl file in an HTML editor?
I know you may need to make it look a certain way but if you just edit it
you can get all screwy with characters such as " and '. Its best just to
make a web page from scratch, take the source, and paste it into the perl
file and then edit out all the thigns that would make it screw up.
-Matt
------------------------------
Date: Sun, 15 Nov 1998 10:24:12 +0200
From: "George Statis" <REMOVETHIS.statis@nettaxi.org>
Subject: iis 4 problem with perl ....
Message-Id: <72kor1$6ig$1@ns1.otenet.gr>
I installed ActiveWare's perl on an NT server machine runing options pack 4
.....
I have tryed to test perl by puting the script bellow on the cgi-bin
directory of the server ...
----------------------------------------------------------------------------
------------
#! c:\perl\bin\perl
print "<meta http-equiv='Content-Type' content='text/html;
charset=windows-1253'>\n";
print "<HTML>\n";
print "<BODY>\n";
print "hello\n";
print "</BODY>\n";
print "</HTML>\n";
----------------------------------------------------------------------------
---------
the script works fine if i run it from the command prompt
but if I try to run it from the server I get the following msg ...
----------------------------------------------------------------------------
---------
CGI Error
The specified CGI application misbehaved by not returning a complete set of
HTTP headers. The headers it did return are:
hello
----------------------------------------------------------------------------
---------
what could be wrong ????????
can anybody help me with that ???
thanx in advance
statis george
------------------------------
Date: Sat, 14 Nov 1998 20:47:47 GMT
From: ehpoole@ingress.com (Ethan H. Poole)
Subject: Re: iis 4 problem with perl ....
Message-Id: <T%l32.2778$A94.7995@news13.ispnews.com>
The server told you exactly what was wrong -- you did not provide *any*
headers!
Make this the first print statement in your script:
print "Content-type: text/html\n\n";
[Posted and Emailed] In article <72kor1$6ig$1@ns1.otenet.gr>,
REMOVETHIS.statis@nettaxi.org says...
>
>I installed ActiveWare's perl on an NT server machine runing options pack 4
>.....
>
>I have tryed to test perl by puting the script bellow on the cgi-bin
>directory of the server ...
>
>----------------------------------------------------------------------------
>------------
>#! c:\perl\bin\perl
>
>print "<meta http-equiv='Content-Type' content='text/html;
>charset=windows-1253'>\n";
>print "<HTML>\n";
>print "<BODY>\n";
>print "hello\n";
>print "</BODY>\n";
>print "</HTML>\n";
>----------------------------------------------------------------------------
>---------
>
>the script works fine if i run it from the command prompt
>but if I try to run it from the server I get the following msg ...
>
>----------------------------------------------------------------------------
>---------
>CGI Error
>The specified CGI application misbehaved by not returning a complete set of
>HTTP headers. The headers it did return are:
>
>hello
>----------------------------------------------------------------------------
>---------
>
>what could be wrong ????????
>can anybody help me with that ???
>thanx in advance
>statis george
>
>
>
--
Ethan H. Poole | Website Design and Hosting,
| CGI Programming (Perl & C)..
========Personal=========== | ============================
* ehpoole @ ingress . com * | --Interact2Day--
| http://www.interact2day.com/
------------------------------
Date: Sat, 14 Nov 1998 10:51:14 -0500
From: Steve Palincsar <palincss@tidalwave.net>
Subject: Re: iis 4 problem with perl ....
Message-Id: <364DA6F2.9F46D2C8@tidalwave.net>
Well, let's go over some of the problems I see here.
> #! c:\perl\bin\perl
#! is meaningless in the WinWorld, but if you want to use a \
you have to remember it's a special character. If you want a
literal \ you need to escape it thusly: \\. For most purposes,
though, you'll want to use / as your path separator.
>
> print "<meta http-equiv='Content-Type' content='text/html;
> charset=windows-1253'>\n";
The many things I see wrong here: 1) you're doing this yourself rather
than using a module that knows how to do it correctly; 2) there should
be two newlines after the header; 3) last time I looked it was
"Content-type: text/html" for most rational servers.
Of course, you're using IIS, which doesn't behave as most servers
do -- but then, that's not a perl problem.
> print "<HTML>\n";
> print "<BODY>\n";
> print "hello\n";
> print "</BODY>\n";
> print "</HTML>\n";
Any sound reason why you aren't using a here document to print this
stuff?
>
> the script works fine if i run it from the command prompt
> but if I try to run it from the server I get the following msg ...
>
> ----------------------------------------------------------------------------
> ---------
> CGI Error
> The specified CGI application misbehaved by not returning a complete set of
> HTTP headers. The headers it did return are:
>
> hello
> ----------------------------------------------------------------------------
> ---------
>
> what could be wrong ????????
That's a clue that the problem is with the header...
And by the way, what is "alt.perl"?
------------------------------
Date: Sat, 14 Nov 1998 20:43:21 GMT
From: Justin Park <jjpark@home.com>
Subject: need help with file manipulating
Message-Id: <364DEC2F.B8D5A305@home.com>
how can i search for a specific string in a opened file and if it finds
it, replace that line with other string?
------------------------------
Date: Fri, 13 Nov 1998 21:32:47 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: PLEASE HELP Re: Capture of Web Form Input
Message-Id: <Pine.GSO.4.02A.9811131330420.5955-100000@user2.teleport.com>
On Fri, 13 Nov 1998, Richard J Kucera wrote:
> PLEASE
Well, I wasn't going to answer you, but since you quoted your entire
article, added the word PLEASE in all caps, and reposted it, I guess I
will.
> Subject : PLEASE HELP Re: Capture of Web Form Input
Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.
http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post
> > I don't care what language it's in mod_perl or Perl CGI or servlet...has
> > anyone written
> > anything to do it?
If you're wishing merely to _find_ (as opposed to write) programs, these
newsgroups may not be the best resource for you. There are many freeware
and shareware archives which you can find by searching Yahoo or a similar
service. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 14 Nov 1998 02:46:17 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Q: pod inside data structures
Message-Id: <x7af1u7m46.fsf@sysarch.com>
>>>>> "Z" == Zenin <zenin@bawdycaste.org> writes:
Z> Uri Guttman <uri@fastengines.com> wrote:
Z> : i want to document my data table of tests in pod since it will describe
Z> : the tests that can be performed. it would be nice to have each test with
Z> : its own pod next to it. the table is just a hash of hashes but i want a
Z> : pod paragraph and head2 before each top level hash.
Z> I often do something like this:
Z> my %hash;
Z> =head2 foo
Z> Some comments about 'foo'
Z> =cut
Z> $hash{foo} = {
Z> this => 'that',
Z> };
Z> etc..
a decent workaround and i will probably use it unless something better
comes along. but it is not a proper answer to why it fails. i was
drinking with randal tonight and he says it has to do with the parser
expecting an expression token next.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: 14 Nov 1998 17:11:52 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Reference returned by tie
Message-Id: <72kdko$kqs$1@pegasus.csx.cam.ac.uk>
Jerome O'Neil <jeromeo@atrieva.com> wrote:
>I am curious about the reference returned by 'tie.' The docs state that
>'...the tie function returns a reference to the object.' But I am not
>groking what object the reference points at. Is it a reference to the
>tied data, or a 'tied object' that is something else?
The object is whatever is returned by the TIESCALAR / TIEARRAY / TIEHASH
method of the class being tied to.
The first paragraph of `perldoc -f tie' explains this:
=item tie VARIABLE,CLASSNAME,LIST
This function binds a variable to a package class that will provide the
implementation for the variable. VARIABLE is the name of the variable
to be enchanted. CLASSNAME is the name of a class implementing objects
of correct type. Any additional arguments are passed to the "C<new()>"
method of the class (meaning C<TIESCALAR>, C<TIEARRAY>, or C<TIEHASH>).
Typically these are arguments such as might be passed to the C<dbm_open()>
function of C. The object returned by the "C<new()>" method is also
returned by the C<tie()> function, which would be useful if you want to
access other methods in CLASSNAME.
[ That first line is rather sloppily worded - I would have written
it as "... binds a variable to a CLASSNAME object that will ..."
Mike Guy
------------------------------
Date: Sat, 14 Nov 1998 13:05:01 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: SIMPLE BLOWFISH IN PERL?
Message-Id: <comdog-ya02408000R1411981305010001@news.panix.com>
In article <364d9a87.2994995@nntp.best.com>, fantastic2@hotmail.com (Alex M) posted:
> I am having an argument with someone I work with about implementing an
> 8-bit Blowfish decryption scheme in PERL.
>
> He says that you have to download and use a module like cryptix and I
> say that you could write the decryption using basic PERL commands.
at some point you can write anything you want in Perl.
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Sat, 14 Nov 1998 20:03:25 GMT
From: ehpoole@ingress.com (Ethan H. Poole)
Subject: Re: SIMPLE BLOWFISH IN PERL?
Message-Id: <hml32.1417$Y77.9420@news12.ispnews.com>
[Posted and Emailed] In article <364d9a87.2994995@nntp.best.com>,
fantastic2@hotmail.com says...
>
>I am having an argument with someone I work with about implementing an
>8-bit Blowfish decryption scheme in PERL.
>
>He says that you have to download and use a module like cryptix and I
>say that you could write the decryption using basic PERL commands.
>
>Has anyone come up with a single PERL script that will decrypt data
>encrypted with Blowfish? I checked CPAN and couldn't find it, but
>maybe someone has.
>
>I hate to be wrong! You can respond here or to me directly at
>fantastic2@hotmail.com.
Well, I haven't tried adapting Blowfish per se. But I have converted several
other such algorithms into pure Perl. I can see no reason why Blowfish could
not be similarly adapted.
Pure Perl does have its drawbacks, however, namely that it will always be
much slower than a well optimized and compiled C implementation. But it is
usually more than adequate for encrypting/decrypting relatively small strings
on the fly.
--
Ethan H. Poole | Website Design and Hosting,
| CGI Programming (Perl & C)..
========Personal=========== | ============================
* ehpoole @ ingress . com * | --Interact2Day--
| http://www.interact2day.com/
------------------------------
Date: Sat, 14 Nov 1998 10:24:18 -0500
From: Tk Soh <r28629@email.sps.mot.com>
To: nomam@my-dejanews.com
Subject: Re: Sorry Array-Hash-Problem
Message-Id: <364DA096.713452D0@email.sps.mot.com>
[posted to c.l.p.m and copy emailed]
nomam@my-dejanews.com wrote:
>
> In article <alecler-0911981406160001@dialup-695.hip.cam.org>,
> alecler@cam.org (Andre L.) wrote:
> > In article <727646$ece$1@nnrp1.dejanews.com>, nomam@my-dejanews.com wrote:
> >
> > [...]
> > > %element = (
> > > 'name' = $name,
> > > 'size' = $size
> > > );
> > [...]
> >
> > You meant to use => instead of = here.
> >
> > HTH,
> > Andre
>
> Sorry for this mistype. Here's the whole, hopefully correct file:
>
> #!/local/bin/perl5 -w
> $count =0;
> $startdir="/home/testuser/";
> $fname;
>
> @array;
> opendir(DH,$startdir) || die("Kann $verzeichnissname nicht oeffnen!");
Hmm, always check return value, good boy.
> while (defined($name = readdir(DH))) {
> if ($name =~ /[^.]/){
did you mean !/^\./ ?
> $count++;
what is $count doing here??
> push(@inhalt, $name);
> }
> }
To do the while{} loop with one line (assuming your original regex):
@inhalt = grep /[^.]/, readdir(DH);
> closedir DH;
> $count=1;
> foreach $name (@inhalt) {
> $fname = $name;
what's $fname doing here??
> %eintrag = (
> 'name'=>$name,
> 'size' => $count,
lhs of => operator don't need quotes, so you only need to say
size => $count, ...
> );
> print "$eintrag{'name'}:$eintrag{'size'}";
> push (@array, \%Eintrag);
> ++$count;
size is $count??
> }
To do the foreach{} loop with one line:
@array = map { { name=>$_, size=>$count++} } @inhalt;
> print "\n\n";
> foreach $fname (@array) {
> print"$fname->{'name'} : $fname->{'count'}";
quotes are also not needed inside {}'s here.
> }
Time to think in Perl ;)
-tk
------------------------------
Date: Fri, 13 Nov 1998 19:59:02 GMT
From: jhill22@csc.com (Jason C. Hill)
Subject: Why is this quiting out of the subroutine early?
Message-Id: <364c8f36.175428793@news.csc.com>
Ok, I think I'm braindead.
What I'm doing is calling a routine that reads through a list of
files. Those files are then parsed and what not for seperate reasons.
Then, the file is read and the element I'm finding in this file is
pushed into an array.
This array is then searched and duplicates are taken out and put into
a master array.
This whole thing needs to go through anywhere between 1 and 365
different files, which is deteremined by @needed_files, which in the
instance that I'm having problems with = 30 (and it doesn't work for
an arbitrary number I've thrown in there as well, where $i < 10).
and sub read_file is just called out in the main program, as
&read_file
The only subroutine called from within another subroutine is
&compare_pop_users inside sub read_file
This is the code:
sub read_file {
$period_count = 0;
for ($i = 0; $i < @needed_files; $i++) {
@pop_user = ("");
$current_file = join '', $logdir, @needed_files[$i];
($filedate, $filename) = split /\./, @needed_files[$i];
$gunzip_file = join '.', $filedate, $filename;
$gunzip_file_path = join '', $logdir, $gunzip_file;
system($gunzip, $current_file);
open(THEFILE, $gunzip_file_path);
while (<THEFILE>) {
if(/Stats:/) {
($a1, $a2, $a3, $a4, $a5, $a6, $pop_user) = split / /;
push @pop_user, $pop_user;
} #end if
} #end while
close THEFILE;
system ($gzip, $gunzip_file_path);
&compare_pop_users;
} #end for
} #end sub read_file
Simple compare and throwaway if already there type search. If you
have a better search (read quicker) please, let me know. The array of
words in this array though isn't so big as to need to worry that the
search won't finish in the next 20 years.
sub compare_pop_users {
$count_var = 0;
for ($i = 0; $i < @pop_user; $i++) {
for ($j = 0; $j < @master_list; $j++) {
if (@master_list[$j] eq @pop_user[$i]) {
$count_var = 1;
} #end if
} #end inner for
if ($count_var == 0) {
push @master_list, @pop_user[$i];
} else {
$count_var = 0;
} #end if
} #end outter for
} #end sub compare_pop_users
As you can see, read_file calls &compare_pop_users;
However, I don't understand why after &compare_pop_users; the program
just quits. I know that the amount of files in @needed_files is
there, I did some print statements to ensure everything was where it's
supposed to be (I've since taken them out to help reduce the size of
the post).
I don't have to worry about returning anything because @master_list
stays as a global array and doesn't get deleted or written over.
Thanks,
-Jason
------------------------------
Date: Fri, 13 Nov 1998 20:01:03 GMT
From: jhill22@csc.com (Jason C. Hill)
Subject: Why is this routine quiting after only one pass?
Message-Id: <364c83c4.172498880@news.csc.com>
Ok, I think I'm braindead.
What I'm doing is calling a routine that reads through a list of
files. Those files are then parsed and what not for seperate reasons.
Then, the file is read and the element I'm finding in this file is
pushed into an array.
This array is then searched and duplicates are taken out and put into
a master array.
This whole thing needs to go through anywhere between 1 and 365
different files, which is deteremined by @needed_files, which in the
instance that I'm having problems with = 30 (and it doesn't work for
an arbitrary number I've thrown in there as well, where $i < 10).
and sub read_file is just called out in the main program, as
&read_file
The only subroutine called from within another subroutine is
&compare_pop_users
This is the code:
sub read_file {
$period_count = 0;
for ($i = 0; $i < @needed_files; $i++) {
@pop_user = ("");
$current_file = join '', $logdir, @needed_files[$i];
($filedate, $filename) = split /\./, @needed_files[$i];
$gunzip_file = join '.', $filedate, $filename;
$gunzip_file_path = join '', $logdir, $gunzip_file;
system($gunzip, $current_file);
open(THEFILE, $gunzip_file_path);
while (<THEFILE>) {
if(/Stats:/) {
($a1, $a2, $a3, $a4, $a5, $a6, $pop_user) = split / /;
push @pop_user, $pop_user;
} #end if
} #end while
close THEFILE;
system ($gzip, $gunzip_file_path);
&compare_pop_users;
} #end for
} #end sub read_file
Simple compare and throwaway if already there type search. If you
have a better search (read quicker) please, let me know. The array of
words in this array though isn't so big as to need to worry that the
search won't finish in the next 20 years.
sub compare_pop_users {
$count_var = 0;
for ($i = 0; $i < @pop_user; $i++) {
for ($j = 0; $j < @master_list; $j++) {
if (@master_list[$j] eq @pop_user[$i]) {
$count_var = 1;
} #end if
} #end inner for
if ($count_var == 0) {
push @master_list, @pop_user[$i];
} else {
$count_var = 0;
} #end if
} #end outter for
} #end sub compare_pop_users
As you can see, read_file calls &compare_pop_users;
However, I don't understand why after &compare_pop_users; the program
just quits. I know that the amount of files in @needed_files is
there, I did some print statements to ensure everything was where it's
supposed to be (I've since taken them out to help reduce the size of
the post).
I don't have to worry about returning anything because @master_list
stays as a global array and doesn't get deleted or written over.
Thanks,
-Jason
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 4220
**************************************