[30380] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1623 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 9 16:09:48 2008

Date: Mon, 9 Jun 2008 13:09:15 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 9 Jun 2008     Volume: 11 Number: 1623

Today's topics:
    Re: <<EndOfMessage <xiaoxia2005a@yahoo.com>
    Re: <<EndOfMessage <xiaoxia2005a@yahoo.com>
        A dumb question but... <bill@ts1000.us>
    Re: A dumb question but... <simon.chao@fmr.com>
    Re: A dumb question but... <joost@zeekat.nl>
    Re: A dumb question but... <m@rtij.nl.invlalid>
    Re: A dumb question but... <jurgenex@hotmail.com>
    Re: FAQ 5.23 All I want to do is append a small amount  <ben@morrow.me.uk>
    Re: FAQ 5.28 How can I read in an entire file all at on <simon.chao@fmr.com>
    Re: FAQ 5.38 How do I select a random line from a file? xhoster@gmail.com
    Re: FAQ 5.38 How do I select a random line from a file? <simon.chao@fmr.com>
    Re: FAQ 5.38 How do I select a random line from a file? <jimsgibson@gmail.com>
    Re: FAQ 5.38 How do I select a random line from a file? xhoster@gmail.com
    Re: FAQ 5.38 How do I select a random line from a file? <simon.chao@fmr.com>
        Good intro to perl to a "newbie to programming" <ignoramus25756@NOSPAM.25756.invalid>
    Re: How to find memory leak in perl server <tzz@lifelogs.com>
    Re: Parsing an AVI to determine the length in time <danrumney@warpmail.net>
    Re: Parsing an AVI to determine the length in time <tzz@lifelogs.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 9 Jun 2008 07:22:00 -0700 (PDT)
From: April <xiaoxia2005a@yahoo.com>
Subject: Re: <<EndOfMessage
Message-Id: <58f0d018-2536-4c4a-a85d-f272915f1c5c@d1g2000hsg.googlegroups.com>

On Jun 6, 8:01=A0am, Tad J McClellan <ta...@seesig.invalid> wrote:
> April <xiaoxia20...@yahoo.com> wrote:
> > print DOMAIL <<"EndOfMessage";
> > What does << in the print statement mean?
>
> It is called a "here document".
>
> It is nothing more than an alternative way of quoting a string.
>
> See the "Quote and Quote-like Operators" section in perlop.pod and
>
> =A0 =A0perldoc -q "here document"
>
> --
> Tad McClellan
> email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"

Thanks Tad!


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

Date: Mon, 9 Jun 2008 07:22:39 -0700 (PDT)
From: April <xiaoxia2005a@yahoo.com>
Subject: Re: <<EndOfMessage
Message-Id: <57fe8fa6-0f29-4df8-a54e-56ea31e1b168@e39g2000hsf.googlegroups.com>

On Jun 6, 9:46=A0am, smallpond <smallp...@juno.com> wrote:
> April wrote:
> > Need help on the following piece ...
>
> > $MTo =3D 'some...@someplace.com';
> > $MSubject =3D 'Something';
> > open(DOMAIL, "| mail -s $Msubject $MTo");
> > print DOMAIL <<"EndOfMessage";
> > First half mail body,
> > Second half mail body.
> > EndOfMessage
>
> > Does this mean the mail body before EndOfMessage will be sent to
> > filehandle DOMAIL, which inturn will be piped to mail for sending out?
>
> > What does << in the print statement mean? =A0Have seen < read, > write,
> > and >> append, but couldn't find <<.
>
> Note that if you have spaces in your subject, this will not work.
> You should add escaped quotes around $Msubject to your mail command.
> -S
> ** Posted fromhttp://www.teranews.com**- Hide quoted text -
>
> - Show quoted text -

Thanks!


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

Date: Mon, 9 Jun 2008 12:26:26 -0700 (PDT)
From: Bill H <bill@ts1000.us>
Subject: A dumb question but...
Message-Id: <5a81e316-6f9a-4ea7-bef9-1a0a9522504e@27g2000hsf.googlegroups.com>

I have this perl script that I have been using for bout 10 years that
sends out a mass email to one of my clients member list (about 4,000)
people. I run it at a shell prompt on an Apache server and it will
display back a "sent email address" for each one it processes. Takes
about 2 hours to run through. I am not concerned about speeding it up
or anything since I only do it once a week and usually off eating
lunch while it runs, but I have always wondered. Would perl be
notified and / or care if I closed that shell window or would it just
continue on till it was done?

