[17397] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4817 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 6 00:05:33 2000

Date: Sun, 5 Nov 2000 21:05:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <973487111-v9-i4817@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 5 Nov 2000     Volume: 9 Number: 4817

Today's topics:
        [OT] Re: Is there a way to get all PID's within Perl ? (Gwyn Judd)
    Re: [OT] Re: Is there a way to get all PID's within Per (Martien Verbruggen)
    Re: About to slit my own throat (Anthony)
    Re: About to slit my own throat (Anthony)
    Re: About to slit my own throat (Anthony)
    Re: About to slit my own throat (Martien Verbruggen)
    Re: About to slit my own throat (Gwyn Judd)
        ADV: New FishBowl web browser integrates web server <JustSpam@chronofish.com>
        Affordable web hosting $7.50/month kevlers@my-deja.com
    Re: atoi for Perl <uri@sysarch.com>
    Re: Building a Module on Server without Install.pm <flavell@mail.cern.ch>
    Re: File locking <g.soper@soundhouse.co.uk>
    Re: File locking (Gwyn Judd)
        Flock problem <g.soper@soundhouse.co.uk>
    Re: Flock problem (Martien Verbruggen)
    Re: getopt doesn't seem work as expected (Gwyn Judd)
    Re: help w/linux RH6.2 perl script (Chris Fedde)
    Re: how to get return value of process <jprokopek@snet.net>
    Re: how to get return value of process <jprokopek@snet.net>
    Re: how to sort corresponding arrays? (Chris Fedde)
    Re: Looking for idiom for getting value from @ARGV, or  (Martien Verbruggen)
    Re: Looking for idiom for getting value from @ARGV, or  (Ameen Dausha)
    Re: Looking for idiom for getting value from @ARGV, or  <jeffp@crusoe.net>
    Re: Need suggestions on optimization <newspost@coppit.org>
    Re: pattern matching across two lines <Leon@caresystems.com.au>
        Perl flock function problem in BSDI 3.0 & 4.0 <wkwok@uunet.com.au>
    Re: Perl flock function problem in BSDI 3.0 & 4.0 (Martien Verbruggen)
    Re: Perl flock function problem in BSDI 3.0 & 4.0 <wkwok@uunet.com.au>
    Re: Perl syntax and beyond (was: Re: Perl style and mod (Ilya Zakharevich)
    Re: Perl syntax and beyond (was: Re: Perl style and mod (Gwyn Judd)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 06 Nov 2000 00:54:22 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: [OT] Re: Is there a way to get all PID's within Perl ?
Message-Id: <slrn90c09r.73f.tjla@thislove.dyndns.org>

I was shocked! How could Martien Verbruggen <mgjv@tradingpost.com.au>
say such a terrible thing:
>On 5 Nov 2000 21:09:38 GMT,
>	Abigail <abigail@foad.org> wrote:
>> That depends on what you want to do with the program. `ps' is a good
>> example of why you may want to use a full path instead of relying on the
>> path setting, because various flavours of `ps' have wildly different
>> command line options. Where I on Solaris would use `-ef' as command
>
>On Solaris I'd probably use '/usr/ucb/ps auxww', at least as a first
>attempt. On failure I'd probably fall back on /usr/bin/ps.
>
>> line options, for a GNU ps I'd use `auxww'. Quite different arguments
>> (and note the absence of - for GNU ps; for some dark reason, use of a
>> dash results in a warning).

Actually it doesn't matter that much. For sufficiently recent versions
of GNU ps, -ef is accepted.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Don't sweat it -- it's only ones and zeros.
-P. Skelly


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

Date: Mon, 06 Nov 2000 01:21:04 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: [OT] Re: Is there a way to get all PID's within Perl ?
Message-Id: <slrn90c1s2.l2.mgjv@verbruggen.comdyn.com.au>

On Mon, 06 Nov 2000 00:54:22 GMT,
	Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote:
> I was shocked! How could Martien Verbruggen <mgjv@tradingpost.com.au>
> say such a terrible thing:
> >
> >On Solaris I'd probably use '/usr/ucb/ps auxww', at least as a first
> >attempt. On failure I'd probably fall back on /usr/bin/ps.
> >
> >On 5 Nov 2000 21:09:38 GMT,
> >	Abigail <abigail@foad.org> wrote:
>
> >> line options, for a GNU ps I'd use `auxww'. Quite different arguments
> >> (and note the absence of - for GNU ps; for some dark reason, use of a
> >> dash results in a warning).
> 
> Actually it doesn't matter that much. For sufficiently recent versions
> of GNU ps, -ef is accepted.

Yes, but some of us prefer the BSD syntax :) Actually, it seems that
more recent GNU ps's also accept that without problems. Hmm.. 

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd.   | you come to the end; then stop.
NSW, Australia                  | 


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

Date: Mon, 06 Nov 2000 01:26:30 GMT
From: apsaffer@hotmail.com (Anthony)
Subject: Re: About to slit my own throat
Message-Id: <3a060891.16841975@news.rectec.net>

Okay, good idea. But I am fairly new to Perl so I am not sure how to
stop people from using automated script to send spam through it. Do
you know of any place I can go that would better fill me in on this??


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

Date: Mon, 06 Nov 2000 01:28:41 GMT
From: apsaffer@hotmail.com (Anthony)
Subject: Re: About to slit my own throat
Message-Id: <3a060915.16973335@news.rectec.net>

Well, I was told to use the CGI::Carp module to help me debug the
script since this is SUPPOSED to print fatals to the browser. I am not
well versed enough to fully understand it but I thought that is what
it did.


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

Date: Mon, 06 Nov 2000 01:30:48 GMT
From: apsaffer@hotmail.com (Anthony)
Subject: Re: About to slit my own throat
Message-Id: <3a0609ab.17123401@news.rectec.net>

Thank you for your suggestions. Seems like I screwed up this script
pretty bad. Going back to the drawing board...


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

Date: Mon, 06 Nov 2000 01:39:13 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: About to slit my own throat
Message-Id: <slrn90c2u3.l2.mgjv@verbruggen.comdyn.com.au>

On Mon, 06 Nov 2000 01:30:48 GMT,
	Anthony <apsaffer@hotmail.com> wrote:
> Thank you for your suggestions. Seems like I screwed up this script
> pretty bad. Going back to the drawing board...

You didn't screw up. It wasn't that bad for an early attempt. It's
just that there were some things that could be improved, and some
things that definitely should be improved. With something as sensitive
as a remailer, or an anonymous mailer, you just need to take extra
care. If it gets abused, you may be the one that they hold
responsible. It wouldn't be the first time. Apart from improving the
code, you may want to consider whether you really want to poke your
nose into this legal wasp's nest :)

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Little girls, like butterflies, need
Commercial Dynamics Pty. Ltd.   | no excuse - Lazarus Long
NSW, Australia                  | 


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

Date: Mon, 06 Nov 2000 04:09:11 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: About to slit my own throat
Message-Id: <slrn90cbn4.73f.tjla@thislove.dyndns.org>

I was shocked! How could Anthony <apsaffer@hotmail.com>
say such a terrible thing:
>Okay, good idea. But I am fairly new to Perl so I am not sure how to
>stop people from using automated script to send spam through it. Do
>you know of any place I can go that would better fill me in on this??

I suggest you read up on the history of the first anonymous remailer
anon.penet.fi available at all good search engines. That had a pretty
good method of limiting both the size or messages and the frequency that
any user was allowed to send. He required people to log in with a unique
username and password so as to identify them (if I recall correctly).
You might also want to look into why the anon.penet.fi service was shut
down and consider whether you are ready for that kind of attention.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
The purpose of a liberal education is to make you philisophical enough
to accept the fact that you will never make much money. (contributed by
Chris Johnston)


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

Date: Sun, 5 Nov 2000 22:39:12 -0500
From: "ChronoFish" <JustSpam@chronofish.com>
Subject: ADV: New FishBowl web browser integrates web server
Message-Id: <3a062876@news.mdc.net>

The ChronoFish FishBowl Browser is an HTML 4.0 Compliant Internet Browser
with a multiple document interface that simulates a web server for local CGI
programs.  It will execute EXE and scripts (such as Perl) and pass
environment variables to them like a Web Server would.  No need to run a web
server at home if all you are doing is testing out your perl script.  Also
loads index.html automatically if pointing to a directory.

see  www.ChronoFish.com/FishBowl for more details.







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

Date: Sun, 05 Nov 2000 23:51:10 GMT
From: kevlers@my-deja.com
Subject: Affordable web hosting $7.50/month
Message-Id: <8u4rpd$1sm$1@nnrp1.deja.com>

http://www.emegaweb.com/hosting


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 06 Nov 2000 04:31:25 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: atoi for Perl
Message-Id: <x7itq1hgbl.fsf@home.sysarch.com>

>>>>> "dd" == dick dijk <ddijk@hetnet.nl> writes:

  dd> Does anyone know the "atoi()" function (from C) equivalent in Perl?

yes.

$x = $x ;

:)

