[10367] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3960 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 13 09:07:21 1998

Date: Tue, 13 Oct 98 06:00:20 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 13 Oct 1998     Volume: 8 Number: 3960

Today's topics:
        [Perl] How to find the Perl FAQ <rootbeer&pfaq*finding*@redcat.com>
        ActiveState Perl evaluation...questions <smithr@lexma.meitech.com>
    Re: Are there any "perl.newbie" group or forum? <ckc@dmi.dk>
    Re: Checking file size and date in Perl Win32 <jimbo@soundimages.co.uk>
    Re: comp.lang.perl.win32?? (Paul Murray)
        Critique my Perl/CGI tutorial? <jbc@west.net>
    Re: Differentiating between STDOUT and STDERR vwstranathan@mailexcite.com
        email with windows 98 perl script? (Hawkwynd)
        I think its a greediness issue <hamptonk@bible.org>
    Re: I think its a greediness issue (Dermot McKay)
    Re: Max lines in an Array? <tobez@plab.ku.dk>
    Re: Max lines in an Array? <jimbo@soundimages.co.uk>
        More Questions on Command Capture using Perl <wkchiu@yahoo.com>
        need help with an interactive gannt chart <webmaster@NOSPAM.web-design.org.uk>
        Perl Cookbook - is this the best perl book? lqyrms@nottingham.ac.uk
    Re: Perl Cookbook - is this the best perl book? dave@mag-sol.com
    Re: Problems Using a Compare Subroutine with Sort (M.J.T. Guy)
    Re: prograMing: CompleteIndexSet <xah@best.com>
    Re: Return Code paul@miraclefish.com
        TAB completion - how? <eedalf@eed.ericsson.se>
        testing (Hawkwynd)
        Using perldoc -m Module_name <smithr@lexma.meitech.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Tue, 13 Oct 1998 10:24:01 GMT
From: Tom Phoenix <rootbeer&pfaq*finding*@redcat.com>
Subject: [Perl] How to find the Perl FAQ
Message-Id: <pfaqmessage908274241.9678@news.teleport.com>

Archive-name: perl-faq/finding-perl-faq
Posting-Frequency: weekly
Last-modified: 10 Sep 1998

[ That "Last-modified:" date above refers to this document, not to the
Perl FAQ itself! The last major update of the Perl FAQ was in Summer of
1998; of course, ongoing updates are made as needed. ]

For most people, this URL should be all you need in order to find Perl's
Frequently Asked Questions (and answers).

    http://cpan.perl.org/doc/FAQs/

Please look over (but never overlook!) the FAQ and related docs before
posting anything to the comp.lang.perl.* family of newsgroups.

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

Beginning with Perl version 5.004, the Perl distribution itself includes
the Perl FAQ. If everything is pro-Perl-y installed on your system, the
FAQ will be stored alongside the rest of Perl's documentation, and one
of these commands (or your local equivalents) should let you read the FAQ.

    perldoc perlfaq
    man perlfaq

If a recent version of Perl is not properly installed on your system,
you should ask your system administrator or local expert to help. If you
find that a recent Perl distribution is lacking the FAQ or other important
documentation, be sure to complain to that distribution's author.

If you have a web connection, the first and foremost source for all things
Perl, including the FAQ, is the Comprehensive Perl Archive Network (CPAN).
CPAN also includes the Perl source code, pre-compiled binaries for many
platforms, and a large collection of freely usable modules, among its
560_986_526 bytes (give or take a little) of super-cool (give or take
a little) Perl resources.

    http://cpan.perl.org/
    http://www.perl.com/CPAN/
    http://cpan.perl.org/doc/FAQs/FAQ/html/
    http://www.perl.com/CPAN/doc/FAQs/FAQ/html/

You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
selected FTP sites is especially good for you, a full list of CPAN sites
is in the SITES file within CPAN.)

    California     ftp://ftp.cdrom.com/pub/perl/CPAN/
    Texas          ftp://ftp.metronet.com/pub/perl/
    South Africa   ftp://ftp.is.co.za/programming/perl/CPAN/
    Japan          ftp://ftp.dti.ad.jp/pub/lang/CPAN/
    Australia      ftp://cpan.topend.com.au/pub/CPAN/
    Netherlands    ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
    Switzerland    ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
    Chile          ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/

If you have no connection to the Internet at all (so sad!) you may wish
to purchase one of the commercial Perl distributions on CD-Rom or other
media. Your local bookstore should be able to help you to find one.
Another possibility is to use one of the FTP-via-email services; for
more information on doing that, send mail to <mail-server@rtfm.mit.edu>
(not to me!) with these lines in the body of the message, flush left:

    setdir usenet-by-group/news.announce.newusers
    send Anonymous_FTP:_Frequently_Asked_Questions_(FAQ)_List

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

Comments and suggestions on the contents of this document
are always welcome. Please send them to the author at
<pfaq&finding*comments*@redcat.com>. Of course, comments on
the docs and FAQs mentioned here should go to their respective
maintainers.

Have fun with Perl!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/


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

