[24764] in Perl-Users-Digest
Perl-Users Digest, Issue: 6917 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 26 18:06:08 2004
Date: Thu, 26 Aug 2004 15:05:09 -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 Thu, 26 Aug 2004 Volume: 10 Number: 6917
Today's topics:
exit(), die, ?? (Tony McGuire)
Re: exit(), die, ?? <mritty@gmail.com>
Re: get variables from another file (J. Romano)
Re: get variables from another file <dwall@fastmail.fm>
Re: I Broke a scalar <Joe.Smith@inwap.com>
Re: Larry Wall & Cults <rnichol_rrc@yahoo.com>
Re: Larry Wall & Cults <pete@fenelon.com>
Re: Larry Wall & Cults <dha@panix.com>
Re: Larry Wall & Cults <tor.iver.wilhelmsen@broadpark.no>
Re: Larry Wall & Cults joe@invalid.address
Re: Larry Wall & Cults <monnier@iro.umontreal.ca>
Re: Larry Wall & Cults <jeff@ccvcorp.com>
Re: Larry Wall & Cults (Otto Wyss)
Re: Larry Wall & Cults (Otto Wyss)
Re: Larry Wall & Cults <areiner@tph.tuwien.ac.at>
Newbie Frontier::Daemon problem <lepi_MAKNI_ME_@fly.srk.fer.hr>
Re: Parsing FileName for upload (Tony McGuire)
Re: Parsing FileName for upload <tore@aursand.no>
Re: Parsing FileName for upload <tore@aursand.no>
Re: Parsing FileName for upload ctcgag@hotmail.com
Re: performance surprise -- why? <haltingNOSPAM@comcast.net>
Re: performance surprise -- why? (Anno Siegel)
Re: Perl and DOS I/O (Hemant Kumar)
segmentation fault / threads (Stuart Kendrick)
Re: Simulating the open() command. (Chris Heller)
Re: Substitution (regex?) <ron.parker@povray.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 26 Aug 2004 11:09:32 -0700
From: tony@paradoxcommunity.com (Tony McGuire)
Subject: exit(), die, ??
Message-Id: <f896a829.0408261009.34a943d6@posting.google.com>
New to PERL.
Can you exit from the middle of a script that is handling incoming
data based on IF statements?
I have a simple script for processing incoming uploads. (Thanks,
Tore!)
Based on the input, I'd like to be able to return info back to the
user.
(I have the info on retrieving the input values)
input field: $uniqueid
input field: $filename
if (length $uniqueid<1) {
# build HTML and return to user
}
if (length $filename<1) {
# build HTML and return to user
}
# process everything, since we have the info we need.
So, if certain conditions aren't met, I'd like to bail and return info
back to the user. I realize you can do this with nested if..else
statements; I am hoping I can halt processing and return to the user
if individual 'if' statements resolve to false.
Is this possible in PERL? And if so, can anyone point me to the
methodology I would need?
------------------------------
Date: Thu, 26 Aug 2004 18:19:41 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: exit(), die, ??
Message-Id: <1RpXc.15136$IO1.1808@trndny03>
"Tony McGuire" <tony@paradoxcommunity.com> wrote in message
news:f896a829.0408261009.34a943d6@posting.google.com...
> New to PERL.
First lesson: The language is Perl. The interpeter is perl. Never ever PERL.
(see also: perldoc -q difference )
> Can you exit from the middle of a script that is handling incoming
> data based on IF statements?
There's no such thing as an IF statement. Case matters.
>
> I have a simple script for processing incoming uploads. (Thanks,
> Tore!)
>
> Based on the input, I'd like to be able to return info back to the
> user.
> (I have the info on retrieving the input values)
>
<snip>
>
> So, if certain conditions aren't met, I'd like to bail and return info
> back to the user. I realize you can do this with nested if..else
> statements; I am hoping I can halt processing and return to the user
> if individual 'if' statements resolve to false.
>
> Is this possible in PERL? And if so, can anyone point me to the
> methodology I would need?
You should always make an attempt before asking if it's possible. You clearly
already know that the way to end a script is with either exit() or die() (based
on the subject of your post). So what happened when you tried putting exit() or
die() inside an if block?
Paul Lalli
------------------------------
Date: 26 Aug 2004 11:22:29 -0700
From: jl_post@hotmail.com (J. Romano)
Subject: Re: get variables from another file
Message-Id: <b893f5d4.0408261022.3531e874@posting.google.com>
Rocky <PerlGuRu2b@bobotheclown.org> wrote in message news:<pan.2004.08.26.13.52.50.870402@bobotheclown.org>...
>
> My boss wants to put all the recipients and hostnames in another file so
> that we can change it per site.
> here is what I tried
>
> #!/usr/bin/perl
> use strict;
> use warnings;
> use Net::SMTP;
> require ('hello.pl');
[SOME CODE SNIPPED]
>
> hello.pl looks like this:
>
> my $recipient1 = 'EMAIL1 HERE';
> my $recipient2 = 'EMAIL2 HERE';
> my $recipient3 = 'EMAIL3 HERE';
> my $recipient4 = 'EMAIL4 HERE';
> my $recipient5 = 'EMAIL5 HERE';
> my $mailfrom = 'MAILFROM HERE';
> my $fromaddress = "ISEETHEFROM HERE";
>
> The problem is that the main script does not see the recipients from the
> file. I am sure this is because of the way I have it scoped, but I know
> no other way. Any pointers will be appreciated.
Dear Rocky,
You are right when you think that it is the way you have it scoped.
The "my" keyword makes a variable visible only to one file. To let
it have visibility outside the file, change "my" to "our".
Also, I recommend that you end your "hello.pl" script with the
following line:
1;
This will prevent "require" from failing if the last variable in
"hello.pl" is set to zero (or an empty string).
You might even want to consider changing the name of "hello.pl" to
"hello.pm" since "hello.pl" is not meant to be executed directly.
That way, you can read in the "hello.pm" file just by typing:
use hello;
I hope this helps, Rocky.
-- Jean-Luc
------------------------------
Date: Thu, 26 Aug 2004 18:47:31 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: get variables from another file
Message-Id: <Xns95519678789FCdkwwashere@216.168.3.30>
Rocky <PerlGuRu2b@bobotheclown.org> wrote in message
<news:pan.2004.08.26.13.52.50.870402@bobotheclown.org>:
> my $recipient1 = 'EMAIL1 HERE';
> my $recipient2 = 'EMAIL2 HERE';
> my $recipient3 = 'EMAIL3 HERE';
> my $recipient4 = 'EMAIL4 HERE';
> my $recipient5 = 'EMAIL5 HERE';
The original problem has been answered by other posters, so I'll ignore
it.
The quoted code is a red flag: a sequence of numbered scalars like that
suggests you should be using an array instead. Consider how your code
might change if you wanted to add a 6th recipient, and how using an
array could make that easier.
Mark-Jason Dominus wrote a series of "Red Flag" articles that you may
find interesting. Links to them are at http://perl.plover.com/.
------------------------------
Date: Thu, 26 Aug 2004 20:01:21 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: I Broke a scalar
Message-Id: <lkrXc.320466$%_6.318635@attbi_s01>
no@no.invalid wrote:
> { 'sessions' => {
> 'IO::Socket::INET=GLOB(0x1a4
> c120)' => $VAR1 },
That part is completely screwed up; it can never work that way.
Please explain what you're trying to do.
Please explain what you mean by "I Broke a scalar"; that makes no sense.
-Joe
------------------------------
Date: Thu, 26 Aug 2004 13:09:31 -0500
From: Reid Nichol <rnichol_rrc@yahoo.com>
Subject: Re: Larry Wall & Cults
Message-Id: <KGpXc.2846$MR2.15519@news1.mts.net>
John Savard wrote:
> They did, though, have to select from the German people those who
> would operate the concentration camps.
Which where the afraid ones or the ones that actually believed in him
for one reason or another. Yes, some people didn't need brain-washing
to believe him. I know it's a radical idea that some people are racist,
but it true!
> As for the masses, it was enough that they were afraid to try to do
> anything to stop it.
Perhaps you should look into the history books a little closer. There
was this thing call the resistance in *all* the countries you know, not
to mention the anti-nazi publications in the papers during his rise to
power. And without those resistance fighters, the allies might have
failed in there endeavour.
Why did you even give an actual reply to this guy anyway?
------------------------------
Date: Thu, 26 Aug 2004 19:25:42 +0100
From: Pete Fenelon <pete@fenelon.com>
Subject: Re: Larry Wall & Cults
Message-Id: <6v9lgc.9i2.ln@fenelon.com>
In alt.folklore.computers R Baumann <rynt@9yahoo.com> wrote:
> In this context --- This is the STUPIDEST thing I've ever heard. What a
> maroon! What a Trollup!
>
He doesn't quite win, there's one regular afc troll who narrowly edges
him out... but I won't mention his name because that tends to invoke
him. ;)
pete
--
pete@fenelon.com "there's no room for enigmas in built-up areas"
------------------------------
Date: Thu, 26 Aug 2004 18:37:43 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: Larry Wall & Cults
Message-Id: <slrncisbfn.fki.dha@panix2.panix.com>
On 2004-08-26, Rich Teer <rich.teer@rite-group.com> wrote:
> On Thu, 26 Aug 2004, Tor Iver Wilhelmsen wrote:
>
>> Rich Teer <rich.teer@rite-group.com> writes:
>>
>> > I think you're getting confused with the Blue Öyster Cult.
>>
>> Actually, there is also The Cult, a British band that lasted from
>> 1984-1995.
>
> I belive the Cult (She Sells Sanctuary, etc.) is another manfifestation
> of the Blue Öyster Cult.
Not in the sense of being any of the same people.
Perhaps you mean that there is some sort of jungian archetype "cult" of
which these are both examples. :-)
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
One should never say such things, it's like wearing red overalls
in Pamplona.
- Jarkko Hietaniemi
------------------------------
Date: 26 Aug 2004 20:50:06 +0200
From: Tor Iver Wilhelmsen <tor.iver.wilhelmsen@broadpark.no>
Subject: Re: Larry Wall & Cults
Message-Id: <uekltloo1.fsf@broadpark.no>
Rich Teer <rich.teer@rite-group.com> writes:
> I belive the Cult (She Sells Sanctuary, etc.) is another manfifestation
> of the Blue Öyster Cult.
Does not seem so: Founding member Ian Astbury is not listed as member
of any other groups, for instance.
http://www.allmusic.com/cg/amg.dll?p=amg&sql=11:5qktk6gx9kr3~T1
------------------------------
Date: Thu, 26 Aug 2004 19:10:54 GMT
From: joe@invalid.address
Subject: Re: Larry Wall & Cults
Message-Id: <m3brgxvhoj.fsf@invalid.address>
xah@xahlee.org (Xah Lee) writes:
> Larry Wall and Cults
> (Lazyness, Impatience and Hubris)
> 200012
[ Poor standup comedy deleted ]
> These brain-washing phenomenon, are not limited to fanatical
> life-and-death or otherwise dire beliefs. You see it work in all
> manners of human thought in the general sense. From culture formation
> to fashion to commercialism. Surely you have heard of Adolf Hitler
Godwin! In the first post of the thread too...
Joe
--
If you don't think too good, don't think too much
- Ted Williams
------------------------------
Date: Thu, 26 Aug 2004 19:20:26 GMT
From: Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Re: Larry Wall & Cults
Message-Id: <jwv7jrlyaee.fsf-monnier+comp.unix.programmer@gnu.org>
> I'm starting my own cult to exterminate morons on this earth.
Sounds suicidal to me,
Stefan
------------------------------
Date: Thu, 26 Aug 2004 13:09:32 -0700
From: Jeff Shannon <jeff@ccvcorp.com>
Subject: Re: Larry Wall & Cults
Message-Id: <10isgqrfbmnc26b@corp.supernews.com>
Rich Teer wrote:
>On Thu, 26 Aug 2004, Tor Iver Wilhelmsen wrote:
>
>
>
>>Rich Teer <rich.teer@rite-group.com> writes:
>>
>>
>>
>>>I think you're getting confused with the Blue Öyster Cult.
>>>
>>>
>>Actually, there is also The Cult, a British band that lasted from
>>1984-1995.
>>
>>
>
>I belive the Cult (She Sells Sanctuary, etc.) is another manfifestation
>of the Blue Öyster Cult.
>
>
No, the two are totally unrelated. (One was American (New York) and led
by Eric Bloom, the other was British (London) and led by Ian Astbury.)
However, The Cult did have an earlier incarnation as Southern Death Cult.
Jeff Shannon
Technician/Programmer
Credit International
------------------------------
Date: Thu, 26 Aug 2004 23:01:46 +0200
From: otto.wyss@orpatec.ch (Otto Wyss)
Subject: Re: Larry Wall & Cults
Message-Id: <1gj4z06.14nwnzs1d0kno4N%otto.wyss@orpatec.ch>
Tassilo v. Parseval <tassilo.von.parseval@rwth-aachen.de> wrote:
> It would, if anyone could take Xah Lee Loo seriously. But really, no one
> can. He's more like the court jester, creeping out of the dark every so
> and so months. We're all very much enjoying his sporadic shows. Really.
>
> ;-)
>
No offense but could you add some references so anyone can make up is
own opinion?
O. Wyss
--
How to enhance your code, see "http://freshmeat.net/projects/wxguide/"
------------------------------
Date: Thu, 26 Aug 2004 23:01:47 +0200
From: otto.wyss@orpatec.ch (Otto Wyss)
Subject: Re: Larry Wall & Cults
Message-Id: <1gj5eeq.gb3dk41wup9zwN%otto.wyss@orpatec.ch>
Xah Lee <xah@xahlee.org> wrote:
> this earth. Two things are on the top of my agenda: Unixism and Perl.
>
What you mean with Unixism?
O. Wyss
--
How to enhance your code, see "http://freshmeat.net/projects/wxguide/"
------------------------------
Date: 26 Aug 2004 23:11:55 +0200
From: Albert Reiner <areiner@tph.tuwien.ac.at>
Subject: Re: Larry Wall & Cults
Message-Id: <vw8fz6938pw.fsf@berry.phys.ntnu.no>
["Michiel Borkent" <borkent@cs.utwente.nl>, Thu, 26 Aug 2004 13:35:38 +0200]:
> LISP and Esperanto: my favorite languages.
Ankaux miaj - krom, eble, ankaux la Haskella.
Stranga koncentrigxo de verdlingvanoj cxe cll, cxu ne?
Albert.
------------------------------
Date: Thu, 26 Aug 2004 21:30:43 +0200
From: lepi <lepi_MAKNI_ME_@fly.srk.fer.hr>
Subject: Newbie Frontier::Daemon problem
Message-Id: <cgldis$s8a$1@bagan.srce.hr>
Hello,
Maybe this isn't the right place to ask this question, 'couse maybe it
has nothing to do with Frontier::RPC, but anyhow I will ask.
Question is about this example
http://xmlrpc-c.sourceforge.net/xmlrpc-howto/xmlrpc-howto-perl-server.html
I started it on one computer in my LAN, and tried client from the other
one. There is no firewalls. All the time I'm getting HTTP Error 403
-Forbidden on the client. I can't figure out why?? Maybe this is newbie
thing. :)
Anyhow, do I need web server on the computer where I'm running this
XMLRPC server?? (It is running on my computer) Is this program acting
like standalone server on port 8080 or it uses Apache (or something)???
Thank you
Tomislav
------------------------------
Date: 26 Aug 2004 11:34:56 -0700
From: tony@paradoxcommunity.com (Tony McGuire)
Subject: Re: Parsing FileName for upload
Message-Id: <f896a829.0408261034.74deb07b@posting.google.com>
Brian McCauley <nobull@mail.com> wrote in message news:<cgkg1f$ai1$1@sun3.bham.ac.uk>...
> Tore Aursand wrote:
> >
> > Use the File::Basename module, for God's sake!
>
> Bzzzt! That doesn't help. File::Basename parses (by default) acording
> to the local OS's syntax. Since we're talking here about filnames
> comming from a remote computer running a potentially different OS this
> is worse than useless.
Well, initial testing indicates that File::Basename does work - at
least in my situation.
I have Apache running on Windows.
That routine correctly parses the [remote] path, name and extension
from a system running on Linux with Opera.
While the path is '.\', that's OK since I'm throwing out the remote
path anyway.
And the filename and extension do parse correctly.
In reading up on the fileparse() routine, it says that if you don't
set the OS type, the routine uses the incoming connection and attempts
to set the OS-type based on that.
At least in limited testing, it correctly parses Opera/Linux as well
as IE/Windows.
So, while not perfect perhaps (time will tell), it appears to be
working.
Please correct my findings if they aren't correct. I'd rather do more
work now and put up a working system than have it fall apart after
people are trying to use it.
------------------------------
Date: Thu, 26 Aug 2004 20:36:03 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: Parsing FileName for upload
Message-Id: <pan.2004.08.26.18.36.02.490330@aursand.no>
On Thu, 26 Aug 2004 10:41:42 -0700, Tony McGuire wrote:
>> Still, I don't understand. Why can't you use File::Basename? Am I
>> misunderstanding something here?
> THANK YOU for pointing this out.
No. Please don't thank me, as I was severely wrong. :) I think I must
have been thinking "backwards" or something, 'cause File::Basename will
only work (correctly) for the server OS (ie. not the client's OS, which is
the important part here).
Still, I'm quite puzzled by the fact that it doesn't seem to be a module
(or a reasonable way) to solve this. Why is that?
One approach which _might_ work, is to read the client's HTTP_USER_AGENT
and try to figure out what OS the client is running, and then feed
File::Basename with that information.
It should work, but I don't know how "valid" this "solution" is.
--
Tore Aursand <tore@aursand.no>
"What we see depends mainly on what we look for." (Sir John Lubbock)
------------------------------
Date: Thu, 26 Aug 2004 21:46:26 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: Parsing FileName for upload
Message-Id: <pan.2004.08.26.19.46.25.810257@aursand.no>
On Thu, 26 Aug 2004 11:34:56 -0700, Tony McGuire wrote:
>>> Use the File::Basename module, for God's sake!
>> Bzzzt! That doesn't help. File::Basename parses (by default) acording
>> to the local OS's syntax. Since we're talking here about filnames
>> comming from a remote computer running a potentially different OS this
>> is worse than useless.
> Well, initial testing indicates that File::Basename does work - at least
> in my situation.
>
> [...]
>
> In reading up on the fileparse() routine, it says that if you don't set
> the OS type, the routine uses the incoming connection and attempts to
> set the OS-type based on that.
Where does it say that? The documentation clearly states that if one
haven't set the filesystem type (using 'fileparse_set_fstype()'), the
'fileparse()' function will use $^O, which is a special variable
containing the current OS name.
It returns the OS name for the computer where the CGI script is running,
and not the OS name of the client machine that is requesting the CGI
script.
> Please correct my findings if they aren't correct.
Try this simple script (untested):
#!/usr/bin/perl
#
use strict;
use warnings;
use Data::Dumper;
use File::Basename qw( fileparse );
my @paths = ('c:\Documents and Settings\username\filename.ext',
'/home/username/filename.ext',
'Doc_Root:[username]:filename.ext');
foreach ( @paths ) {
my @info = fileparse( $_ );
print Dumper( \@info );
}
Gunnar: Please respect my use of Data::Dumper in this case also. :)
--
Tore Aursand <tore@aursand.no>
"It's not so much what you have to learn if you accept weird theories,
it's what you have to unlearn." (Isaac Asimov)
------------------------------
Date: 26 Aug 2004 20:20:00 GMT
From: ctcgag@hotmail.com
Subject: Re: Parsing FileName for upload
Message-Id: <20040826162000.894$Hl@newsreader.com>
Tore Aursand <tore@aursand.no> wrote:
> On Thu, 26 Aug 2004 10:41:42 -0700, Tony McGuire wrote:
> >> Still, I don't understand. Why can't you use File::Basename? Am I
> >> misunderstanding something here?
>
> > THANK YOU for pointing this out.
>
> No. Please don't thank me, as I was severely wrong. :) I think I must
> have been thinking "backwards" or something, 'cause File::Basename will
> only work (correctly) for the server OS (ie. not the client's OS, which
> is the important part here).
I'm not sure that that is so important. I assume that he is using the
basename as the basis of a filename to store the file locally. In that
case, the most important thing is probably that the basename that you
obtain doesn't contain things that are directory separators on the server's
filesystem. Whether or not they are separators on the client's filesystem
is probably of lesser importance. If some bizarre OS uses q as a separator
and tells me the file is 'qetcqpasswd', and I leave it like that, well,
that is no skin off my nose.
> Still, I'm quite puzzled by the fact that it doesn't seem to be a module
> (or a reasonable way) to solve this. Why is that?
Because you generally let the server do the server's job and the client do
the client's job. Why make the server gratuitously psychoanalyze the
client?
If all you want is something to name the file which serves
as a mnemonic for the person who loaded it, then I'd use something like:
$name =~ /([a-zA-Z0-9._]+)$/ or die "Bad name $name";
my $newname=$1;
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Thu, 26 Aug 2004 21:04:30 GMT
From: Joe Davison <haltingNOSPAM@comcast.net>
Subject: Re: performance surprise -- why?
Message-Id: <m2sma9ipba.fsf@Jupiter.local>
Here's one weirdness!
use English;
I created a file with 400_000 chars from the big file I use, to ease
comparison with Anno's original.
Here's the output form Anno's script on my system:
Rate substitute indexing globmatch
substitute 103/s -- -22% -49%
indexing 133/s 28% -- -35%
globmatch 204/s 97% 54% --
time: 4.94s user 0.99s system 91% cpu 6.500 total
Here's the output from my current version, without "Use English;"
Rate indexing substitute globmatch
indexing 125/s -- -12% -32%
substitute 142/s 13% -- -23%
globmatch 184/s 47% 30% --
time: 3.75s user 1.05s system 91% cpu 5.257 total
And here's the output from my current versin, with "Use English;"
Rate globmatch substitute indexing
globmatch 8.00/s -- -93% -94%
substitute 113/s 1314% -- -10%
indexing 125/s 1466% 11% --
time: 2.70s user 1.54s system 90% cpu 4.685 total
And, to make that more believable, here's the diff between my two
versions:
=================== diff AnnosProg1.pl AnnosProg5.pl=======
4a5,6
> use English;
>
19d20
<
23,24c24,25
< $whatItWas = $/;
< undef $/;
---
> $whatItWas = $INPUT_RECORD_SEPARATOR;
> undef $INPUT_RECORD_SEPARATOR;
28c29
< $/ = $whatItWas;
---
> $INPUT_RECORD_SEPARATOR = $whatItWas;
=============================================================
And here's the source for AnnosProg1.pl -- the one without use English.
===================================
#!/usr/bin/perl
use strict; use warnings; $| = 1;
#use Vi::QuickFix;
use Benchmark ':all';
use constant SIZE => 400_000;
my ($ifile,$whatItWas);
my ($str,$fsz);
my $sequence = 'AGTACT';
$ifile = shift @ARGV;
unless (open INPUT, $ifile) {
print STDERR "Can't open $ifile: $! \n";
}
# Suck the whole ifile in for processing
$str=<INPUT>; #toss the first record (the >CHR1v03212003 line in one case...)
$whatItWas = $/;
undef $/;
$fsz = -s $ifile;
$str = " " x $fsz; # preallocate filesized string!!
$str = <INPUT>;
$/ = $whatItWas;
close INPUT;
# Now do what we came for
$str =~ s/\n//gs; # delete newlines
goto bench;
print "globmatch: ", globmatch(), "\n";
print "indexing: ", indexing(), "\n";
print "substitute: ", substitute(), "\n";
exit;
bench:
cmpthese( -1, {
globmatch => 'globmatch',
substitute => 'substitute',
indexing => 'indexing',
});
######################################################################
sub globmatch {
my @indices;
$_ = $str;
push @indices, pos while /$sequence/g;
scalar @indices;
}
sub substitute {
$_ = $str;
s/$sequence/\n$sequence/g;
}
sub indexing {
$_ = $str;
my @indices;
my $pos = 0;
while ( 1 ) {
last if ( $pos = index( $_, $sequence, $pos)) < 0;
push @indices, $pos;
$pos += length $sequence;
}
scalar @indices;
}
------------------------------
Date: 26 Aug 2004 21:25:28 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: performance surprise -- why?
Message-Id: <cglkg8$bmd$1@mamenchi.zrz.TU-Berlin.DE>
Joe Davison <haltingNOSPAM@comcast.net> wrote in comp.lang.perl.misc:
[shortened]
> Here's one weirdness!
>
> use English;
>
> I created a file with 400_000 chars from the big file I use, to ease
> comparison with Anno's original.
>
> Here's the output form Anno's script on my system:
> globmatch 204/s
>
> Here's the output from my current version, without "Use English;"
> globmatch 184/s
>
> And here's the output from my current versin, with "Use English;"
> globmatch 8.00/s
"Performance surprise" indeed. Something is dreadfully wrong there.
The only reason that hasn't come up earlier is because nobody uses
the English module. Well, sorry, almost nobody :)
Time for a serious bug fix. Or to deprecate "English" officially.
Anno
------------------------------
Date: 26 Aug 2004 13:06:39 -0700
From: kumarh@gmail.com (Hemant Kumar)
Subject: Re: Perl and DOS I/O
Message-Id: <878e8c25.0408261206.7aca483a@posting.google.com>
Thank you for the response. I used Open2 and faced issues with output
buffering on the C side. My program hangs (I believe waiting for the
input which will never come since its waiting for the output to give
that precious character)
It works well when I explicitly flush buffers in the example using
fflush (alas I don't have the source for the C program that I really
need to use). Next stop Expect package.
Thanks,
Hemant
<snip>
> The standard answer is IPC::Open2, but I don't know how well this will
> work under Win32. You may want to try Win32::Process instead.
>
> IME, getting DOS programs to behave nicely is Very Difficult: it is
> usually easier to arrange things so you can just do
>
> system "dosprog.exe < input > output";
>
> and process the results: it looks like this isn't possible in your case,
> though.
------------------------------
Date: 26 Aug 2004 14:29:12 -0700
From: skendric@fhcrc.org (Stuart Kendrick)
Subject: segmentation fault / threads
Message-Id: <62dbf7f1.0408261329.2d40a27b@posting.google.com>
has anyone developed any tricks for spawning lots of threads?
i'm using perl 5.8.5, making use of threads ... i'd like to spawn
several hundred at a time (i've written them to go off and perform
tasks which take a long time ... like perform nessus scans of every
active IP address on a subnet ... )
more often than not, the master thread crumps with a Segmentation
Fault, after spawning ... a few dozen. rather unpredictable, actually
-- sometimes, the whole routine succeeds, spawning several hundred
threads and running them just fine. sometimes, it crumps after
spawning a few ... sometimes after spawning a few dozen ... i don't
see a rhythym yet to the behavior.
i've found that inserting a delay ("sleep 10;" for example) between
spawning events generally increases the number of threads i can launch
before the Segementation Fault occurs. has anyone developed any other
tricks? i realize that threading is new in Perl ... but i find it so
useful, that i'm using it already, despite this wart, in a variety of
applications.
#!/usr/bin/perl
use strict;
use warnings;
use threads;
use threads::shared;
use Thread::Running qw(running);
[...]
--sk
stuart kendrick
fhcrc
------------------------------
Date: 26 Aug 2004 13:10:10 -0700
From: tomaco@gmail.com (Chris Heller)
Subject: Re: Simulating the open() command.
Message-Id: <f9630e2c.0408261210.701c7bb3@posting.google.com>
Well,
I managed to answer my own question and solve the problem.
It was a case of not using qualify_to_ref() fully.
As you see my examples all do something like:
qualify_to_ref($fh);
when they really needed to be this:
qualify_to_ref($fh, scalar caller);
That makes all the difference.
Thanks for everyone who suggested solutions to my problem, my
understanding of Perl is a little greater now.
-Chris
------------------------------
Date: Thu, 26 Aug 2004 13:03:34 -0500
From: Ron Parker <ron.parker@povray.org>
Subject: Re: Substitution (regex?)
Message-Id: <slrncis9fm.896.ron.parker@mail.parkrrrr.com>
On Thu, 26 Aug 2004 13:51:33 -0400, Lou Moran wrote:
> s/<key>Album</key><string>(\d+)(\s)-(\s)/<key>Album</key><string>/
^ this / ends the first part of the substitution
^ this / ends the substitution.
You need to either escape that / in "/key" or you need to use a different
delimiter.
--
plane{-z,-3normal{crackle scale.2#local a=5;#while(a)warp{repeat x flip x}rotate
z*60#local a=a-1;#end translate-9*x}pigment{rgb 1}}light_source{-9red 1rotate 60
*z}light_source{-9rgb y rotate-z*60}light_source{9-z*18rgb z}text{ttf"arial.ttf"
"RP".01,0translate-<.6,.4,.02>pigment{bozo}}light_source{-z*3rgb-.2}//Ron Parker
------------------------------
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 V10 Issue 6917
***************************************