uri

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


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

Date: Mon, 6 Nov 2000 01:24:46 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Building a Module on Server without Install.pm
Message-Id: <Pine.GHP.4.21.0011060103060.22362-100000@hpplus03.cern.ch>

On Sun, 5 Nov 2000, David Steuber wrote:

> If I were an IT manager, I would want to take advantage of the popular
> packages in order to reduce the effort of my developers.  Development
> time costs more money than hardware, network bandwidth, etc.  That's
> what code reuse is all about.  CGI.pm exemplifies that.

Sounds good to me.  Though I tend to generate boilerplate HTML from
template files or here-documents rather than using CGI.pm's generating
methods.  But its form handling has pretty much everything I need, and
(over time) I've learned about quite a few bugs in the popular
browsers by looking at how CGI.pm copes with them...

> ' Yeah, I've seen plenty of commercial systems that suck. 
> 
> I've worked to improve a few.  It's not easy work.  Fact is, most code
> written sucks.  Certainly the first few itterations.

Well, I tell you frankly, my first drafts fit that description too[*],
but I come here not to encourage others to write code as bad as my
first drafts, but to learn and share better ideas.  To my way of
thinking, that's what usenet is all about, and when a group has
collectively decided "we don't care what the experts say, we know how
it's gotta be for commercial reasons and will howl down anyone who
disagrees" then I'm off.  