Date: Tue, 13 Oct 1998 08:01:20 -0400
From: "Ray Smith" <smithr@lexma.meitech.com>
Subject: ActiveState Perl evaluation...questions
Message-Id: <6vvfc0$3dd$1@client3.news.psi.net>

I've been trying to use ActiveState's Perl (build 502).  A few problems have
stopped me cold.  I'm hoping this forum might propose some answers.
1. In attempting to run Perl code which correctly works under Gurusamy
Sarathy's binary distribution Perl, the following occurs:
Note the example code uses Tk and I have installed Tk.
S:/R11/SDFREV/TESTDEV[4204] sdflog -bt01.sfl -e
 ...
Goto undefined subroutine &Tk::Entry::insert at
d:\ap502\site\5.00502\lib/Tk/Widget.pm line 318.
I can't see where the problem lies.
 ...Looking at the source code, I see nothing which references "insert":
S:/R11/SDFREV/TESTDEV[4205]         head -320
d:/ap502/site/5.00502/lib/tk/widget.pm|tail
         require "Tk/$method.pm";
        }
      }
    }
  }
$@ = $save;
$DB::sub = $what; # Tell debugger what is going on...
goto &$what;
}
I may be dense, but I don't quite see where member references such as ...
d:/ap502/site/5.00502/lib/Tk/Entry.pm: $w->insert("insert",$s);
d:/ap502/site/5.00502/lib/Tk/Entry.pm: $w->insert('insert',$new);
2. Debugging... When I try to use the debugger (via -d switch) to debug the
above problem.
a. I get a deluge of "Use of uninitialized value at d:\pasdebug\PerlDB.pl
line 644." messages
b. then I get a message saying "No License Key was found"
c. When I continue the debugger exits upon the "Goto undefined subroutine"
error.
Is there a way to set breakpoints in a named module's member function?
Single stepping from the main would take just too long.
Does the debugger work properly for evaluation without a license key?
Thanks for your attention and help.





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

Date: Tue, 13 Oct 1998 11:51:19 +0100
From: Casper Kvan Clausen <ckc@dmi.dk>
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <Pine.GSO.3.92.981013114406.12706g-100000@edb>

On 13 Oct 1998, Mark-Jason Dominus wrote:

> In article <ylww658eup.fsf@windlord.stanford.edu>,
> Russ Allbery  <rra@stanford.edu> wrote:
> >Perl isn't that good of a language to learn how to program in
> >(yes, I know some people with strong qualifications disagree with me on
> >that score...).
>
> Really?  Who disagrees?
>
> I ask because I've never actually seen anyone express that opinion,
> and I've often wanted to try it and see what the result was.

You can do a search for "learning programming" on DN, with the author
field set to ken@forum.swarthmore.edu, who started a thread on this in
January.

To sum up, my personal feeling is that Perl is as good a language as any
to learn first. Using -w and strict, it really isn't ill-behaved at all.
That said, I kind of like the idea of starting off people with a
functional language. ML, for instance, is very clear and suitable for
learning programming.

Kvan.

-------Casper Kvan Clausen------ | 'I haven't seen an Englishman take a
----------<ckc@dmi.dk>---------- |  blow like that since Hugh Grant!
           Lokal  544            |
I do not speak for DMI, just me. |        - Football announcer.



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

Date: 13 Oct 1998 13:29:34 +0100
From: Jim Brewer <jimbo@soundimages.co.uk>
Subject: Re: Checking file size and date in Perl Win32
Message-Id: <upvbwsl01.fsf@jimbosntserver.soundimages.co.uk>

lr@hpl.hp.com (Larry Rosler) writes:

> 
> [Posted to comp.lang.perl.misc and copy mailed.]
> 
> In article <3622C31F.3938A7E5@ix.netcom.com> on Mon, 12 Oct 1998 23:04:00 
> -0400, Lyubov Ignatovsky <mikei@ix.netcom.com> says...
> > On Win32 use modification time for the file date, the others (access, creation)
> > don't work.
> > Lyubov
> 
> "Wouldn't It Be Nice If" people would check their assertions, before 
> posting them for thousands of people to be misled by.  All it takes to 
> find out what works is this:
> 
> #!/usr/local/bin/perl -w
> print -A $0, ' ', -C $0, ' ', -M $0, "\n";
> __END__
> 
> And guess what -- it all works!  And even better than on Unix, because 
> the -C gives the creation date as advertised, not the inode-change date.  
> (No inodes, you know.)

Well, somewhat misleading as well. These times are relative to when
your script began execution, not the dates the file system maintains
for these values. You would have to calculate the system dates from
the times returned by -x file tests above. They are not quite ready
for consumption in their raw form. Unless one only begins to live
while ones script is running. :)
-- 
Jim Brewer
e-mailed courtesy copies are unappreciated, please refrain.


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

Date: 13 Oct 1998 09:02:43 GMT
From: murray-paul@usa.net (Paul Murray)
Subject: Re: comp.lang.perl.win32??
Message-Id: <slrn7265pi.po8.murray-paul@unix2.netaxs.com>