Bill H


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

Date: Mon, 9 Jun 2008 12:41:23 -0700 (PDT)
From: nolo contendere <simon.chao@fmr.com>
Subject: Re: A dumb question but...
Message-Id: <88c13114-1f75-4f84-bc5a-770613672fce@m73g2000hsh.googlegroups.com>

On Jun 9, 3:26=A0pm, Bill H <b...@ts1000.us> wrote:
> I have this perl script that I have been using for bout 10 years that
> sends out a mass email to one of my clients member list (about 4,000)
> people. I run it at a shell prompt on an Apache server and it will
> display back a "sent email address" for each one it processes. Takes
> about 2 hours to run through. I am not concerned about speeding it up
> or anything since I only do it once a week and usually off eating
> lunch while it runs, but I have always wondered. Would perl be
> notified and / or care if I closed that shell window or would it just
> continue on till it was done?


That depends on your shell, and how it handles hangup signals. Use
nohup explicitly if you want to be sure that your script will continue
to run even after you close your window.


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

Date: Mon, 09 Jun 2008 21:43:35 +0200
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: A dumb question but...
Message-Id: <87ej769yxk.fsf@zeekat.nl>

Bill H <bill@ts1000.us> writes:

> I have this perl script that I have been using for bout 10 years that
> sends out a mass email to one of my clients member list (about 4,000)
> people. I run it at a shell prompt on an Apache server and it will
> display back a "sent email address" for each one it processes. Takes
> about 2 hours to run through. I am not concerned about speeding it up
> or anything since I only do it once a week and usually off eating
> lunch while it runs, but I have always wondered. Would perl be
> notified and / or care if I closed that shell window or would it just
> continue on till it was done?

By default programs exit on a SIGHUP, so unless the script you're
using takes care to handle that, it will probably exit.

If you want to, you could run the program in screen instead (I
actually prefer this for long-running processes, since it can be
slightly too easy to kill an xterm / ssh session).

See: http://en.wikipedia.org/wiki/SIGHUP
     http://en.wikipedia.org/wiki/GNU_Screen


-- 
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/


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

Date: Mon, 9 Jun 2008 21:59:23 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: A dumb question but...
Message-Id: <pan.2008.06.09.19.59.14@rtij.nl.invlalid>

On Mon, 09 Jun 2008 12:26:26 -0700, Bill H wrote:

> I have this perl script that I have been using for bout 10 years that
> sends out a mass email to one of my clients member list (about 4,000)
> people. I run it at a shell prompt on an Apache server and it will
> display back a "sent email address" for each one it processes. Takes
> about 2 hours to run through. I am not concerned about speeding it up or
> anything since I only do it once a week and usually off eating lunch
> while it runs, but I have always wondered. Would perl be notified and /
> or care if I closed that shell window or would it just continue on till
> it was done?

On most (all) shells, that would send a SIGHUP to the process. If you 
don't catch that signal, it kills the process.

If you don't want that, either use nohup or batch.

M4


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

Date: Mon, 09 Jun 2008 20:08:00 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: A dumb question but...
Message-Id: <b33r4453gt9vl2o3indnrnp1cnct85p76h@4ax.com>

Bill H <bill@ts1000.us> wrote:
[long running perl script]
>Would perl be
>notified and / or care if I closed that shell window or would it just
>continue on till it was done?

That depends on the shell you are using, how you start that program, and
how it is attached to that virtual terminal.

Typically processes that run in the foreground are terminated when their
terminal closes. Processes that run in the background may or may not
continue, depending on how you configure them. But that's only a broad
generalization and can be reconfigured for each process.

jue


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

Date: Mon, 9 Jun 2008 20:51:28 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: FAQ 5.23 All I want to do is append a small amount of text to the end of a file.  Do I still have to use locking?
Message-Id: <07e0i5-pvl2.ln1@osiris.mauzo.dyndns.org>


Quoth PerlFAQ Server <brian@stonehenge.com>:
> 
> 5.23: All I want to do is append a small amount of text to the end of a
> file.  Do I still have to use locking?
> 
<snip>
>     There is still a small theoretical chance that a signal will interrupt
>     the system level write() operation before completion. There is also a
>     possibility that some STDIO implementations may call multiple system
>     level write()s even if the buffer was empty to start. There may be some
>     systems where this probability is reduced to zero.

    This includes all systems using the :perlio layer instead of native
    STDIO.

Ben