Thank goodness that, for the most part, that hasn't happened here.

[*] it's well known that "physicists write FORTRAN in any language".

> ' I'm afraid that history shows that technologically advanced solutions
> ' can't win.  The customers understand brute force much better than they
> ' understand the right answer. 
> 
> I think what you are describing here is people who don't RTFM. 

That's only a secondary symptom.  The primary problem is that they
don't care what the technology was meant for nor what its strong
points are: rather, they start by deciding what it's gotta do, and
then bawl out anyone who tries to teach them about it.  "Don't give
me that crap" they say, "just answer the question".  Sometimes with
"I've got a deadline to meet".   Well, some folk here have rate cards
for that sort of thing.  

all the best




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

Date: Mon, 06 Nov 2000 00:10:35 +0000 (GMT)
From: Geoff Soper <g.soper@soundhouse.co.uk>
Subject: Re: File locking
Message-Id: <4a18ede452g.soper@soundhouse.co.uk>

In article <5fiN5.503$R.218274@news.uswest.net>,
   Michael Cook <mikecook@cigarpool.com> wrote:
> The close() function will perform the unlock & the close functions...

Great, thanks.

-- 
Geoff Soper
g.soper@soundhouse.co.uk
Take a look at the Soundhouse page http://www.soundhouse.co.uk/


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

Date: Mon, 06 Nov 2000 04:21:22 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: File locking
Message-Id: <slrn90ccdv.73f.tjla@thislove.dyndns.org>

I was shocked! How could Geoff Soper <g.soper@soundhouse.co.uk>
say such a terrible thing:
>My next point is do I need to unlock the files or will closing the files
>have this effect?

Definitely do not unlock the files. This will create the sort of race
condition you are trying to avoid.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
VYARZERZOMANIMORORSEZASSEZANSERAREORSES?


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

Date: Mon, 06 Nov 2000 00:41:55 +0000 (GMT)
From: Geoff Soper <g.soper@soundhouse.co.uk>
Subject: Flock problem
Message-Id: <4a18f0c2a3g.soper@soundhouse.co.uk>

I'm having a problem with a script using flock()
The error given is:
can't lock file: Invalid argument at display.cgi line 168. 

Line 168 is:
flock(EXPIRY, LOCK_EX) || die "can't lock file: $!";