On 12 Oct 1998 21:45:27 GMT, Craig Berry <cberry@cinenet.net> wrote:
>Paul Murray (murray-paul@usa.net) wrote:
>: On 6 Oct 1998 23:24:32 GMT, Craig Berry <cberry@cinenet.net> wrote:
>: >thom_co@my-dejanews.com wrote:
>: >: There are several perl issues that would be of interest only to those
>: >: doing win32 perl programming and not to the rest of the perl community.
>: >Examples?  
>: o Using Win32 GUI modules, Win32 Registry modules, umm most things
>: called Win32:: :)
>Sounds more like comp.lang.perl.modules.win32 to me.
>: o Connecting to Access databases/Excell spreadsheets/etc...
>Ditto.

Hmm, good point, maybe that would be a better suggestion.

>: o Peculiarities of perl under win32 (or win32 under perl, depending on
>: your perspective)
>This would be topical, but seems a limited area of conversation.  The
>number of non-module-related peculiarities is small.
>: o Differences between available ports, utilities only available under
>: Win32, such as perl2exe.
>Again, topical but I can't see their being a lot of traffic on this (based
>in part on how little occurs currently in clpm).

They could probably live alongside the module posts in modules.win32
if need be.

>: >And why win32 as opposed to any other particular architecture or OS? 
>: o Most unices can be considered essentially homogeneous, Win32 is a
>: very different environment. This would also apply to Macs, but...
>But?  Please, extend the thought.  I'm interested in how this case
>differs.

Sorry, the but... extended on to the next point ...

>: o Userbase. There are a lot of Win32 perl users out there, more than
>: any other non-unix port.

ie. there are not enough MacPerl users out there to warrant splitting
them out of clp.misc.

>Yes, but I'm really not sure that they have needs differing that strongly
>from the Unix-or-other-OS Perlers.
>
>: o Cluelessness. It seems fair to say that the average Win32 perl
>: programmer is less experienced than the average unix perl programmer,
>: thus the level of questions asked is lower.
>But this 'justification' fails for the same reason the frequently
>suggested clp.newbies is a bad idea; the worst possible venue for a newbie
>to ask a question is in a room full of newbies with no experts present.
>Bad advice would be endlessly recycled.

True, this wasn't a good point to make.

>: Currently this causes...
>: o Attitude problem of current newsgroup towards Win32, probably caused 
>: by abovementioned cluelessness getting all Win32 programmers and 
>: questions tarred with the same brush.  Questions tend to get blown off 
>: with 'install a real OS' type 'help'
>I really don't see that much OS prejudice in clpm (with a few loud-mouthed
>exceptions).

I guess it depends on individual perceptions. (Did you see the example
I gave at the end of the post). I certainly perceive clp.misc as being
hostile to win32-related questions.

-Paul Murray


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

Date: Tue, 13 Oct 1998 04:12:56 -0700
From: John Callender <jbc@west.net>
Subject: Critique my Perl/CGI tutorial?
Message-Id: <362335B8.4B8136A2@west.net>

Seeking to light a candle rather than curse the darkness, I've put
together a no-prior-knowledge-assumed Web tutorial for newbies wanting
to use Perl for CGI purposes. Realizing that there are those who will
argue that it is wrong to even cast such pearls before such swine, and
others who will flame me reflexively (or automatically kill me) for
posting to c.l.p.m. with "CGI" in the subject, I wanted to post here to
see if one or more of you experts would be willing to give a critique of
the tutorial before I announce it more widely (e.g., in c.i.w.a.cgi).

You're welcome to shoot holes in everything from overall approach down
to punctuation, but in particular I was hoping for an informed review of
the two main scripts included in the tutorial: a form-to-email gateway
and a guestbook script.

See:

http://www.lies.com/begperl/

Thanks.

--
John Callender
jbc@west.net
http://www.west.net/~jbc/


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

Date: Tue, 13 Oct 1998 11:51:33 GMT
From: vwstranathan@mailexcite.com
Subject: Re: Differentiating between STDOUT and STDERR
Message-Id: <6vves6$d57$1@nnrp1.dejanews.com>

Sorry.  What I need to be able to do though is this.

print NEWSOCKET `ls -la /usr`;
print NEWSOCKET `ls -la /foo`;