-- 
I have two words that are going to make all your troubles go away.
"Miniature". "Golf".
                                                         [ben@morrow.me.uk]


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

Date: Mon, 9 Jun 2008 07:11:02 -0700 (PDT)
From: nolo contendere <simon.chao@fmr.com>
Subject: Re: FAQ 5.28 How can I read in an entire file all at once?
Message-Id: <57a06505-e148-403e-ae19-5f29881d67ac@b1g2000hsg.googlegroups.com>

On Jun 8, 6:48=A0pm, Bill H <b...@ts1000.us> wrote:
> > =A0 =A0 The customary Perl approach for processing all the lines in a fi=
le is to
> > =A0 =A0 do so one line at a time:
>
> > =A0 =A0 =A0 =A0 =A0 =A0 open (INPUT, $file) =A0 =A0 || die "can't open $=
file: $!";
> > =A0 =A0 =A0 =A0 =A0 =A0 while (<INPUT>) {
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 chomp;
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 # do something with $_
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> > =A0 =A0 =A0 =A0 =A0 =A0 close(INPUT) =A0 =A0 =A0 =A0 =A0 =A0|| die "can'=
t close $file: $!";
>
> I recently had to rework a program that used the above method in many
> places to load in small files (100 lines or so) containing product
> information, sales tax, ect. for a simple cart because a high placed
> security firm that was overseeing the project felt that the above
> method caused too much lag on servers and a possible collision with
> users. Not wanting to argue I followed their advice and replaced it
> with the @lines =3D <INPUT> method shown below. Not that it matters now,
> but did they have a valid point?
>
> > =A0 =A0 This is tremendously more efficient than reading the entire file=
 into
> > =A0 =A0 memory as an array of lines and then processing it one element a=
t a
> > =A0 =A0 time, which is often--if not almost always--the wrong approach. =
Whenever
> > =A0 =A0 you see someone do this:
>
> > =A0 =A0 =A0 =A0 =A0 =A0 @lines =3D <INPUT>;
>
> > =A0 =A0 you should think long and hard about why you need everything loa=
ded at
> > =A0 =A0 once. It's just not a scalable solution. You might also find it =
more fun
> > =A0 =A0 to use the standard Tie::File module, or the DB_File module's $D=
B_RECNO
> > =A0 =A0 bindings, which allow you to tie an array to a file so that acce=
ssing an
> > =A0 =A0 element the array actually accesses the corresponding line in th=
e file.
>

What exactly do you mean by "load in"? And what did *they* mean by
"caused too much lag on servers and a possible collision with users"?

If you're loading into a database, the best method would be to bulk
load if possible, using the bulk loader util of whichever database
you're using. Barring that, another efficient way would be to batch up
the records you're loading, using parameter binding, etc. Was the line-
by-line method slow before because they were loading and committing
every record?


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

Date: 09 Jun 2008 16:16:42 GMT
From: xhoster@gmail.com
Subject: Re: FAQ 5.38 How do I select a random line from a file?
Message-Id: <20080609121644.467$R2@newsreader.com>

brian d  foy <brian.d.foy@gmail.com> wrote:
> In article <484adab2$0$30196$4c368faf@roadrunner.com>, Dan Rumney
> <danrumney@warpmail.new> wrote:
>
> > Peter J. Holzer wrote:
> > > On 2008-06-04 19:03, PerlFAQ Server <brian@stonehenge.com> wrote:
> > >> 5.38: How do I select a random line from a file?
>
> > > If your file is large, and the lines are roughly of equal length, it
> > > is probably preferrable to just do a random seek into the file and
> > > read the line you've hit (by searching backwards and forwards for
> > > $/).
>
> > The  problem with that is that the probability of selecting a line
> > becomes a function of that line's length.
> >
> > The algorithm above ensures that the probability of selecting a line is
> > precisely 1/N where N is the total number of lines in the file.
>
> From time to time, I think about how I would solve this problem if I
> actually needed it for something important. That is, not as some
> thought experiment or quote-for-the-sig thing.
>
> Has anyone solved this for something non-trivial? Say, for something
> with huge numbers of lines or large file sizes, or where you want to
> choose several random lines?
>
> The solution that I think about (but have never implemented), is some
> sort of pre-indexing of line endings so you have a list of file
> positions where all the lines line (or start, or whatever). When you
> want a random line, you choose a random element from that list. Open
> the file, seek, and read a line.