The script is called from
http://www.soundhouse.co.uk/cgi-bin/news/display.cgi?org=rs
and can be viewed as text at http://www.soundhouse.co.uk/geoff/display.txt

I've taken my file locking from the perlopentut pages and can't for the
life of me see what I've done wrong!

Thanks

-- 
Geoff Soper
g.soper@soundhouse.co.uk
Take a look at the Soundhouse page http://www.soundhouse.co.uk/


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

Date: Mon, 06 Nov 2000 01:35:05 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Flock problem
Message-Id: <slrn90c2ma.l2.mgjv@verbruggen.comdyn.com.au>

On Mon, 06 Nov 2000 00:41:55 +0000 (GMT),
	Geoff Soper <g.soper@soundhouse.co.uk> wrote:
> I'm having a problem with a script using flock()
> The error given is:
> can't lock file: Invalid argument at display.cgi line 168. 

You didn't include Fcntl, and you are not running with strict. You
need to do both! One, because you need the LOCK_EX constant, and the
other because it will help you write sane programs. You are also not
using -w or the warnings pragma.

Warnings would have given you the warning:
Argument "LOCK_EX" isn't numeric in flock at ./foo.pl line 7.

Strict would have given you the error:
Bareword "LOCK_EX" not allowed while "strict subs" in use 
	at ./foo.pl line 7.
Execution of ./foo.pl aborted due to compilation errors.

See? Both would have pointed out the problem to you right away. Get
used to using them, all the time.

use strict;
use warnings;
use Fcntl ':flock';

> I've taken my file locking from the perlopentut pages and can't for the
> life of me see what I've done wrong!

You didn't take all of it, though. The perlopentut man page actually
does use Fcntl.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | 
Commercial Dynamics Pty. Ltd.   | What's another word for Thesaurus?
NSW, Australia                  | 


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

Date: Mon, 06 Nov 2000 04:28:57 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: getopt doesn't seem work as expected
Message-Id: <slrn90ccs5.73f.tjla@thislove.dyndns.org>

I was shocked! How could bwlang <bwlang@usa.net>
say such a terrible thing:
>I'm using Getopt:Long
>
>When i call this program with no command line parameters $parsedopts
>comes back with a value of "1".  This does not make sense to me since
>the required argument "-d blastdbname" is required (as designated by
>the d=s bit).  Am I misunderstanding something?

At the bottom of the Getopt::Long Manual:

       GetOptions does not return a false result when an option
       is not supplied

       That's why they're called 'options'.

Put more simply, although the '-d' option requires a value, the '-d'
option is not required itself. Probably you'll be better off checking if
it was passed by hand after calling getopts.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Monogamy is the Western custom of one wife and hardly any mistresses.
		-- H.H. Munro


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

Date: Mon, 06 Nov 2000 01:10:45 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: help w/linux RH6.2 perl script
Message-Id: <pynN5.190$Bf7.170932224@news.frii.net>

In article <8u1mbr$oc8$1@nnrp1.deja.com>,  <wmarvel@my-deja.com> wrote:
>/home/me/foo
>
>#!/usr/bin/perl
>print("this and that\n");
>
>Gives the bash interpreter.
>Yet the "> perl foo" works.
>
>HELP, TIA.
>

did you set the execute bit?

-- 
    This space intentionally left blank


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

Date: Sun, 05 Nov 2000 19:20:15 -0500
From: John D Prokopek <jprokopek@snet.net>
Subject: Re: how to get return value of process
Message-Id: <3A05F93F.D1086A6@snet.net>

Ren,

thank you very much.

john

Ren Maddox wrote:
> 
> John D Prokopek <jprokopek@snet.net> writes:
> 
> > If I run a process within a perl script how can I get the exit value?
> >
> > I am doing something like to following to get the output
> >
> >
> > open STATUS, "./chapname $comp_id  2>&1 |"
> >                               or die "cant fork: $!";
> > while (<STATUS>)
> > {
> >       $logfile = $_;
> >       print $logfile;
> > }
> >
> > I would like the exit value returned by ./chapname
> 
> You need to check $? after closing the filehandle.  See the
> description of close in  perlfunc(1) for the details, but basically,
> something like:
> 
> close STATUS or $! and die "Problem running ./chapname: $!";
> my $result = $?;
> 
> --
> Ren Maddox
> ren@tivoli.com

