[19630] in Perl-Users-Digest
Perl-Users Digest, Issue: 1825 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 26 18:10:51 2001
Date: Wed, 26 Sep 2001 15:10:17 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1001542216-v10-i1825@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 26 Sep 2001 Volume: 10 Number: 1825
Today's topics:
launching acrobat on Win32 <clarke__@__hyperformix.com>
Re: Managing Child Processes (Kevin J. Schmidt)
Re: MIME::Lite problem <bill02115@hotmail.com>
Re: Net::FTP help for login & script <dtweed@acm.org>
Re: Net::FTP help for login & script <ldk006@email.mot.com>
Re: non-persistent cookies management <simon.oliver@umist.ac.uk>
opening a file <inna@raykhman.com>
Re: opening a file (David Wall)
Re: opening a file <mjcarman@home.com>
Re: Peek and Poke on Perl? <nospam-abuse@ilyaz.org>
Re: Peek and Poke on Perl? <gamtci1@mpinet.net>
Re: Peek and Poke on Perl? <gamtci1@mpinet.net>
Re: Peek and Poke on Perl? <bart.lateur@skynet.be>
Perl running slow... (Adam)
Re: Reading from HTML <jurgenex@hotmail.com>
Re: sendmail gadget works on one server, not on another <stevea@wrq.com>
Re: sendmail gadget works on one server, not on another <joe+usenet@sunstarsys.com>
Re: Setting max. values (cpu/ram usage) for mod_perl sc <nospaming@gmx.net>
Re: Single line if Statement <whatever@nevermind.invalid>
String Comparison Problem (Matt Uhrich)
Re: String Comparison Problem <jurgenex@hotmail.com>
Re: String Comparison Problem <ren@tivoli.com>
Re: time and win32 perl nobull@mail.com
Re: time and win32 perl <inna@raykhman.com>
Re: Transforming HTML nobull@mail.com
Using in/output ports within perl. <robvitters@hotmail.com>
Re: Using in/output ports within perl. <tsee@gmx.net>
Re: Using in/output ports within perl. <tsee@gmx.net>
Re: Werte aus einem Array =?iso-8859-1?q?l=F6schen?= <tony_curtis32@yahoo.com>
Werte aus einem Array löschen <info@gummipuppen.de>
Re: What does ||= do ? (Miko O'Sullivan)
What's wrong with this pack() line? (Stan Brown)
Re: What's wrong with this pack() line? nobull@mail.com
Re: who said this? (Tim Hammerquist)
Re: XML::Writer question... how to write output to file (Malcolm Dew-Jones)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 26 Sep 2001 16:23:34 -0500
From: "Allan" <clarke__@__hyperformix.com>
Subject: launching acrobat on Win32
Message-Id: <sHrs7.944$bL5.423399@news.uswest.net>
I have been trying to find a way to launch the Acrobat reader to view
a PDF file. If I use
system ("test.pdf")
acrobat comes up but my application hangs until its closed. I have
not found any variation that works, including
system ("start test.pdf")
system ('start','test.pdf')
system ("cmd.exe /c start test.pdf")
Anyone have any clues on how to start acrobat reader on a file
without hanging and without explicitly knowing the path to the
acrobat exe?
Allan
------------------------------
Date: 26 Sep 2001 14:46:46 -0700
From: kschmidt@mindspring.com (Kevin J. Schmidt)
Subject: Re: Managing Child Processes
Message-Id: <92541e99.0109261346.3f239018@posting.google.com>
Ok, here is the basic program
1: #!/usr/bin/perl
2:
3: $SIG{CHLD} = \&REAPER;
4:
5: sub REAPER {
6: my $stiff;
7: while ($stiff = waitpid(-1, &WNOHANG) > 0) {
8: #do something
9: }
10: $SIG{CHLD} = \&REAPER;
11: }
12:
13: sub doSomething {
14:
15: # this is the routine that is called by each child. It runs some
16: # system commands and then finally runs exec(). Checks are done
17: # prior to the exec() call, and if any fail, this routine returns
18: }
19:
20: foreach $host (sort keys %hostList) {
21: unless ($child = fork()) {
22: # child
23: die "cannot fork: $!" unless defined $child;
24: doSomething();
25: exit;
26: } push @pids, $child;
27: }
28:
29: #parent
30: while(1) {
31:
32: # process data, etc.
33: }
Now, if all the children get to the point where they can call exec(),
then all is well and the parent makes it to line 29 and does its
thing. If any of the children exit, i.e. they return (due to the host
being down, etc.) and exit on line 25 is called then the parent never
makes it to line 29. It seems to sit in lines 20-27 without doing
anything. Since I keep track of all pids (@pids), I can call waitpid
with each pid and determine which one died, but that still doesn't
explain why the parent hands when any children exit.
Hopefully I've provided enough info in this post. :-)
Thanks,
-Kevin
nobull@mail.com wrote in message news:<u9r8stvqr3.fsf@wcl-l.bham.ac.uk>...
> kschmidt@mindspring.com (Kevin J. Schmidt) writes:
>
> > ... am unable to get this hanging problem fixed with the right
> > combination of wait, waitpid, and $SIG{CHLD} code. The basic structure
> > of my code is as follows:
>
> [snip]
>
> > Obviously I left out the calls to wait, waitpid, etc., mainly because
> > I'm not sure if I have them in the right places or not.
>
> So let's get this clear... you have deliberately left out the bit of
> your code where you think the problem is? Like, uh?
>
> Actually I think despite your best efforts you have failed to not give
> us sufficient information (sic). Your problem is that you don't check
> that the fork() succeded. Consider what your code will do if fork() fails?
>
> > To recap, I'm trying to do the following:
> >
> > 1. fork many children from the parent (this works)
> > 2. the parent doesn't care if any children die (exit). It should
> > continue processing as normal, i.e. make it to its infinite loop (this
> > doesn't work)
> > 3. if a child does die, the parent needs to be made aware of that and
> > re-fork a new child. The parent needs to somehow get a hold of the PID
> > of the dead child, since a specific child is responsible for getting
> > log data from a single host. I create a hash of PID to host mappings,
> > and I need to make sure that the new child knows which host to talk
> > to.
> >
> > If anyone can help me with numbers 2 and 3, I would greatly appreciate
> > it.
>
> Well doing 2 is trivial - simply don't not do it. The way to ignore
> something is not to do anything about it.
>
> To do 3 then put a waitpid(-1,&WNOHANG) in your polling loop to find
> out which children have failed.
------------------------------
Date: 26 Sep 2001 13:05:10 -0400
From: bill <bill02115@hotmail.com>
Subject: Re: MIME::Lite problem
Message-Id: <9ot1s6$nb6$1@panix3.panix.com>
In <slrn9r3mt2.ecd.vek@pharmnl.ohout.pharmapartners.nl> vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse) writes:
>On 26 Sep 2001 09:00:08 -0400,
> bill <bill02115@hotmail.com> wrote:
>> < pdf attachment >
>>
>>Everything works fine, including the attachment, but, at the receiving
>>end, the e-mail (as presented by Eudora) shows an unsightly header of
>>directives, like this:
>>
>> Content-Disposition: inline
>> Content-Length: 326
>> Content-Transfer-Encoding: binary
>> Content-Type: text/plain
>>
>> Dear Dr. Foo:
>>
>> < etc. >
>>
>What do you get if you ask MIME::Lite to print out the message instead
>of mailing it?
It prints:
Content-Transfer-Encoding: binary
Content-Type: multipart/mixed; boundary="_----------=_1001523516135880"
MIME-Version: 1.0
X-Mailer: MIME::Lite 2.117 (F2.6; B2.12; Q2.03)
Date: Wed, 26 Sep 2001 16:58:36 UT
From: drfoo@some.domain.com
To: drbar@some.other.domain.com
Subject: Schedule
Reply-To: drquux@some.domain.com
This is a multi-part message in MIME format.
--_----------=_1001522175134000
Content-Disposition: inline
Content-Length: 326
Content-Transfer-Encoding: binary
Content-Type: text/plain
Dear Dr. Foo:
I tried the following alternative code in my script:
my $msg = new MIME::Lite(From => FROM,
To => $to,
Subject => SUBJECT,
'Reply-To' => REPLY_TO,
Type => 'TEXT',
Data => "${address}\n\n${text}"
);
$msg->attach(Type => 'application/pdf',
Path => PATH,
Filename => PDF_FILE,
Disposition => 'attachment');
but got pretty much the same results (the only difference is that the
line "X-Mailer: MIME::Lite 2.117 (F2.6; B2.12; Q2.03)" as the ninth
line instead as of the fourth).
In contrast to the output of MIME::Lite, Eudora produces:
X-Sender: yourstruly@my.domain
Date: Wed, 26 Sep 2001 12:53:10 -0400
To: drbar@some.other.domain.com
From: drfoo@some.domain.com
Subject: Schedule
Content-Type: multipart/mixed;
boundary="=====================_79226521==_"
--=====================_79226521==_
Content-Type: text/plain; charset="us-ascii"; format=flowed
Dear Dr. Foo:
Thanks,
bill
------------------------------
Date: Wed, 26 Sep 2001 17:06:37 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: Net::FTP help for login & script
Message-Id: <3BB209D6.BF7688C7@acm.org>
Are you sure you want FTP and not Telnet?
-- Dave Tweed
------------------------------
Date: Wed, 26 Sep 2001 10:53:12 -0400
From: David Kowal <ldk006@email.mot.com>
Subject: Re: Net::FTP help for login & script
Message-Id: <3BB1EBD8.1F1F3187@email.mot.com>
I may not have been clear on my question - I need to basically run remotely su <password> to
authenticate.
David Kowal wrote:
> Hi,
>
> I've a question as how to do the following:
>
> 1) after successfully logging to a remote server using $ftp->login('username','password'), I then to
> to run a UNIX script (basically a version of su) where I need to supply the above password. After I
> have authenticated as this user, I need to do some file manipulation using the system 'command'. Any
> samples or links of reference would be helpful.
>
> BTW - This is all being done on UNIX boxes running SunOS and HP-UX.
>
> Regards,
> DaveK
> --
> -
> *******************************************
> David E. Kowal
> Vanguard Managed Solutions
> SCM Engineering/Administration
> 575 West Street, Mansfield, MA 02048
> Email: LDK006@email.mot.com
> Phone: (508) 261-5649 / Fax: (508) 261-4545
> *******************************************
--
-
*******************************************
David E. Kowal
Vanguard Managed Solutions
SCM Engineering/Administration
575 West Street, Mansfield, MA 02048
Email: LDK006@email.mot.com
Phone: (508) 261-5649 / Fax: (508) 261-4545
*******************************************
------------------------------
Date: Wed, 26 Sep 2001 16:29:10 +0100
From: "Simon Oliver" <simon.oliver@umist.ac.uk>
Subject: Re: non-persistent cookies management
Message-Id: <3bb1f7b0$1@news.umist.ac.uk>
Anthony - the following code, adapted from your subroutine auto-saves all
cookies in a cookie file for persistance. If you don't need persistance
just make the cookie_jar a package global or pass it to the sub every call.
I changed the code to print out only the headers so you can see how the
cookies change over time.
return $response->headers->as_string;
--
Simon Oliver
#!perl
use strict;
use warnings;
use HTTP::Cookies;
use LWP::UserAgent;
my $cookie_file = 'my_cookie_file';
my $result = GetURL('http://localhost/', $cookie_file);
print $result;
sub GetURL
{
my ($inURL, $file) = @_;
my ($ua, $request, $response);
$ua = new LWP::UserAgent;
$request = new HTTP::Request 'GET', $inURL;
my $cookie_jar = HTTP::Cookies->new(file=>$file, autosave=>1,
ignore_discard=>1 );
$cookie_jar->add_cookie_header($request);
$response = $ua->request($request);
if ($response->is_success) {
$cookie_jar->extract_cookies($response);
return $response->headers->as_string;
} else {
return $response->error_as_HTML;
}
}
----- Original Message -----
From: "Anthony Clifford" <ant@tardis.ed.ac.uk>
To: "Simon Oliver" <simon.oliver@umist.ac.uk>
Sent: Wednesday, September 26, 2001 3:49 PM
Subject: Re: non-persistent cookies management
>
> Simon,
> I've followed this thread, and thought it might help with an issue i have
> with cookies. Using lynx, i get prompted 3 times to accept a cookie, using
> the code i had already i get a 403, the code i use is similar to yours,
> but without the extra cookie stuff. I've tried to implement the
> difference but don't know enough about cookies to understand the process..
>
> can you help? i've included the code i use
>
> cheers
> ant
>
> start my code
> sub GetURL
> {
> my ($inURL) = @_;
> my ($ua, $request, $response);
> $ua = new LWP::UserAgent;
> $request = new HTTP::Request 'GET', $inURL;
> $response = $ua->request($request);
> if ($response->is_success) {
> return $response->content;
> } else {
> return $response->error_as_HTML;
> }
> }
>
> end my code start yours..
>
> > use HTTP::Cookies;
> > use LWP::UserAgent;
> >
> > my $ua = LWP::UserAgent->new;
> > $request = HTTP::Request->new('GET', 'file://localhost/etc/motd');
> > $response = $ua->request($request);
> > $cookie_jar = HTTP::Cookies->new;
> > $cookie_jar->extract_cookies($response);
> >
> > Will retrieve the cookies for you. You can use the
> > $cookie_jar->add_cookie_header($request) method send the coockie back.
>
>
>
------------------------------
Date: Wed, 26 Sep 2001 15:15:22 -0500
From: <inna@raykhman.com>
Subject: opening a file
Message-Id: <4Pps7.2$P04.1439@news.nyc.globix.net>
Hi,
i am trying to implement the upload a file functionality through a perl/cgi
page.
in the script i open the file, read it and write it out to a diff. file,
since i need to rename this file in the process.
for some reason, i am able to open the new file in one directory on a win2k
machine, but not in another. visibly the directories are the same, there is
space in both, the properties and rights seem to be the same.
the probl. is that on windows i don't even know how to retrieve the error.
any suggestions? or a place may be where i can get this information?
thanks,
inna
------------------------------
Date: Wed, 26 Sep 2001 20:39:31 -0000
From: darkon@one.net (David Wall)
Subject: Re: opening a file
Message-Id: <Xns9128A9587623darkononenet@207.126.101.97>
<inna@raykhman.com> wrote on 26 Sep 2001:
> i am trying to implement the upload a file functionality through a
> perl/cgi page.
>
> in the script i open the file, read it and write it out to a diff.
> file, since i need to rename this file in the process.
>
> for some reason, i am able to open the new file in one directory on a
> win2k machine, but not in another. visibly the directories are the
> same, there is space in both, the properties and rights seem to be the
> same.
>
> the probl. is that on windows i don't even know how to retrieve the
> error.
>
> any suggestions? or a place may be where i can get this information?
If you're using IIS and Activestate Perl, look for PerlIS.log in one of the
subdirectories where you installed Perl. This has the error log for Perl
for ISAPI, iirc. (I don't remember exactly where, because I haven't used
IIS lately)
More generally, CGI::Carp is useful for testing CGI scripts. Just put
use CGI::Carp qw(fatalsToBrowser);
at the beginning of your program, and errors will be sent to the browser
when you run them as CGI.
--
David Wall
darkon@one.net
------------------------------
Date: Wed, 26 Sep 2001 15:32:11 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: opening a file
Message-Id: <3BB23B4B.D384B995@home.com>
inna@raykhman.com wrote:
>
> in the script i open the file, read it and write it out to a diff.
> file, since i need to rename this file in the process.
Take a look at the File::Copy module. It can do this for you.
> for some reason, i am able to open the new file in one directory on
> a win2k machine, but not in another. [...]
>
> the probl. is that on windows i don't even know how to retrieve
> the error.
When a function such as open() fails, it puts the error in the builtin
variable $!. The common idiom for opening a file is:
open(FOO, 'file') or die "Can't open 'file' [$!]\n";
-mjc
------------------------------
Date: Wed, 26 Sep 2001 16:30:11 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Peek and Poke on Perl?
Message-Id: <9osvqj$24lc$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Gary
<gamtci1@mpinet.net>], who wrote in article <3BB1DAFF.111A@mpinet.net>:
> According to your thinking, segment 0000 non-protected
> mode would be an invalid address in protected mode, but, of course,
> it isn't.
This depends on how the OS requests memory mapping to be organized
(LDT GDT etc). And what is the relevance for the discussion at hand?
Ilya
------------------------------
Date: Wed, 26 Sep 2001 17:31:20 GMT
From: Gary <gamtci1@mpinet.net>
Subject: Re: Peek and Poke on Perl?
Message-Id: <3BB210B5.413A@mpinet.net>
The relevance is: YOU are thinking in terms of what is
happening in the CPU and I'M talking about what happens
on the address bus, which happens to be point of this
entire thread: Having an ability within Perl to read/write
to memory-mapped cards on the bus.
In regards to your latest display of ignorance in this issue:
Address 0 is still valid regardless of Descriptor tables. It is
an address inside the RAM, the RAM chips all have an address 0.
They have no idea how the CPU has internally decided to designate
the RAM. They have no idea what CPU is connected to them. If a
RAM chip is 256 bytes in size, it will have 8 address lines, which
reference byte locations 0 thru 255. This has nothing to do with
the CPU, or protected or non-protected modes either.
------------------------------
Date: Wed, 26 Sep 2001 18:41:33 GMT
From: Gary <gamtci1@mpinet.net>
Subject: Re: Peek and Poke on Perl?
Message-Id: <3BB22129.7C25@mpinet.net>
I was responding to a poster who didn't understand the
question. I realize a device driver is needed to produce this
functionality. I was looking for a Perl module which was
already written which provided such functionality. The post
to which I was responding stated that "a protected-mode
operating system wouldn't generate the address C000, because
that was a DOS address", or some nonsense close to that.
------------------------------
Date: Wed, 26 Sep 2001 18:54:29 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Peek and Poke on Perl?
Message-Id: <2s84rtcbb67d0dn9c0nu5ie9kjfe9l7e31@4ax.com>
Gary wrote:
>The relevance is: YOU are thinking in terms of what is
>happening in the CPU and I'M talking about what happens
>on the address bus, which happens to be point of this
>entire thread
I think Ilya knows what it is about. Under protected mode, address
0C0000 is not what gets put on the address bus when you try to access
it. Under real mode, it is. (IIRC)
--
Bart.
------------------------------
Date: 26 Sep 2001 15:03:52 -0700
From: adcoment@ameritech.net (Adam)
Subject: Perl running slow...
Message-Id: <e2768ea2.0109261403.43d42be5@posting.google.com>
Using some simple benchmarks, I am having problems with Perl 5.6 on a
cobalt raq3 (running redhat -- not cobalt linux). Using a simple use
CGI and a print loop, I have yeilded the following:
1) raq3, P XMHZ, 64MB, perl 5.6.0
2) PIII 700MHZ, 128MB, perl 5.6.0
3) PII 450MHZ, 256MB, perl 5.005_03
use CGI;
1) 10000 loops of other code took:22 wallclock secs (21.76 usr + 0.03
sys = 21.79 CPU) @ 458.93/s (n=10000)
2) 10000 loops of other code took: 2 wallclock secs ( 1.82 usr + 0.01
sys = 1.83 CPU) @ 5464.48/s (n=10000)
3) 10000 loops of other code took: 5 wallclock secs ( 4.49 usr + 0.06
sys = 4.55 CPU)
use CGI;
use DBI;
1) 10000 loops of other code took:22 wallclock secs (22.07 usr + 0.08
sys = 22.15 CPU) @ 451.47/s (n=10000)
2) 10000 loops of other code took: 2 wallclock secs ( 1.85 usr + 0.00
sys = 1.85 CPU) @ 5405.41/s (n=10000)
3) 10000 loops of other code took: 7 wallclock secs ( 4.82 usr + 0.04
sys = 4.86 CPU)
Whenever a script is ran, it has a few seconds of nothing, just
startup overhead. If anyone has any information on why, I would be
very thankful.
Thanks,
Adam
------------------------------
Date: Wed, 26 Sep 2001 08:32:10 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Reading from HTML
Message-Id: <3bb1f4fc@news.microsoft.com>
"Dejan" <dejan.tomazic@club.win-ini.si> wrote in message
news:X1bs7.539$8v1.18371@news.siol.net...
> how can I read from HTML where is an option radio button its value into
perl
> script. I'd like to have a $variable that is depending on witch radio
button
> is selected.
Reading from HTML? That always calls for "HTML::Parser".
See the FAQ why analysing HTML with a home-made hack is generally not a good
idea.
jue
------------------------------
Date: Wed, 26 Sep 2001 19:22:24 GMT
From: Steve Allan <stevea@wrq.com>
Subject: Re: sendmail gadget works on one server, not on another
Message-Id: <uy9n169is.fsf@wrq.com>
mgjv@tradingpost.com.au (Martien Verbruggen) writes:
>On Wed, 26 Sep 2001 04:32:28 GMT,
> Fat Boy <simercer@NOSPAMhotmail.com> wrote:
<snip>
>[snip]
>
>> # Add the command line flags
>> $mail_program = "/usr/sbin/sendmail -t -n";
>
>Good quality code always does a lot of work first, and then discards
>it all by overwriting the result of that work.
I don't understand that statement. Could you elaborate or give an
example of what you mean?
--
-- Steve __
------------------------------
Date: 26 Sep 2001 17:37:14 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: sendmail gadget works on one server, not on another
Message-Id: <m3lmj1d46t.fsf@mumonkan.sunstarsys.com>
Steve Allan <stevea@wrq.com> writes:
> mgjv@tradingpost.com.au (Martien Verbruggen) writes:
> >[snip]
> >
> >> # Add the command line flags
> >> $mail_program = "/usr/sbin/sendmail -t -n";
> >
> >Good quality code always does a lot of work first, and then discards
> >it all by overwriting the result of that work.
>
> I don't understand that statement. Could you elaborate or give an
> example of what you mean?
I think he was mocking the fact that the line in question [cs]hould
have looked a bit more like:
$mail_program = "$mail_program $flags ";
which btw is what a google search for "sendmail_lib.pl" yields.
More interesting was that 5.6.1's Deparse failed on it:
% perl -c try.pl
try.pl syntax OK
% perl -MO=Deparse try.pl
Can't call method "PADLIST" on an undefined value at
/usr/lib/perl5/5.6.1/i586-linux-thread-multi/B/Deparse.pm line 1039.
CHECK failed--call queue aborted.
% perl5.00503 -MO=Deparse try.pl
try.pl syntax OK
$flags = '-t -n -f';
$mailer = '/usr/lib/sendmail';
$mailer1 = '/usr/bin/sendmail';
$mailer2 = '/usr/sbin/sendmail';
if (-e $mailer) {
$mail_program = $mailer;
}
elsif (-e $mailer1) {
$mail_program = $mailer1;
}
elsif (-e $mailer2) {
$mail_program = $mailer2;
}
else {
print "Content-type: text/html\n\n";
print q[I can't find sendmail, shutting down...<br>];
print 'Whoever set this machine up put it someplace weird.';
exit;
}
$mail_program = '/usr/sbin/sendmail -t -n';
[...]
sub web_error {
local($error) = @_;
$error = "Error Occured: $error";
print "$error<p>\n";
die $error;
}
'???';
^^^
OTOH, I couldn't have said it better myself.
--
Joe Schaefer "A little inaccuracy sometimes saves a ton of explanation."
-- H. H. Munro (Saki)
------------------------------
Date: Wed, 26 Sep 2001 17:59:26 +0200
From: EXP <nospaming@gmx.net>
Subject: Re: Setting max. values (cpu/ram usage) for mod_perl scripts?
Message-Id: <3BB1FB5E.114D8879@gmx.net>
Ilya Martynov wrote:
>
> >>>>> On Wed, 26 Sep 2001 13:23:09 +0200, EXP <nospaming@gmx.net> said:
>
> E> Anyway, I seem to have found something better than "shell" ulimit.
> E> man Apache::Resource
>
> What is the difference? Both Apache::Resource and 'shell' ulimit use
> setrlimit syscall internally.
>
> But you are right: limiting CPU is not so easy as it looks
> first time.
>
I have not tested the cpu limit yet, but apache::resource makes setting
those limits possible via httpd.conf settings and the ram limit works as
expected, that's something :o).
BYe!
EXP
------------------------------
Date: Wed, 26 Sep 2001 12:32:12 -0400
From: asif <whatever@nevermind.invalid>
Subject: Re: Single line if Statement
Message-Id: <3BB2030C.3020702@nevermind.invalid>
asif wrote:
> David Wall wrote:
>
>> darkon@one.net (David Wall) wrote on 25 Sep 2001:
>>
>>
>>> "Victor Menendez" <nomail@please.com> wrote on 25 Sep 2001:
>>>
>>>
>>>> I would like to print an item based on an expression that is true.
>>>> print OUT if expression returns TRUE other wise skip goto next line."
>>>> Content "\n";
>>>> Is there a way to do this using just a single line command?
>>>>
>>> You could do something like
>>>
>>> while ( <> ) {
>>> print and next if EXPRESSION;
>>> }
>>>
>>> where EXPRESSION is what you're testing.
>>>
>>
>> Oops, I should have read the original post more carefully.
>> while ( <> ) {
>> EXPRESSION ? print : next;
>> # other stuff happens here when EXPRESSION is true
>> }
>>
>> prints the input line if EXPRESSION is true, otherwise it goes to the
>> next line. And "Laocoon" has already showed you another example of
>> statement modifiers that may be exactly what you want.
>>
>> "Laocoon"? Are you telling us to beware of emails bearing
>> attachments? Remind me not to be around when the worms come for
>> you... :-)
>>
>>
>
> I've used:
>
> while(<>){ EXPRESSION && print; }
>
> /whatever
>
Please excuse the multiple posts. Somewhere between Mozilla 9.4+ and
EasyNews there were multiple communication breakdowns which appeared to
be time-outs.
/whatever
/whatever
------------------------------
Date: 26 Sep 2001 10:06:27 -0700
From: muhrich@deltadentalpa.org (Matt Uhrich)
Subject: String Comparison Problem
Message-Id: <6ac97d6d.0109260906.30d5c5d0@posting.google.com>
Hi,
Here is the program I am having problems with:
#!d:/perl/bin/perl.exe
$sourcedir = "d:\\data";
chdir $sourcedir or die "Can't chdir to $path:$\n";
@files = <*>;
$previous_group = "0000";
foreach ( @files ) {
next if ( -d );
print "Could not open $_!" unless open( INPUT, "<$_" );
m/(\.\w+$)/;
$extension = $1;
while ( <INPUT> ) {
$first = substr( $_, 15, 1 );
if ( $first == "-" ) {
$current_group = substr( $_, 11, 4 );
if ( $current_group != $previous_group ) {
close ( OUTPUT );
open( OUTPUT, ">$current_group.$extension");
printf OUTPUT ( "%s", $_ );
$previous_group = $current_group;
}
else {
printf OUTPUT ( "%s", $_ );
}
}
else {
printf OUTPUT ( "%s", $_ );
}
}
close( INPUT );
close( OUTPUT );
}
The results of "if ( $first == "-" )" is always true. Is this not the
proper way to compare strings?
Thanks,
Matt
------------------------------
Date: Wed, 26 Sep 2001 11:59:45 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: String Comparison Problem
Message-Id: <3bb225a1$1@news.microsoft.com>
"Matt Uhrich" <muhrich@deltadentalpa.org> wrote in message
news:6ac97d6d.0109260906.30d5c5d0@posting.google.com...
> The results of "if ( $first == "-" )" is always true. Is this not the
> proper way to compare strings?
As "perldoc perlop" will tell you "==" is a NUMERICAL compare, i.e. you are
comparing the numerical values of "$first" and "-" which is 0 in both cases
and therefore the comparison yields true.
You want "eq" instead.
jue
------------------------------
Date: 26 Sep 2001 12:41:20 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: String Comparison Problem
Message-Id: <m3elotetof.fsf@dhcp9-161.support.tivoli.com>
On 26 Sep 2001, muhrich@deltadentalpa.org wrote:
> The results of "if ( $first == "-" )" is always true. Is this not
> the proper way to compare strings?
No, it isn't. Use "eq".
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: 26 Sep 2001 19:10:47 +0100
From: nobull@mail.com
Subject: Re: time and win32 perl
Message-Id: <u9adzhvn4o.fsf@wcl-l.bham.ac.uk>
<inna@raykhman.com> writes:
> i am using the time() function on win2k machine, with activestate perl
> 5.6.0, binary build 623.
>
> the problem is that the time function doesn't get updated properly, i.e. if
> i reload the page cgi/perl that calls the function, the value that the
> function return doesn't change, i.e. doesn't get updated properly.
This sounds improbable. Please produce a small but complete script
that will reproduce the symtoms and post it here.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 26 Sep 2001 15:04:25 -0500
From: <inna@raykhman.com>
Subject: Re: time and win32 perl
Message-Id: <PEps7.1$P04.1267@news.nyc.globix.net>
> This sounds improbable. Please produce a small but complete script
> that will reproduce the symtoms and post it here.
If it sounds improbably then you're prob. right :)
let me try again, thanks.
inna
------------------------------
Date: 26 Sep 2001 19:29:17 +0100
From: nobull@mail.com
Subject: Re: Transforming HTML
Message-Id: <u97kulvm9u.fsf@wcl-l.bham.ac.uk>
"Raj" <oneconcept@yahoo.co.uk> writes:
> <nobull@mail.com> wrote in message news:u97kunw3sg.fsf@wcl-l.bham.ac.uk...
> > "Raj" <oneconcept@yahoo.co.uk> writes:
> > >
> > > Basically, I would like to turn:
> > >
> > > <INPUT TYPE="text" NAME="xFname">
> > >
> > > into:
> > >
> > > <INPUT TYPE=text" NAME="xFname" VALUE="Raj">
> > >
> > > I'm sure its quite simple
> >
> > That would be your error. As we point out in this newsgroup several
> > times a week trasforming HTML is not simple. That's why we have
> > modules to do it.
>
> I'm quite new to Perl and I was hoping that this could be done
> without the need for modules.
As you correctly point out your desire not to use modules is a
reflection of your inexperience. Since you have realised this it
seems odd that the desire should persist.
> Do they not carry any sort of overhead?
Yes modules carry a runtime memory/speed overhead. Plus you have to
download them.
Not using modules carries a large development overhead.
> Also, I'd like to learn exactly how I would do this rather than let a module
> cover up the detail (which I know is their function!).
You really do _not_ want to write the whole of HTML::Parser again.
> If anyone can think of a way to acheive what I want without the use of a
> module, and has the time for me, please feel free to contact me.
Obviously in this very restricted case you can simply do
s/(<INPUT TYPE="text") (NAME="x(\w+)")>/$1 VALUE="$address{$3}" $2/;
This will not work if the <INPUT> tag does not appear exactly as you
describe all on one line.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 26 Sep 2001 20:35:20 +0200
From: "rob vitters" <robvitters@hotmail.com>
Subject: Using in/output ports within perl.
Message-Id: <1001529839.691431@news.knoware.nl>
Hi,
Does anyone know if perl can read and write i/o ports.
Rob
------------------------------
Date: Wed, 26 Sep 2001 22:47:33 +0200
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: Using in/output ports within perl.
Message-Id: <9oteu7$l2h$03$1@news.t-online.com>
"Steffen Müller" <tsee@gmx.net> schrieb im Newsbeitrag
news:9ote4v$jo7$03$1@news.t-online.com...
> Do not multi-post.
Sorry for being a bit harsh.
Try search.cpan.org?mode=module&query=port
or the like to find a ton of modules.
Try
http://www.perldoc.com/perl5.6.1/pod/perlfaq8.html#How-do-I-read-and-write-t
he-serial-port-
Steffen
------------------------------
Date: Wed, 26 Sep 2001 22:34:59 +0200
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: Using in/output ports within perl.
Message-Id: <9ote4v$jo7$03$1@news.t-online.com>
"rob vitters" <robvitters@hotmail.com> schrieb im Newsbeitrag
news:1001529839.691431@news.knoware.nl...
> Does anyone know if perl can read and write i/o ports.
Yes.
Do not multi-post.
RTFM. Period.
Steffen
------------------------------
Date: Wed, 26 Sep 2001 12:19:01 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Werte aus einem Array =?iso-8859-1?q?l=F6schen?=
Message-Id: <874rppoooq.fsf@limey.hpcc.uh.edu>
>> On Wed, 26 Sep 2001 19:06:02 -0000,
>> "Michael" <info@gummipuppen.de> said:
> @delete = ('wer1','wert2'); # Zu l"schende Werte @val =
> ('wert1','wert2','wert3','wert4');
> Ich möchte alle Werte, die sich in @delete befinden, aus
> @val löschen. Hat jemand eine schnelle Routine für mich
> ?
(I want to delete all of the values in @delete from @val)
This looks like a set difference operation, so see
http://search.cpan.org/doc/JHI/Set-Scalar-1.10/lib/Set/Scalar.pm
hth
t
--
Yes way! Mmmmkay?
------------------------------
Date: Wed, 26 Sep 2001 19:06:02 -0000
From: "Michael" <info@gummipuppen.de>
Subject: Werte aus einem Array löschen
Message-Id: <9ot1u3$6cl$06$1@news.t-online.com>
@delete = ('wer1','wert2'); # Zu l"schende Werte
@val = ('wert1','wert2','wert3','wert4');
Ich möchte alle Werte, die sich in @delete befinden, aus @val löschen.
Hat jemand eine schnelle Routine für mich ?
Viele Dank !
Michael
------------------------------
Date: 26 Sep 2001 11:24:35 -0700
From: miko@idocs.com (Miko O'Sullivan)
Subject: Re: What does ||= do ?
Message-Id: <db27ea77.0109261024.7d83900f@posting.google.com>
stanb@panix.com (Stan Brown) wrote in message news:<9osnkc$cvi$1@panix2.panix.com>...
> I ran across the ||= construct in some examle code, and I can't figure out
> what it does.
||= means "if it's false, assign the following value". For example,
the two following lines of code are functionally identical:
if (! $var)
{$var = 'Stan'}
$var ||= 'Stan';
Be careful: ||= checks for any kind of falsehood. If 0 and an empty
string have different meanings to your code, the following line
probably won't do what you want:
$var ||= '';
-miko
------------------------------
Date: 26 Sep 2001 13:33:54 -0400
From: stanb@panix.com (Stan Brown)
Subject: What's wrong with this pack() line?
Message-Id: <9ot3i2$47e$1@panix1.panix.com>
I'm trying to pacj teh results of a database row retrieved with
fetchrow_array, to send to a co-operating process. Heres what I'm trying:
my $serialized = join '', pack "w/a*", @onerow;
print $writer pack("L", length $serialized), $serialized;
my $l = length $serialized;
print "onerow = @onerow\n";
print "Sent data of length $l\n";
I'm getting the corrrect retrieved from teh DB and printed by the "print
onerow" Line, but the "Sent data of length" line always says that it sennt
a length of 2, which is _)always_ wrong.
So, I suspect that I must have the pack() line wrong. Correct?
If so, what's the correct syntax here to pack the data into a null
seperated record?
--
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
-- Benjamin Franklin
------------------------------
Date: 26 Sep 2001 19:04:57 +0100
From: nobull@mail.com
Subject: Re: What's wrong with this pack() line?
Message-Id: <u9elotvnee.fsf@wcl-l.bham.ac.uk>
stanb@panix.com (Stan Brown) writes:
> my $serialized = join '', pack "w/a*", @onerow;
a* only uses up a sigle value from the list and pack() returns only a
scalar I think you meant to say:
my $serialized = join '', map { pack 'w/a*', $_ } @onerow;
But IMNSHO it's neater to do:
my $serialized = pack 'w/a*' x @onerow, @onerow;
stanb@panix.com (Stan Brown) writes:
> my $serialized = join '', pack "w/a*", @onerow;
> print $writer pack("L", length $serialized), $serialized;
Of course there's nothing to stop you using the / pack character more
than once in the same program... or even the same expression.
print $writer pack 'L/a*' => pack 'w/a*' x @onerow => @onerow;
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 26 Sep 2001 22:04:36 GMT
From: tim@vegeta.ath.cx (Tim Hammerquist)
Subject: Re: who said this?
Message-Id: <slrn9r4l0o.lan.tim@vegeta.ath.cx>
Me parece que Kenny McCormack <gazelle@yin.interaccess.com> dijo:
> I.e., that the whole point of the
> PC/DOS/Windoze is to remove the limitation of being limited by one's own
> wisdom ... and instead, to allow everyone to benefit from the efforts of
> the few.
Step 1:
Remove a person's intelligence from the list of requirements to
use, much less maintain, a computer.
Step 2:
Let them continue in their oblivious bliss of MS Windows/AOL
lifestyle.
Step 3:
Those who are not so limited by their "own knowledge" find
themselves constantly repeating things like:
"I'm sorry you hate your computer, but AOL is the one kick you
off of your long uploads to eBay."
"So turn off MSIE Content Advisor. What? You turned it off 3
years ago?! And it still accepts the same password? ...and it
_still_ comes up repeatedly?!"
Not to mention my own family who doesn't care that their MS Office
appliacations still work, merely that their pretty icons don't show
up any more. "Does it open Word when you click on the icon? Good.
Done." There are just too many things I could be doing rather than
keep finding and replacing pretty blue icons of large W's just so
they have a more aesthetic 5 minute wait for Word2000 to load on a
Pentium II.
I'm sorry. I like working with people that can actually wrap their heads
'round what a browser cache is, much less how a browser cache can
interfere with their websites.
So do you think Uncle Bill has succeeded in removing the necessity of a
person's intelligence from using computers? I personally took some
credits with students who thought Microsoft was the coolest thing since
checking email from different computers.
Am I just out of touch? :)
> I don't think this later interpretation is at all unreasonable. Mind you,
> I haven't said anything about what my own view is (*).
I have. ;)
> (*) Although I am, in fact, as much of a "Unix good, Windoze bad"
> person as you are likley to find.
Bet ya couldn't tell my bias...
--
I'm already not yet convinced.
-- Larry Wall
------------------------------
Date: 26 Sep 2001 11:26:38 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: XML::Writer question... how to write output to file?
Message-Id: <3bb21dde@news.victoria.tc.ca>
Dr Joolz (julius_mong@hotmail.com) wrote:
: ***24 hours in a day...24 beers in a case...coincidence?***
gee, maybe, but on the other hand, at 2.5 beers an hour, the numbers don't
work out so well...
------------------------------
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.
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 1825
***************************************