If space wasn't at a premium, and the file was static, I might just
determine the maximum line length and then pad out all lines to that length
(putting the padding after the \n, so they are really part of the next
line), and then encode that fixed length either in the code or in the file
name.  Then seek to a random record.  If the maximum line length was an
order of magnitude more than the typical, I might not do that.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

Date: Mon, 9 Jun 2008 11:38:01 -0700 (PDT)
From: nolo contendere <simon.chao@fmr.com>
Subject: Re: FAQ 5.38 How do I select a random line from a file?
Message-Id: <07da2e78-771c-456c-981c-443efa2fc545@l64g2000hse.googlegroups.com>

On Jun 9, 12:16=A0pm, xhos...@gmail.com wrote:
> brian d =A0foy <brian.d....@gmail.com> wrote:
>
>
>
> > In article <484adab2$0$30196$4c368...@roadrunner.com>, Dan Rumney
> > <danrum...@warpmail.new> wrote:
>
> > > Peter J. Holzer wrote:
> > > > On 2008-06-04 19:03, PerlFAQ Server <br...@stonehenge.com> wrote:
> > > >> 5.38: How do I select a random line from a file?
>
> > > > If your file is large, and the lines are roughly of equal length, it=

> > > > is probably preferrable to just do a random seek into the file and
> > > > read the line you've hit (by searching backwards and forwards for
> > > > $/).
>
> > > The =A0problem with that is that the probability of selecting a line
> > > becomes a function of that line's length.
>
> > > The algorithm above ensures that the probability of selecting a line i=
s
> > > precisely 1/N where N is the total number of lines in the file.
>
> > From time to time, I think about how I would solve this problem if I
> > actually needed it for something important. That is, not as some
> > thought experiment or quote-for-the-sig thing.
>
> > Has anyone solved this for something non-trivial? Say, for something
> > with huge numbers of lines or large file sizes, or where you want to
> > choose several random lines?
>
> > The solution that I think about (but have never implemented), is some
> > sort of pre-indexing of line endings so you have a list of file
> > positions where all the lines line (or start, or whatever). When you
> > want a random line, you choose a random element from that list. Open
> > the file, seek, and read a line.
>
> If space wasn't at a premium, and the file was static, I might just
> determine the maximum line length and then ...<snip>

Wouldn't determining the maximum line length require you to go through
the entire file? So right there the cost is more than the solution in
the FAQ (the one referencing the Camel book), right? Unless you're
saying not to count this initial work, but then, is that fair when
trying to compare solutions?



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

Date: Mon, 09 Jun 2008 12:20:03 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: FAQ 5.38 How do I select a random line from a file?
Message-Id: <090620081220030810%jimsgibson@gmail.com>

In article <080620080134579524%brian.d.foy@gmail.com>, brian d  foy
<brian.d.foy@gmail.com> wrote:

> In article <484adab2$0$30196$4c368faf@roadrunner.com>, Dan Rumney
> <danrumney@warpmail.new> wrote:
> 
> > Peter J. Holzer wrote:
> > > On 2008-06-04 19:03, PerlFAQ Server <brian@stonehenge.com> wrote:
> > >> 5.38: How do I select a random line from a file?


> Has anyone solved this for something non-trivial? Say, for something
> with huge numbers of lines or large file sizes, or where you want to
> choose several random lines?
> 
> The solution that I think about (but have never implemented), is some
> sort of pre-indexing of line endings so you have a list of file
> positions where all the lines line (or start, or whatever). When you
> want a random line, you choose a random element from that list. Open
> the file, seek, and read a line.
> 
> I guess if it really mattered, you'd put every line in a some sort of
> persistence thingy and choose choose a random record without having to
> read a file at all.

In the general case of reading a file and picking a random record
without knowing the number or length of records in the file, this is
"reservoir sampling", or picking n elements from a set of N without
knowing N at the beginning, with a reservoir of one. See p. 138 of
Knuth's "Seminumerical Algorithms, 2nd Ed." or google for "reservoir
sampling", e.g. <http://gregable.com/2007/10/reservoir-sampling.html>

For a reservoir of size one, the algorithm can be simplified to
something like (untested):
  
  1. Read the first line of the file into a scalar
  2. Read the subsequent lines in the file and, for each line, replace
     the saved line with a probability of 1/n, where n is the number
     of lines read so far (e.g. $.). Generate a random number
     in the interval (0,1) and replace the saved value if the random
     value is less than 1/n.

After reading the entire file, each line in the file has equal
probability of being selected and remaining in the scalar variable.