-- 
John D. Prokopek
jprokopek@snet.net

"The bus came by and I got on
thats when it all began ...."


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

Date: Sun, 05 Nov 2000 19:21:32 -0500
From: John D Prokopek <jprokopek@snet.net>
Subject: Re: how to get return value of process
Message-Id: <3A05F98C.D1441EE1@snet.net>

btw,, 

it looks like you work at tivoli.
did you know john turek?
I used to work with him at tj watson;

thanks again

john

Ren Maddox wrote:
> 
> John D Prokopek <jprokopek@snet.net> writes:
> 
> > If I run a process within a perl script how can I get the exit value?
> >
> > I am doing something like to following to get the output
> >
> >
> > open STATUS, "./chapname $comp_id  2>&1 |"
> >                               or die "cant fork: $!";
> > while (<STATUS>)
> > {
> >       $logfile = $_;
> >       print $logfile;
> > }
> >
> > I would like the exit value returned by ./chapname
> 
> You need to check $? after closing the filehandle.  See the
> description of close in  perlfunc(1) for the details, but basically,
> something like:
> 
> close STATUS or $! and die "Problem running ./chapname: $!";
> my $result = $?;
> 
> --
> Ren Maddox
> ren@tivoli.com

-- 
John D. Prokopek
jprokopek@snet.net

"The bus came by and I got on
thats when it all began ...."


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

Date: Mon, 06 Nov 2000 04:08:59 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: how to sort corresponding arrays?
Message-Id: <v9qN5.193$Bf7.170932224@news.frii.net>
Keywords: browse, forbid, gasify, practicable

In article <3a04a234.5467$135@news.op.net>,
Mark-Jason Dominus <mjd@plover.com> wrote:
>
>See
>
>        http://perl.plover.com/yak/hw2/slide003.html
>

404

-- 
    This space intentionally left blank


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

Date: Sun, 05 Nov 2000 23:07:02 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Looking for idiom for getting value from @ARGV, or a default
Message-Id: <slrn90bq0n.l2.mgjv@verbruggen.comdyn.com.au>

On 05 Nov 2000 14:51:24 -0800,
	Mark Atwood <mra@pobox.com> wrote:
> 
> I've seen somewhere a neat little one line expression idiom using
> "defined", "shift", and "||" that does something like
> 
> $s = shift @ARGV;
> unless (defined($s)) {
>   $s = 'default';
> }
> 
> in less space.

Not entirely possible. There was talk of an operator that would test
for defined-ness, so one could do things like:

    $s = shift @ARGV ?OP? 'default';

but I'm pretty sure it didn't make it in 5.6.0[1]. I believe it was
still mentioned in the RFC's for Perl 6.

> But now I can't find an example. Does anyone have any pointers?

If you really need to test for defined-ness, then you need to use two
statements:

$s = shift @ARGV;
$s = 'default' unless defined $s;

If you're really only interested in $s being false (undefined, 0, "0"
or ""), you can do:

$s = shift @ARGV || 'default';

Martien

[1] It was tentatively going to be called ?? or ???. I just skimmed
perlop and perldelta, but see no reference to it.
-- 
Martien Verbruggen              | 
Interactive Media Division      | For heaven's sake, don't TRY to be
Commercial Dynamics Pty. Ltd.   | cynical. It's perfectly easy to be
NSW, Australia                  | cynical.


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

Date: Sun, 05 Nov 2000 23:24:39 GMT
From: ameen @ dausha . net (Ameen Dausha)
Subject: Re: Looking for idiom for getting value from @ARGV, or a default
Message-Id: <3a05ea39.245213374@news>

On 05 Nov 2000 14:51:24 -0800, Mark Atwood <mra@pobox.com> spat:

[snip]

>$s = shift @ARGV;
>unless (defined($s)) {
>  $s = 'default';
>}

[snip]

$s = shift @ARGV if (@ARGV) || $s = 'default';

Not that I'm an expert in this.



Ben Wilson (a.k.a. Ameen, Last of the Dausha)
____________________________
-"Ever heard of Aristotle . . . Plato . . . Socrates?!"
-"Yes."
-"Morons!"


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