And have the first line prepend each line with "STDOUT:  ", and the second
(assuming /foo doesn't exist) prepend each line with "STDERR:  ".

I have both STDOUT and STDERR going to the NEWSOCKET handle, it's just that I
need to be able to let the client application know which came from where.

Thanks again,
Will Stranathan

In article <6vu4kn$3ma@bgtnsc01.worldnet.att.net>,
  "Rath" <r.r@att.net> wrote:
> vwstranathan@mailexcite.com wrote in message
> <6vtcpg$k0i$1@nnrp1.dejanews.com>...
> >This might take a while to explain....
> >
> >I have a socket application that executes commands, and sends the resulting
> >text back to the client.  What I would like to do is trap messages from
> STDOUT
> >on the command, and send those back to the client in the form:
> >
> >  print CLIENT "stdout:  $result";
> >
> >and trap STDERR messages and send those back as:
> >
> >  print CLIENT "stderr:  $result";
> >
> >I've tried using formats, you name it, but to no avail.
> >
> >Is there any way to do this?  I have STDOUT and STDERR going back to the
> same
> >CLIENT connection, but can't seem to find a way to let the client know
> which
> >was lines came from STDOUT and which came from STDERR.
> >
> >I appreciate any help!
> >
> >Thanks!
> >Will Stranathan
> >wstranathan@kltymail.com
> >
> >-----------== Posted via Deja News, The Discussion Network ==----------
> >http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own
>
> This should help you....
>
> #--- Perl Example to redirect STDOUT & STDERR ----
>
> open (STDOUT, ">> std.out") or die "ERROR Redirecting STDOUT";
> open (STDERR, ">> std.err") or die "ERROR Redirecting STDERR";
>
> select (STDOUT); $| = 1;   # Set Unbuffered
> select (STDERR); $| = 1;   # Set Unbuffered
>
> print STDOUT "STDOUT:::   Line 1\n";
> print STDERR "STDERR:::   Line 1\n";
>
> print STDOUT "STDOUT:::   Line 2\n";
> print STDERR "STDERR:::   Line 2\n";
>
> close STDOUT;
> close STDERR;
> #---- Perl End -----
>
> # Run this program
> $ perl test.pl
>
> YOu will see that, program creates two files "std.out" and "std.err".
>
> Rath
> r.r@att.net
>
>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 13 Oct 1998 10:51:05 GMT
From: hawkwynd@adelphia.net (Hawkwynd)
Subject: email with windows 98 perl script?
Message-Id: <36233031.2527991@nntp.adelphia.net>

So far, all the email scripts for web servers have been for Unix and
NT. Is it possible to do this on a Windows 98 Web server? 

Thanks in advance,
Scott


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

Date: Tue, 13 Oct 1998 10:55:03 GMT
From: Hampton Keathley <hamptonk@bible.org>
Subject: I think its a greediness issue
Message-Id: <3623319B.8FE78143@bible.org>

Greetings,

I'm working on cleaning up a few thousand theological journal articles
in SGML. 

I have to get all the footnote links out from between the foreign
language tags. 

This: <grc>greek words<info "n=12"> more greek</grc> 

must be changed to this:

<grc>greek words more greek</grc><info "n=12">

Here's my code:

while  (<INFILE>){
$line = $_;
$line =~ s/(\<grc\>)(.*?)(\<info.*?\>)(.*?)(\<\/grc\>)/$1$2$4$5$3/g;
	print OUTFILE $line;
}



The problem is that sometimes the search matches on the first <grc> and
then a second </grc> tag and takes the <info> tag and puts it in the
wrong place.

How can I ensure that it always matches the first </grc> after a <grc>?

I've copied the input and output line at the end of the message so you
can see the actual text I'm working with.


Thanks,

Hampton

(Ignore the line breaks. This is one line)

Notice how it took the <info t="g88b111" n=11> which was fine where it
was and moved it outside the second </grc> tag leaving the <info
t="g88b112" n=12> still inside the second </grc>. Now footnote #11
follows #12.

INPUT
<p type=bodyblock>desires these believers not to be ignorant
&ld;regarding those who have fallen asleep,&rd; <grc>periV tw'n
kekoimhmevnwn</grc>.<info t="g88b111" n=11> From the use of
<grc>periv<info t="g88b112" n=12></grc><grc> following ajgnoei'n</grc>,
it is evident,that the problem these believers faced centered on the
fortune of the faithful departed (<grc>tw'n kekoimhmevnwn</grc>).<info
t="g88b113" n=13> Thus it is likely that the cause of their sorrow was
not disappointment over the nonarrival of the Parousia, as Best
suggests,<info t="g88b114" n=14> but rather anxiety over the issue of
whether the Christian dead would suffer a disadvantage at the
Parousia.<info t="g88b115" n=15> The question still remains why Paul


OUTPUT
<p type=bodyblock>desires these believers not to be ignorant
&ld;regarding those who have fallen asleep,&rd; <grc>periV tw'n
kekoimhmevnwn</grc>. From the use of <grc>periv<info t="g88b112"
n=12></grc><info t="g88b111" n=11><grc> following ajgnoei'n</grc>, it is
evident,that the problem these believers faced centered on the fortune
of the faithful departed (<grc>tw'n kekoimhmevnwn</grc>).<info
t="g88b113" n=13> Thus it is likely that the cause of their sorrow was
not disappointment over the nonarrival of the Parousia, as Best
suggests,<info t="g88b114" n=14> but rather anxiety over the issue of
whether the Christian dead would suffer a disadvantage at the
Parousia.<info t="g88b115" n=15> The question still remains why Paul


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

Date: Tue, 13 Oct 1998 11:31:19 GMT
From: MCKAYD@aplbt1.agw.bt.co.uk (Dermot McKay)
Subject: Re: I think its a greediness issue
Message-Id: <6vve0q$klu$1@pheidippides.axion.bt.co.uk>


>
>Notice how it took the <info t="g88b111" n=11> which was fine where it
>was and moved it outside the second </grc> tag leaving the <info
>t="g88b112" n=12> still inside the second </grc>. Now footnote #11
>follows #12.
>
This is because you are tell the script to look for <grc>then anything then 
<info.*?> then anything and finally </grc>
Therefore the frist search and replace is correct.

It replaces  <grc>periV tw'n kekoimhmevnwn</grc>.<info t="g88b111" n=11> 
                 ^^^^^^                                                   ^^
                   1                                                       2
>From the use of <grc>periv<info t="g88b112" n=12></grc>
                                                                          ^^
                                                                          3
^^ these show you script working it finds 1 then anything then 2 then anything 
then 3.
To do this you may need to rethink your script.


$line=~s!(<grc>)([A-Za-z0-9\'\.\,=\-\n]+)(<info.*?>)([A-Za-z0-9\'\.
\,=\-]+)(</grc>)!$1$2$4$5$3!g;

this would work but has the problem that you have to include everything but 
the / character as it is needs to be removed to stop the script from changing 
correct tags.

OK

Dermot


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

Date: 13 Oct 1998 12:12:29 +0200
From: Anton Berezin <tobez@plab.ku.dk>
Subject: Re: Max lines in an Array?
Message-Id: <86lnmksrci.fsf@lion.plab.ku.dk>

"Doyle Johnson" <sales@madm.com> writes:

> Mark-Jason Dominus wrote in message <6vuakb$lc8$1@monet.op.net>...
> >In article <6vu4o4$egq$1@nnrp03.primenet.com>,
> >Doyle Johnson <sales@madm.com> wrote:
> >>  Is there a limit to the number of lines you can stuff into an array?
> >
> >No, unless you run out of memory.
> 
>   Ok thats where I guess I lose it.....  there must be a certain amount of
> overhead to each line.... my testing has produced the following:
> 
> File A  12,000 lines  1.7 megs total size   runs
> 
> File B  16,000 lines  1.3 megs total size  gags
> 
> The fact that the length of the lines in file B didnt seem to matter nor did
> the file size. It seemed to be more of a number of lines before "out of mem"
> error.

Well, of course there is an overhead.

Basically, if you are using those lines just like strings, on a
machine with 32-bit integers and 32-bit pointers you have 12+12=24
bytes a _necessary_ ``overhead'' for every string scalar, plus one
NULL byte at the end of the string.  If you are putting those strings
into an array, you'll have 4 bytes more (a pointer).  I.e. in
conditions you described there should be _at least_ 29 bytes per line.

malloc() also has an overhead, depending of the implementation.

etc. etc.

Being on the very optimistic end, you'll have extra 16,000*29 bytes.
Most likely, much more than that.

-- 
-- 
Anton Berezin <tobez@plab.ku.dk>
The Protein Laboratory, University of Copenhagen


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

Date: 13 Oct 1998 12:57:34 +0100
From: Jim Brewer <jimbo@soundimages.co.uk>
Subject: Re: Max lines in an Array?
Message-Id: <ur9wcsmhd.fsf@jimbosntserver.soundimages.co.uk>

"Doyle Johnson" <sales@madm.com> writes:
>
> Mark-Jason Dominus wrote in message <6vuakb$lc8$1@monet.op.net>...
> >In article <6vu4o4$egq$1@nnrp03.primenet.com>,
> >Doyle Johnson <sales@madm.com> wrote:
> >>  Is there a limit to the number of lines you can stuff into an array?
> >
> >No, unless you run out of memory.
> 
>   Ok thats where I guess I lose it.....  there must be a certain amount of
> overhead to each line.... my testing has produced the following:
> 
> File A  12,000 lines  1.7 megs total size   runs
> 
> File B  16,000 lines  1.3 megs total size  gags
> 
> The fact that the length of the lines in file B didnt seem to matter nor did
> the file size. It seemed to be more of a number of lines before "out of mem"
> error.

Well, think about it logically. If you want to read in 1,048,576 you
need 1,048,576 free bytes avaiable to read it into. Now if you want to
read these bytes into a scalar then you will need just a bit more
memory to account for the scalar itself plus the data you are reading
in.

Now, suppose that you want to read the data line by line using an
array. Bearing in mind that an array is a list of scalars, your not
going to really need much more memory than if you read the data into a
single scalar. Just enough to account for 16,000 scalars. Now if each
scalar requires 32 bits to represent internally, that adds up to
something like 64,000 bytes. Now, even if keeping track of the array
itself takes the same number of bytes, the total is still reasonable,
128,000 bytes. So, a file of 16,000 lines, each line containing 256
characters will require 4,096,000 bytes plus 64,000 bytes of free
memory if you want to read it into memory. Plus some additional
overhead for the array itself. But still very resonable.

So, the fact that you are running out of memory seems to indicate you
have a different problem. Like, are you, perhaps unwittingly, making
several copies of your array when processing the log file? Is your
system configured to restrict the total memory available to a single
process that happens to fall below the amount you require to run your
particular script? Have you checked your syslog files to see if your
script's is in there? Have you tried monitoring your script when it is
running to see what kind of system behaviour your script is producing?

I did a bit of a test on my systems, using the following script:

#! /usr/bin/perl -w

# The program is named array_read.plx.
# This file is read recusively to build up the array to
# simulate the processing of the log file.

$elements = 100000;

open(FRED, "< array_read.plx") || die "cannot open file:$!\n";
{
  local $/ = undef;
  $_ = <FRED>;
}
close (FRED);

for ($i = 0; $i < $elements; ++$i) {
  push @lines, $_;
  $count += length $lines[$i];
  print "loop is $i; ";
  print "array has @{[scalar @lines]} elements; ";
  print "$count total bytes\r";
}
print "\n";
sleep 100;

The results are as follows: 

RedHat 5.1, 16Mb memory, 64Mb swap partition, Perl 5.004_04:

loop is 99999; array has 100000 elements; 54200000 total bytes

Top reported a size of 57268 Kb (58642432 bytes) for the process when
finshed.

Win NT, 128Mb memory, 128Mb swap file, Perl 5.004_04 Standard
Distribution:

loop is 99999; array has 100000 elements; 55900000 total bytes

NT reported approximately 59183104 bytes (57796 Kb) used for the
script when the process had finished.

I allocated 100000 array elements. I had approximately 53700 Kb of
data allocated. I never ran out of memory.

Now, I know this isn't exhaustive, but it does point out that whatever
problems you are encountering are not REQUIRED to be Perl's
problem. They are just as likely your problem, or your systems
problem, or a system configuration problem.

> Now Im no expert but this would suggest that Perl is using twice the mem for
> an array than the actual data contained in it. There must be a work around
> in Perl to use an array or some other grouped list to sort data.

Well, not according to my tests. My Perl is not using anywhere near
the same amount of memory for the array compared to the data
itself. Let alone TWICE that of the data. About 10% of total process
memory is allocated to Perl and everything it needs, including the
array. The rest is the data itself. Note, 10%, not 200%.

Like I said, the problem is not very likely to be a Perl problem. Your
sorting method, your data handling method, the log file itself, may all
be contributing to your problem.

> There must be someone on this list that has been through this and knows how
> to get around it. I guess I just have to get lucky enough for them to see
> this thread and give me a hand...:)

<grin>
Well, if your looking for applause...
</grin>
-- 
Jim Brewer
e-mailed courtesy copies are unappreciated, please refrain.


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

Date: 13 Oct 1998 12:03:39 GMT
From: "wkchiu" <wkchiu@yahoo.com>
Subject: More Questions on Command Capture using Perl
Message-Id: <01bdf6a1$fbf2c1c0$741e500a@pct2>

I use the PIPE command to capture the output of a event log program with
the following method :

open(PIPE,"somecmd.exe |") or die(\n"Can't open pipe !\n");
while(<PIPE>) {
print(localtime,"$_");
 ...some processing...
}
close(PIPE);

I am using Windows NT Server 4.0 and perl 5.00502. However, I found that
the output of 'somecmd.exe' is already printed out to console when
'while(<PIPE>)' is executed. The 'print(localtime,"$_")' will not give out
the command output.

As my ultimate goal is to pre-pend a prefix before every line of the
output, pls tell me how to do that. Also, since the while loop loops
infinitely which will eat up all processing power, is it possible to set
the while loop to continue only after a line is read ?

wkchiu


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

Date: Tue, 13 Oct 1998 13:35:47 +0100
From: "Webmaster" <webmaster@NOSPAM.web-design.org.uk>
Subject: need help with an interactive gannt chart
Message-Id: <6vvhhf$5p1$1@times.colloquium.co.uk>

Can anyone help me, please reply in this newgroup



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

Date: Tue, 13 Oct 1998 10:03:19 GMT
From: lqyrms@nottingham.ac.uk
Subject: Perl Cookbook - is this the best perl book?
Message-Id: <6vv8h6$799$1@nnrp1.dejanews.com>

Could anybody who has read the Perl Cookbook please tell me if this is the
best perl book to get. There are a couple of reviews of this book at amazon (
 http://www.amazon.com/exec/obidos/ASIN/1565922433/bibs/  ) , but I would
appreciate the views of the experts in this newsgroup too.

Many thanks,

--
Mark.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 13 Oct 1998 11:11:38 GMT
From: dave@mag-sol.com
Subject: Re: Perl Cookbook - is this the best perl book?
Message-Id: <6vvcha$b24$1@nnrp1.dejanews.com>

In article <6vv8h6$799$1@nnrp1.dejanews.com>,
  lqyrms@nottingham.ac.uk wrote:
> Could anybody who has read the Perl Cookbook please tell me if this is the
> best perl book to get. There are a couple of reviews of this book at amazon (
>  http://www.amazon.com/exec/obidos/ASIN/1565922433/bibs/  ) , but I would
> appreciate the views of the experts in this newsgroup too.

Depends what you're looking for. For learning Perl you should use 'Learning
Perl' (or the Win32 version). For a Perl reference you need 'Programming
Perl'. 'The Perl Cookbook' is a large number of 'tricks of the trade', ways
to use Perl to get real-life jobs done. If that's what you want - then it's
the best!

hth,

Dave...


--
dave@mag-sol.com
London Perl M[ou]ngers: <http://london.pm.org/>
[Note Changed URL]

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 13 Oct 1998 12:09:28 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Problems Using a Compare Subroutine with Sort
Message-Id: <6vvfto$lq5$1@pegasus.csx.cam.ac.uk>

In article <6vij07$pvc$1@nnrp1.dejanews.com>,  <droby@copyright.com> wrote:
>In article <361BB7F3.7B7F7619@min.net>,
>  John Porter <jdporter@min.net> wrote:
>> 	2. characters are unsigned.
>>
>
>I think that one's reasonably safe.  What would we mean by a signed character?

Err... what it says.    Unfortunately, some Unix flavours *do* have
signed characters (e.g. SunOS 4.1.3), and they used to cause Perl grief.
This got mended in perl5.004_11.

See the HAS_SANE_MEMCMP symbol in the Perl source.


Mike Guy


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

Date: Tue, 13 Oct 1998 03:13:59 +0000
From: "Xah" <xah@best.com>
Subject: Re: prograMing: CompleteIndexSet
Message-Id: <362325d8$0$25894@nntp1.ba.best.com>

I wrote:
>I have a every interesting
>academic-type programing problem involving array generation, and am
>interested to see creative results. 

Doesn't looks like there's whole lot of interest in this problem. Anyway, here's some codes to satisfy those perl-holic.

The algorithm used for CompleteIndexSet is from Rick Delaney <rick.delaney@shaw.wave.ca>. Thanks Rick.

I was going to write a version that avoids generating existing indexes, but Rick's solution is good enough that I decided to use it. My planned algorithm will use MinimumIndexSet to prune the argument first, then use this minimum index set to generate the complete index set, where as soon as a single index is detected existing, that index would be immediately dropped from the generating process. This algorithm would have a better time complexity, but is probably not worthy unless the input is huge with lots of different branches...

#------------------------
#!perl -w

use strict;
#_____ MinimumIndexSet _____ _____

=pod

B<MinimumIndexSet>

MinimumIndexSet([index1,index2,...]) returns a modified version of input in which indexes that can be inferred from other indexes are deleted. Indexes are of the form [n1,n2,n3,...] where the n are non-negative integers.

Related: CompleteIndexSet, FullArrayIndexSet.


Example:

 MinimumIndexSet([[1], [2], [3], [2, 3], [2, 2], [2, 3, 7], [3, 1]])
 #returns [[2, 3, 7], [3, 1]].

=cut

# implementation note:
# definition: Suppose {a,b,c,d} is one index. It is redundant if MemberQ[givenIndexes,{a,b,c,x$_/;x$ > d}|{a,b,c,x$_/;x$ >= d,__}], and if the index is {}, then it is redundant if MemberQ[givenIndexes,{__}].
# algorithm used: exactly same as LeafIndexSet except _leafIndexQ is replaced by _inferableIndexQ.

# Dependent functions: _inferableIndexQ.

# misc notes: this function needs heavy testing. xxxxx

sub MinimumIndexSet ($) {
my @indexList = @{$_[0]};

my $count = 1;
my $ref_currentIndex;
my $ref_currentElement;
OUTER: while ($count < scalar @indexList) {
$ref_currentIndex = $indexList[-$count];
 INNER: for (my $i = scalar(@indexList) -$count -1; $i >= 0; $i--) {
 $ref_currentElement = $indexList[$i];
 
 if (_inferableIndexQ($ref_currentElement,$ref_currentIndex))
 {splice(@indexList,$i,1); next INNER;}
 elsif (_inferableIndexQ($ref_currentIndex,$ref_currentElement))
 {splice(@indexList,-$count,1); next OUTER;};
 };
$count++;
};

return \@indexList;
};

#_____ CompleteIndexSet _____ _____

=pod

B<CompleteIndexSet>

CompleteIndexSet([index1,index2,...]) returns a modified version of argument in which indexes that are implied by givens are inserted. The elements in the result list is arbitrary ordered, and without duplicates.

Related: MinimumIndexSet, FullArrayIndexSet, IndexSetSort.

Example:

The empty array [] in the result represents the index for the root node.

 IndexSetSort( CompleteIndexSet( [[2, 1]] ) );
 #returns [[],[0],[1],[2],[2,0],[2,1]].

 IndexSetSort( CompleteIndexSet( [[2, 1], [3]] ) );
 #returns [[],[0],[1],[2],[3],[2,0],[2,1]].

 IndexSetSort( CompleteIndexSet( [[2, 1], [3], [3]] ) );
 #returns [[],[0],[1],[2],[3],[2,0],[2,1]].

 IndexSetSort( CompleteIndexSet( [[3, 3], [4]] ) );
 #returns [[],[0],[1],[2],[3],[4],[3,0],[3,1],[3,2],[3,3]].

 IndexSetSort( CompleteIndexSet( [[3, 3], [1, 1], [4]] ) );
 #returns [[],[0],[1],[2],[3],[4],[1,0],[1,1],[3,0],[3,1],[3,2],[3,3]].

=cut

# implementation note:
# some description:
# Suppose one of the given index is {a,b,c,d}. If the last digit is not 0, then generate {a,b,c,d-1}. If the last digit is 0, then generate {a,b,c}. Add the new element into a result list. Now take new element as input and repeat the process until it becomes {}. Now do the above with every given index. Now eliminate duplicates and {} in the result list. The result is as desired.

# Dependent functions: (none)

# misc notes: this function needs heavy testing. This function's time complexity can also be improved by first generate a minimum index set, and use a smart algorithm to avoid generating repeatitions (without even checking for existance). xxxxx


sub CompleteIndexSet ($) {
 my @indexList = @{$_[0]};

 my %indexListHash;
 foreach my $elem (@indexList) {$indexListHash{"@{$elem}"} = $elem;};

    foreach my $ref_index (@indexList) {
        my @index = @{$ref_index};
 LOOP1: while (@index) {
   if ($index[-1]-- == 0) {pop(@index);};
   if (exists $indexListHash{"@index"}) {last LOOP1;};
   $indexListHash{"@index"} = [@index];
  };
 };
 return [values %indexListHash];
};


# _inferableIndexQ($indexA,$indexB) returns 1 if $indexB implies $indexA. Suppose indexA = {a,b,c,d}. Then it is inferable if MatchQ[indexB, {a,b,c,x$_/;x$ > d}|{a,b,c,x$_/;x$ >= d,__}]. If indexA == indexB, we also say it's inferable.
# $indexA and B must have the form [n1,n2,...], where n_i is non-negative integer.
# Examples: the following are all true:
# _inferableIndexQ([3,2],[3,2]);
# _inferableIndexQ([3,2],[3,3]);
# _inferableIndexQ([3,2],[3,2,0]);
# _inferableIndexQ([3,2],[3,2,2,4]);
# the following are false:
# _inferableIndexQ([3,2],[4]);
# _inferableIndexQ([3,2],[3,1]);
# _inferableIndexQ([3,2],[3,1,5]);

sub _inferableIndexQ ($$) {
my @indexA = @{$_[0]};
my @indexB = @{$_[1]};

# if length of indexA is greater then indexB, then indexA is not inferable.
if (scalar @indexA > scalar @indexB) {return 0};

# if the first few of indexA are not the same as indexB, then indexA is not inferable.
foreach my $i (0 .. $#indexA -1) {if ($indexA[$i] != $indexB[$i]) {return 0;};};

if ($indexA[-1] <= $indexB[$#indexA]) {return 1;};

return 0;
};

#------------------------

 Xah, xah@best.com
 http://www.best.com/~xah/PageTwo_dir/more.html
 "YOU! stop bad cencorship NOW: http://www.cdt.org/ "


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

Date: Tue, 13 Oct 1998 12:03:08 GMT
From: paul@miraclefish.com
Subject: Re: Return Code
Message-Id: <6vvfhs$doa$1@nnrp1.dejanews.com>

In article <6vpt43$j4$1@nslave1.tin.it>,
  "Simeone" <simeonem@tin.it> wrote:
> Hi! Just a beginner's question for you:
>
> I've got to execute some system commands, like useradd, userdel, chage, etc.
> What can I do, if I want to run them and catch their return codes?
>
> Thank you!
>
>
man perlfunc and look for the 'system' entry.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 13 Oct 1998 14:35:06 +0200
From: Alexander Farber <eedalf@eed.ericsson.se>
Subject: TAB completion - how?
Message-Id: <362348FA.446D76B4@eed.ericsson.se>

Dear perl gurus,

how do you implement the file name completion (with TAB)?
I suspect it is usually done using the Term::Completion,
but its documentation (perldoc on it) is really scarce
and I have no clue how to do it. I have also searched
the Dejanews for "Term::Completion perl" - with no success.

I am trying:

use Term::Complete;
$input = Term::Complete -> Complete ('prompt_string', glob <*>);

but get the warning: Use of uninitialized value at Complete.pm line 86.

Thanks in advance!
Alex


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

Date: Tue, 13 Oct 1998 10:53:47 GMT
From: hawkwynd@adelphia.net (Hawkwynd)
Subject: testing
Message-Id: <36233113.2754071@nntp.adelphia.net>

			
Testing... One twp tje';ef
Visit Hawkwynd's Personal Web Server - Windows 98
http://hawkwynd.tzo.com


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

Date: Tue, 13 Oct 1998 08:14:45 -0400
From: "Ray Smith" <smithr@lexma.meitech.com>
Subject: Using perldoc -m Module_name
Message-Id: <6vvg55$3iv$1@client3.news.psi.net>

Most of the time when I run "perldoc -m MODULE_NAME" I get a view (via
NotePad the local editor) of the module documentation.  However, for some
modules the view appears to be just a listing of the code with out the
proper line control.  Note that when I cut and past an abbreviated example
below the display appears normal.
Command line:
H:/SmithR[4509] perldoc -m MD5

Displayed via local editor:
# SCCS ID @(#)MD5.pm 1.9 96/06/28
package MD5;
use strict;
use vars qw($VERSION @ISA @EXPORT);
 ...
1;
__END__
=head1 NAME
MD5 - Perl interface to the RSA Data Security Inc. MD5 Message-Digest
Algorithm
=head1 SYNOPSIS
    use MD5;
 ...

Any ideas?

Thanks for your attention,

Ray Smith





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

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 3960
**************************************

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