-- 
Jim Gibson


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

Date: 09 Jun 2008 20:00:52 GMT
From: xhoster@gmail.com
Subject: Re: FAQ 5.38 How do I select a random line from a file?
Message-Id: <20080609160055.109$xM@newsreader.com>

Jim Gibson <jimsgibson@gmail.com> wrote:
> In article <080620080134579524%brian.d.foy@gmail.com>, brian d  foy
> <brian.d.foy@gmail.com> wrote:
>
> > In article <484adab2$0$30196$4c368faf@roadrunner.com>, Dan Rumney
> > <danrumney@warpmail.new> wrote:
> >
> > > Peter J. Holzer wrote:
> > > > On 2008-06-04 19:03, PerlFAQ Server <brian@stonehenge.com> wrote:
> > > >> 5.38: How do I select a random line from a file?
>
> > Has anyone solved this for something non-trivial? Say, for something
> > with huge numbers of lines or large file sizes, or where you want to
> > choose several random lines?
> >
> > The solution that I think about (but have never implemented), is some
> > sort of pre-indexing of line endings so you have a list of file
> > positions where all the lines line (or start, or whatever). When you
> > want a random line, you choose a random element from that list. Open
> > the file, seek, and read a line.
> >
> > I guess if it really mattered, you'd put every line in a some sort of
> > persistence thingy and choose choose a random record without having to
> > read a file at all.
>
> In the general case of reading a file and picking a random record
> without knowing the number or length of records in the file, this is
> "reservoir sampling", or picking n elements from a set of N without
> knowing N at the beginning, with a reservoir of one.

Yep, and this is the algorithm that the FAQ gives.  But some people are
not happy with it.  So you have the progression:

1) naive: read the file once to count the lines, and again to pick
a random line out of it.  You need to read the file, on average, 1.5 times.

2) The reservoir algorithm that the FAQ gives.  This requires reading the
file exactly once.

If you are dealing with a variable-line-length text file never seen before
and are unwilling to compromise on randomness, I don't think it is possible
to do better than this.

3) If you are willing to compromise by preprocessing the file--either into
something else or building an auxiliary structure--or having longer lines
be more likely to be chosen than shorter lines, then of course you can do
better than reading the entire file even once (per execution).  I think
that is outside the scope of the FAQ, but it is what people decided to
discuss.

When I saw the FAQ posted, before seeing follow-ups to it, I thought it
should probably clarify that it is limiting itself to the situation where
the file cannot or will not be preprocessed.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

Date: Mon, 9 Jun 2008 13:02:15 -0700 (PDT)
From: nolo contendere <simon.chao@fmr.com>
Subject: Re: FAQ 5.38 How do I select a random line from a file?
Message-Id: <2856722a-0c9e-42fe-8b35-5987a2b13e7e@s50g2000hsb.googlegroups.com>

On Jun 9, 3:20=A0pm, Jim Gibson <jimsgib...@gmail.com> wrote:
> In article <080620080134579524%brian.d....@gmail.com>, brian d =A0foy
>
>
>
> <brian.d....@gmail.com> wrote:
> > In article <484adab2$0$30196$4c368...@roadrunner.com>, Dan Rumney
> > <danrum...@warpmail.new> wrote:
>
> > > Peter J. Holzer wrote:
> > > > On 2008-06-04 19:03, PerlFAQ Server <br...@stonehenge.com> wrote:
> > > >> 5.38: How do I select a random line from a file?
> > Has anyone solved this for something non-trivial? Say, for something
> > with huge numbers of lines or large file sizes, or where you want to
> > choose several random lines?
>
> > The solution that I think about (but have never implemented), is some
> > sort of pre-indexing of line endings so you have a list of file
> > positions where all the lines line (or start, or whatever). When you
> > want a random line, you choose a random element from that list. Open
> > the file, seek, and read a line.
>
> > I guess if it really mattered, you'd put every line in a some sort of
> > persistence thingy and choose choose a random record without having to
> > read a file at all.
>
> In the general case of reading a file and picking a random record
> without knowing the number or length of records in the file, this is
> "reservoir sampling", or picking n elements from a set of N without
> knowing N at the beginning, with a reservoir of one. See p. 138 of
> Knuth's "Seminumerical Algorithms, 2nd Ed." or google for "reservoir
> sampling", e.g. <http://gregable.com/2007/10/reservoir-sampling.html>
>
> For a reservoir of size one, the algorithm can be simplified to
> something like (untested):
>
> =A0 1. Read the first line of the file into a scalar
> =A0 2. Read the subsequent lines in the file and, for each line, replace
> =A0 =A0 =A0the saved line with a probability of 1/n, where n is the number=