Date: Sun, 5 Nov 2000 19:28:42 -0500
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Looking for idiom for getting value from @ARGV, or a default
Message-Id: <Pine.GSO.4.21.0011051928100.25313-100000@crusoe.crusoe.net>

[posted & mailed]

On Nov 5, Mark Atwood said:

>$s = shift @ARGV;
>unless (defined($s)) {
>  $s = 'default';
>}

  $s = defined($ARGV[0]) ? shift : 'default';

-- 
Jeff "japhy" Pinyan     japhy@pobox.com     http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine            http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc.    http://www.perlarchive.com/
CPAN - #1 Perl Resource  (my id:  PINYAN)        http://search.cpan.org/



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

Date: Sun, 5 Nov 2000 19:24:00 -0500
From: David Coppit <newspost@coppit.org>
Subject: Re: Need suggestions on optimization
Message-Id: <Pine.GSO.4.21.0011051920440.16082-100000@mamba.cs.Virginia.EDU>

[This email doesn't add a whole lot to the discussion. It just reports
the effects of a couple good suggestions.]

On 3 Nov 2000, Ren Maddox wrote:

> >     while ($READ_BUFFER =~ /^From\s.*\d:\d+:\d.* \d{4}/igm)
> 
> Do you really need to match all those digits?  Does the file have
> other lines that start with "From " that are not real From lines?

I dropped them. No appreciable performance increase.

> Right here I start to get the feeling that you could define $/ as
> "\nFrom " and process a message at a time.  The possibility of
> included messages would still need to be handled (assuming that they
> also start with "From "), but that shouldn't be a problem.  I expect
> you would get an appreciable performance improvement from this change
> alone.