> =A0 =A0 =A0of lines read so far (e.g. $.). Generate a random number
> =A0 =A0 =A0in the interval (0,1) and replace the saved value if the random=

> =A0 =A0 =A0value is less than 1/n.
>
> After reading the entire file, each line in the file has equal
> probability of being selected and remaining in the scalar variable.

Isn't that what the solution in the FAQ does?

            srand;
            rand($.) < 1 && ($line =3D $_) while <>;

for the first line, rand($.) will always be less than 1, so your 1st
instruction is done. for the subsequent lines, the chance of rand($.)
being less than 1 is ~ 1/$., etc.

is that what you were saying? or were you saying something else?



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

Date: Mon, 09 Jun 2008 14:58:58 -0500
From: Ignoramus25756 <ignoramus25756@NOSPAM.25756.invalid>
Subject: Good intro to perl to a "newbie to programming"
Message-Id: <PPednU1yX5YfFtDVnZ2dnUVZWhednZ2d@giganews.com>

I am looking for a book on Perl that introduces it to a person who is
not a programmer, and offers a track along with exercises, etc. 

That would be for someone who does not know any programming, so it
would need to explain a little more what is a "loop", "subroutine" and
similar things in more depth than a book for people who are
programmers already.

Some useful recommendations would be appreciated. Thanks
-- 
   Due to extreme spam originating from Google Groups, and their inattention 
      to spammers, I and many others block all articles originating 
       from Google Groups. If you want your postings to be seen by 
         more readers you will need to find a different means of 
                       posting on Usenet.
                   http://improve-usenet.org/


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

Date: Mon, 09 Jun 2008 10:42:29 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: How to find memory leak in perl server
Message-Id: <86hcc2vcm2.fsf@lifelogs.com>

On Sun, 8 Jun 2008 12:11:32 -0700 "Yuri Shtil" <shtil@comcast.net> wrote: 

YS> I have written an event driven network server in perl. However, when running 
YS> tests I see that the server process increases in memory and slows down.

YS> How would you recommend to approach the problem? What to look for in order 
YS> to identify the cause of the memory leaks?

Do you create variables?

Do you keep their contents around after you need them?

Generally, Perl will use as much memory as you need, but there's a
threshold where that gets annoying (perhaps due to memory fragmentation
or too much memory used--it really depends on what your process does)
and you're better off exiting and restarting.  It's best to use as
little memory as possible and allocate new memory as infrequently as
possible if you want to run forever.  Whether this is feasible with your
server, we don't know.

Ted


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

Date: Mon, 09 Jun 2008 09:53:57 -0400
From: Dan Rumney <danrumney@warpmail.net>
Subject: Re: Parsing an AVI to determine the length in time
Message-Id: <484d35f9$0$30163$4c368faf@roadrunner.com>

marcelo.ebay.1970@gmail.com wrote:
> Hi all, I need to find out the length (in seconds) of a AVI video
> file.
> I search all the CPAN directory without success.
> 
> Does anyone know a way to get this information from an AVI file with a
> batch process, either using a module or a plain routine?
> 
> Thanks in advance!
> Marcelo

Try
http://search.cpan.org/~allenday/Video-Info-0.993/Info/RIFF.pm

Which was the first hit when I search CPAN for "AVI"

It will give you the fps and number of frames in an AVI file


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

Date: Mon, 09 Jun 2008 10:37:53 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Parsing an AVI to determine the length in time
Message-Id: <86lk1evctq.fsf@lifelogs.com>

On Sun, 8 Jun 2008 21:00:15 -0700 (PDT) marcelo.ebay.1970@gmail.com wrote: 

me1> Hi all, I need to find out the length (in seconds) of a AVI video
me1> file.  I search all the CPAN directory without success.

me1> Does anyone know a way to get this information from an AVI file with a
me1> batch process, either using a module or a plain routine?

I usually run mplayer (there's a way to do it just to get the file
statistics) and parse the output.  You may also be able to do it with
ffmpeg, for example.  AVI files are a real mess since they are
containers of just about anything, so there's no good way to parse them
without tools like mplayer or ffmpeg.

Ted


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

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


Administrivia:

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

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

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

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

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


------------------------------
End of Perl-Users Digest V11 Issue 1623
***************************************


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