Yeah, that dawned on me after I posted. I tried that, and got no
appreciable improvement. :(

> >       my $email = $`;
> >       my $from_line = $&;
> >       my $rest = $';
> 
> The inclusion of these special variables in a script causes *all*
> regexes in the script to save this information, making them all
> slower.  I do not know how significant the impact is (probably minimal
> in this case), but the above recommendation would also eliminate the
> need for them.

I tried replacing this code with $1, $2, $3 matching, but that didn't
speed things up. (And I wasn't using $`, $&, $' elsewhere.) But as you
note, this part is unnecessary anyway.

Regards,
David




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

Date: Mon, 6 Nov 2000 14:13:35 +1000
From: "Leon" <Leon@caresystems.com.au>
Subject: Re: pattern matching across two lines
Message-Id: <R4qN5.16287$SF5.362880@ozemail.com.au>

from what i gather some of the build releases of Mission Possible could do
that very easily...

http://www.lanasoft.com/mp




>Nitin wrote in message <8mb442$61l$1@nnrp1.deja.com>...
>>I have text as follows:
>>
>>foo^M
>>bar
>>
>>in several files. I need to replace this with:
>>
>>foobar
>>
>>How can I match patterns across two lines?
>>
>>Thanks,
>>
>>
>>Sent via Deja.com http://www.deja.com/
>>Before you buy.
>>
>
>
>
>




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

Date: Mon, 06 Nov 2000 13:20:35 +1100
From: Willis Kwok <wkwok@uunet.com.au>
Subject: Perl flock function problem in BSDI 3.0 & 4.0
Message-Id: <3A061573.BCF4AC1@uunet.com.au>

Has anyone had problem with the perl flock () function in BSDI 4.0 ?  It
works on in BSDI 3.0.....
Process hung when tries to read / write a file with flock() function.
Should i close a file before doing flock(FH,8) or after ??

Thanks

Willis



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

Date: Mon, 06 Nov 2000 02:44:56 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Perl flock function problem in BSDI 3.0 & 4.0
Message-Id: <slrn90c6pa.l2.mgjv@verbruggen.comdyn.com.au>

On Mon, 06 Nov 2000 13:20:35 +1100,
	Willis Kwok <wkwok@uunet.com.au> wrote:
> Has anyone had problem with the perl flock () function in BSDI 4.0 ?  It
> works on in BSDI 3.0.....
> Process hung when tries to read / write a file with flock() function.
> Should i close a file before doing flock(FH,8) or after ??

You should just close the file, and not explicitly unlock it. If you
do, you open yourself up to a race condition, where the buffers might
not be flushed yet, but you allow other processes to write to the
file. I believe that in recent Perls this race condition is prevented
by explicitly flushing the file buffers.

However, your process should not hang on unlocking the file. The fact
that it works on BSDI 3 and not on 4 probably means that something
changed in the way the syscalls work on these two platforms. Is there
anything in the man pages?

You're trying to lock a regular file, on a normal file system? How did
you configure Perl when you compiled it? Where's the code that you are
trying to execute?

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | For heaven's sake, don't TRY to be
Commercial Dynamics Pty. Ltd.   | cynical. It's perfectly easy to be
NSW, Australia                  | cynical.


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

Date: Mon, 06 Nov 2000 15:05:19 +1100
From: Willis Kwok <wkwok@uunet.com.au>
Subject: Re: Perl flock function problem in BSDI 3.0 & 4.0
Message-Id: <3A062DFF.54CFD827@uunet.com.au>

thanks for your reply.

I am doing a locking on a regular file but NFS mount file system.
Do you know whether perl 5_003 & 5_004's made any changes to the flock ()
function.  Because i migrated my code to different version of OS & perl.

If i dont do file locking in Perl, can i leave the OS do it for me?

The code is just as simple as below:

sub readdata {
   if (open(DATA,"$datafile")) {
      flock(DATA,2);
      @$r_data = <DATA>;
      flock(DATA,8);
      close(DATA);
   }
   else {
      my_die("Error in subroutine readdata: Can't open $datafile",$!);
   }

   $r_data;
}

Thanks again

Willis

Martien Verbruggen wrote:

> On Mon, 06 Nov 2000 13:20:35 +1100,
>         Willis Kwok <wkwok@uunet.com.au> wrote:
> > Has anyone had problem with the perl flock () function in BSDI 4.0 ?  It
> > works on in BSDI 3.0.....
> > Process hung when tries to read / write a file with flock() function.
> > Should i close a file before doing flock(FH,8) or after ??
>
> You should just close the file, and not explicitly unlock it. If you
> do, you open yourself up to a race condition, where the buffers might
> not be flushed yet, but you allow other processes to write to the
> file. I believe that in recent Perls this race condition is prevented
> by explicitly flushing the file buffers.
>
> However, your process should not hang on unlocking the file. The fact
> that it works on BSDI 3 and not on 4 probably means that something
> changed in the way the syscalls work on these two platforms. Is there
> anything in the man pages?
>
> You're trying to lock a regular file, on a normal file system? How did
> you configure Perl when you compiled it? Where's the code that you are
> trying to execute?
>
> Martien
> --
> Martien Verbruggen              |
> Interactive Media Division      | For heaven's sake, don't TRY to be
> Commercial Dynamics Pty. Ltd.   | cynical. It's perfectly easy to be
> NSW, Australia                  | cynical.



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

Date: 5 Nov 2000 23:14:35 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Perl syntax and beyond (was: Re: Perl style and module searches)
Message-Id: <8u4pkr$1ss$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Abigail
<abigail@foad.org>],
who wrote in article <slrn90bm48.f32.abigail@tsathoggua.rlyeh.net>:
> There are cases where linked lists are faster than arrays. But more
> often in C than in Perl. 

And the principal reason for this rarity may be that it is so damn
hard to implement doubly-linked lists in Perl...  Another reason is
that Perl so damn slow, that the difference between O(n^2) and O(n)
algorithms is not noticable until you finish testing and start
real-life applications...

Ilya


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

Date: Mon, 06 Nov 2000 00:49:14 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Perl syntax and beyond (was: Re: Perl style and module searches)
Message-Id: <slrn90c008.73f.tjla@thislove.dyndns.org>

I was shocked! How could Abigail <abigail@foad.org>
say such a terrible thing:

>Deleting from a linked list is O(n) unless you happen to have a
>pointer to the to be deleted element.

<rant>That's what I meant</rant> I'm leaving this topic now since it
seems to have gotten off the point of what I was originally trying to
say which was that Perl could stand to have some new operators.

Oh and welcome back Abigail, we all missed you :)

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Fortune's real live weird band names #417:

Lawnsmell


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

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


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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

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

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


------------------------------
End of Perl-Users Digest V9 Issue 4817
**************************************


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