[19957] in Perl-Users-Digest
Perl-Users Digest, Issue: 2152 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 18 09:05:54 2001
Date: Sun, 18 Nov 2001 06:05:08 -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: <1006092307-v10-i2152@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 18 Nov 2001 Volume: 10 Number: 2152
Today's topics:
Re: Binary issues.. <mgjv@tradingpost.com.au>
Re: Binary issues.. <mgjv@tradingpost.com.au>
Re: Call a CGI from another CGI script <execv@hotmail.com>
Re: Directory problem... again (BUCK NAKED1)
Re: Directory problem... again <mgjv@tradingpost.com.au>
Re: Directory problem... again (BUCK NAKED1)
Re: Directory problem... again <uri@stemsystems.com>
Re: Directory problem... again <mgjv@tradingpost.com.au>
HELP: creating regexps on the fly and backslashes...? (Bruno Boettcher)
Re: HELP: creating regexps on the fly and backslashes.. <Tassilo.Parseval@post.rwth-aachen.de>
Re: How to conditionalize output in a here document? (Tad McClellan)
Re: I'm Scared of Signal Processing <goldbb2@earthlink.net>
Re: no more than 128 symbles <Laocoon@eudoramail.com>
Re: please help: good OOP guide for perl <roger_faust@bluewin.ch>
Re: reading null terminated string from a file <mkmazie>
Re: send HTTP response <roger_faust@bluewin.ch>
shorten a pattern-matching-statement <Rene.Scheibe@gmx.net>
Re: shorten a pattern-matching-statement <Laocoon@eudoramail.com>
Re: shorten a pattern-matching-statement <krahnj@acm.org>
Re: shorten a pattern-matching-statement <Tassilo.Parseval@post.rwth-aachen.de>
Re: shorten a pattern-matching-statement (F. Xavier Noria)
Re: Talking to serial ports? (Si Ballenger)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 18 Nov 2001 17:38:30 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Binary issues..
Message-Id: <slrn9velr6.i3u.mgjv@martien.heliotrope.home>
On 18 Nov 2001 02:08:34 GMT,
Alan Barclay <gorilla@elaine.furryape.com> wrote:
> In article <slrn9vc34r.3j7.mgjv@martien.heliotrope.home>,
> Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
>>Anyway, it shouldn't be too hard to adapt that code. Reading byte by
>>byte is almost never a good idea in Perl, even though it would be a good
>>idea in C.
>
> Even in C it's a bad idea to read byte by byte. If you do, then it will
> be much less efficent than reading in large blocks.
Actually, using the stdio stuff it shouldn't be that much different, as
long as you read linearly. The buffering is done as part of the stdio
interface. If you use raw i/o byte by byte, then I agree with you.
> Of course, reading is totally seperate to processing, you can read into
> a buffer, and then proess individual bytes from that buffer, that's
> exactly what stdio functions such as fread do.
Indeed. And also what fgetc does. It hands you characters from the
internal buffer one by one. Disk I/O is not done for each character.
Martien
--
|
Martien Verbruggen |
| The gene pool could use a little chlorine.
|
------------------------------
Date: Sun, 18 Nov 2001 17:39:26 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Binary issues..
Message-Id: <slrn9velsu.i3u.mgjv@martien.heliotrope.home>
On Sun, 18 Nov 2001 10:48:51 +1100,
Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
> On Sun, 18 Nov 2001 10:02:58 +1100,
> Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
>
> I just thought of a much, much simpler way. It allows you less control
[snip]
> $/ = "</data>";
>
> while (<>)
Of course, in a real program, you still want to make sure to use binmode
on the file handle you're going to be reading from.
Martien
--
|
Martien Verbruggen | If it isn't broken, it doesn't have enough
| features yet.
|
------------------------------
Date: Sat, 17 Nov 2001 23:44:47 -0500
From: "execv" <execv@hotmail.com>
Subject: Re: Call a CGI from another CGI script
Message-Id: <JxHJ7.1105$K86.11549@newscontent-01.sprint.ca>
why not just make main.cgi do it ALL?
Richard <google@richmore.com> wrote in message
news:81f7a6eb.0111150338.5634cabe@posting.google.com...
> "Th.G" <th_gi@hotmail.com> wrote in message
news:<3BF2F1F2.2040005@hotmail.com>...
> > Hi
> >
> > How can I call a CGI-script from another CGI, give any parameters to
> > that CGI and receive
> > any results from the other CGI.
> > Eg. 2 scripts 'main.cgi' and 'check.cgi'.
> > 'main.cgi' calls 'check.cgi' and sends a parameter to check. 'check.cgi'
> > gives back any
> > result based on that parameter.
> > Can I use this:
> > in main.cgi:
> > .
> try the lwp modules, it won't do quite what you expect, but close enough.
> Use perl's perldoc command to find more info about lwp.
>
> perldoc lwpcook
> perldoc LWP::Simple
------------------------------
Date: Sun, 18 Nov 2001 00:36:33 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Directory problem... again
Message-Id: <5079-3BF756F1-92@storefull-248.iap.bryant.webtv.net>
clintp@geeksalad.org (Clinton=A0A.=A0Pierce)
> Why not just use a File::Find solution?
> It's quick, it's easy. (untested):
> use File::Find;
> sub chtime {
>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0utime $now, $now, $_;
> }
> find(\&chtime, $tmpdir);
I wondered why I kept getting 1969 as the time modified. You didn't
define the time in your example. I guess you left that for me to do,
since you stated your example was untested. :-)
Anyway, thanks for helping me out before Tad came along and chastised me
for asking a question that's been answered before... but I couldn't get
the "touch" coding from the Google archives to work.
Isn't File::Find the best thing since sliced bread? I'll be glad when I
get the hang of it. Here's my latest working code.
use File::Find;
find (\&mod_time, $tmpdir);
sub mod_time {
$now =3D time;
utime $now, $now, $_;
}
I don't understand why there are 2 $nows in "utime $now, $now, $_;"
either; but it works.
Again, thanks.
Dennis
------------------------------
Date: Sun, 18 Nov 2001 18:25:53 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Directory problem... again
Message-Id: <slrn9veok1.i3u.mgjv@martien.heliotrope.home>
On Sun, 18 Nov 2001 00:36:33 -0600 (CST),
BUCK NAKED1 <dennis100@webtv.net> wrote:
>
> I don't understand why there are 2 $nows in "utime $now, $now, $_;"
> either; but it works.
*sigh*
Honestly, by now you should _know_ how to look up this stuff in the
perlfunc documentation. You've been around here long enough, and you've
been told often enough how to do this.
From the utime entry in perlfunc:
utime LIST
Changes the access and modification times on each
file of a list of files. The first two elements
of the list must be the NUMERICAL access and modi
fication times, in that order. Returns the number
[SNIP]
Now, please, next time, when you find yourself, once again, thinking
that you don't undersdtand why a certain argument goes with a certain
function, _look it up_ first, before posting the question here.
Martien
--
|
Martien Verbruggen | I took an IQ test and the results were
| negative.
|
------------------------------
Date: Sun, 18 Nov 2001 03:01:47 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Directory problem... again
Message-Id: <1810-3BF778FB-114@storefull-247.iap.bryant.webtv.net>
I looked up Utime *before* posting. JFYI, Martien, I *always* look up
stuff *before* posting. Please don't assume.
--Dennis
------------------------------
Date: Sun, 18 Nov 2001 09:58:48 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Directory problem... again
Message-Id: <x7hersflgs.fsf@home.sysarch.com>
>>>>> "BN" == BUCK NAKED1 <dennis100@webtv.net> writes:
BN> I looked up Utime *before* posting. JFYI, Martien, I *always* look up
BN> stuff *before* posting. Please don't assume.
then how come in all this time you still can't grok the docs? just
looking up stuff isn't enough. you should have developed the skills to
understand them and how perl funcs are called and what args are passed,
etc.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sun, 18 Nov 2001 21:10:36 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Directory problem... again
Message-Id: <slrn9vf28s.i3u.mgjv@martien.heliotrope.home>
On Sun, 18 Nov 2001 03:01:47 -0600 (CST),
BUCK NAKED1 <dennis100@webtv.net> wrote:
> I looked up Utime *before* posting. JFYI, Martien, I *always* look up
> stuff *before* posting. Please don't assume.
Second time in one week that I've had to read a perlfunc entry out to
you. Was there anything not clear about the utime() entry in perlfunc?
Martien
--
|
Martien Verbruggen | The Second Law of Thermodenial: In any closed
| mind the quantity of ignorance remains
| constant or increases.
------------------------------
Date: 18 Nov 2001 11:47:27 GMT
From: bboett@bboett.dyndns.org (Bruno Boettcher)
Subject: HELP: creating regexps on the fly and backslashes...?
Message-Id: <9t874f$7ip$1@wanadoo.fr>
Hello!
i am mangling with a irc script ...
it gets line from an irc server and has to parse them... now i want the
thing to react on empty lines or lines that contain a [\] but depending
on some previously parsed stuff....
so i thought i set up a thing like this:
my $characteristicString = "" or '\[\\\\\]'; (i tryed '\[\\\]' first...)
if($line =~ /^\s*$characteristicString\s*$/)
{ ... process... }
but somehow this line gets never triggered....
as far as i can tell there's some problem with the backlsashes....
so is there an easy way to get this working?
--
ciao bboett
==============================================================
bboett@earthling.net
http://inforezo.u-strasbg.fr/~bboett http://erm1.u-strasbg.fr/~bboett
------------------------------
Date: Sun, 18 Nov 2001 13:17:03 +0100
From: "Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: HELP: creating regexps on the fly and backslashes...?
Message-Id: <9t88rv$j74$00$1@news.t-online.com>
On 18 Nov 2001 11:47:27 GMT, Bruno Boettcher wrote:
> Hello!
>
> i am mangling with a irc script ...
> it gets line from an irc server and has to parse them... now i want the
> thing to react on empty lines or lines that contain a [\] but depending
> on some previously parsed stuff....
I really don't understand this, but...
> so i thought i set up a thing like this:
> my $characteristicString = "" or '\[\\\\\]'; (i tryed '\[\\\]' first...)
^^^^^^^^^^^^^
This line does not make any sense. The or-part is never reached. Perl
actually considers this a stealth if-statement because it gets parsed
as:
(my $characteristicString = "") or ('...')
Do you perhaps want '||'? Yet this would not make sense either.
my $s = "" || "string"; # is equiv to
my $s = "string";
How about:
$s = $s eq "" ? $s : 'another string';
This sets $s = 'another string' if it was previously not "".
> if($line =~ /^\s*$characteristicString\s*$/)
> { ... process... }
>
> but somehow this line gets never triggered....
> as far as i can tell there's some problem with the backlsashes....
No, there must be other problems. I guess somewhere in the logic.
Tassilo
--
Everything is controlled by a small evil group to which, unfortunately,
no one we know belongs.
------------------------------
Date: Sun, 18 Nov 2001 05:45:37 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How to conditionalize output in a here document?
Message-Id: <slrn9vefr6.5qf.tadmc@tadmc26.august.net>
Robert Nicholson <robert@elastica.com> wrote:
>If it possible to conditionalize some of the output contained in a here document?
Sounds like you want a "Template". There are modules for doing that...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 18 Nov 2001 01:35:09 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: I'm Scared of Signal Processing
Message-Id: <3BF7569D.14216217@earthlink.net>
What A Man ! wrote:
>
> Is signal processing dangerous to us amateur perlers? I've studied
> perlsec. The reason I'm asking is because Ben Goldberg graciously
> posted the code below recently; but when I modified the coding below
> (I think I removed a couple of lines), it left a process running (over
> process limit) that caused my server to shut me down for a few days,
> so I went back to just using a plain "open" or "system" to execute the
> program.
I think I recall you mentioning it to me, or something similar -- you
had removed the END block, I think, and this resulted in your problem.
> While I'm on the subject, how do I check to see if any processes were
> left running on a webserver? and how do I turn them off?
There's always *some* processes, but what I think you mean is how do you
tell whether any of *your* processes are left running.
When a process dies, it's children get adjusted so that 'init' (process
id 1) is their parent, such that when they die, they are immediately
reaped, thus preventing them from being zombies when they die. A simple
solution *might* be [I'm not sure if it will work] to use the output of
the 'ps' program, and look for "gunzip" and "tar" processes which have a
parent pid of 1, and kill them, under the assumption that they are
orphaned processes from this particular cgi program.
[snip]
> my $g_pid = open2(FROM_GUNZIP, "<&TMPFILE", "gunzip", "-c", "-d");
> my $t_pid = open2(FROM_TAR, "<&FROM_GUNZIP", "tar", "tf", "-");
[snip stuff which dies under certain conditions]
> END: {
> kill SIGKILL => $g_pid, $t_pid;
> }
I probably should have added a comment "do not remove!" inside the END
block.
--
Klein bottle for rent - inquire within.
------------------------------
Date: Sun, 18 Nov 2001 11:31:45 +0100
From: Laocoon <Laocoon@eudoramail.com>
Subject: Re: no more than 128 symbles
Message-Id: <Xns915D7553D1CABLaocooneudoramailcom@62.153.159.134>
"Godhead" <dolgopa@co.ru> wrote in news:9t6hmr$85d$1@octopus.co.ru:
> Is it OK:
> if ($domain =~ /^.{129,}(\.ru)$/){ }
This makes sure every string has 129 characters or more and
after them is '.ru'
if ( $domain =~ /^.{1,128}\.ru$/) {...}
At least 1 to 128 characters followed by '.ru'
Lao
------------------------------
Date: Fri, 16 Nov 2001 10:28:03 +0100
From: Roger Faust <roger_faust@bluewin.ch>
Subject: Re: please help: good OOP guide for perl
Message-Id: <3bf77ef2_1@news.bluewin.ch>
David H. Adler wrote:
> In article <9t6n8j$kkb$1@news.ethome.net.tw>, ETHOME USER wrote:
> > I enjoy programming with perl because it is so efficent and elegant but
> > i am so confused with the OOP concept...
> >
> > could anyone please tell me where to find good resouces on perl OOP
> > programming ? (network on line free resouces are prefered)
>
> Well, it's not generally free, but I'll mention this because it's just
> *good*:
>
> Object Oriented Perl by Damian Conway (published by Manning).
>
> Generally considered not only a good resource on OOP, but a good book in
> general.
>
> dha
to get some free stuff try:
%perldoc perlboot
%perldoc perltoot
%perldoc perltootc
%perldoc perlobj
%perldoc perltie
%perldoc perlbot
always rember to check out %perldoc perl, it will give you an overview of
the documentation
--
Roger Faust
------------------------------
Date: Sun, 18 Nov 2001 00:16:42 -0600
From: "MK Mazie" <mkmazie>
Subject: Re: reading null terminated string from a file
Message-Id: <tvekitsdpj3d09@corp.supernews.com>
Thank you!
------------------------------
Date: Fri, 16 Nov 2001 10:21:25 +0100
From: Roger Faust <roger_faust@bluewin.ch>
Subject: Re: send HTTP response
Message-Id: <3bf77d64_1@news.bluewin.ch>
paul wrote:
> Hi,
>
> I have a Perl script which works great. It recieves an http request
> from another script and does all its stuff fine. The other script
> requires an http 200 response otherwise it resends the data every 15
> mins. This is where I get stuck as even though my script seems to work
> perfectly the data keeps coming. Does anyone have any pointers or
> example http responses?
>
> P.S. I am already using LWP in the script to 'make' an http request. I
> am just too dumb right now to get my head round sending a response...
>
> Thanks in advance,
>
> Paul
At first, try to get a modul which makes the response for you (see cpan)
since http header very strict, and browsers sometimes doesn't accept them
right (in fact, IE accepts them even if they are wrong...).
then check with your browser wether the output is ok
--
Roger Faust
------------------------------
Date: Sun, 18 Nov 2001 11:34:10 +0100
From: "Rene Scheibe" <Rene.Scheibe@gmx.net>
Subject: shorten a pattern-matching-statement
Message-Id: <9t82m8$s836$1@ID-65612.news.dfncis.de>
How can I shorten or merge this pattern matching statement into one?
if (($line =~ /(^192.168.)/) && !($line =~ /(0\.0KB\/s.*0\.0KB\/s)/)) {
...
}
------------------------------
Date: Sun, 18 Nov 2001 11:56:03 +0100
From: Laocoon <Laocoon@eudoramail.com>
Subject: Re: shorten a pattern-matching-statement
Message-Id: <Xns915D7972E35C2Laocooneudoramailcom@62.153.159.134>
"Rene Scheibe" <Rene.Scheibe@gmx.net> wrote in news:9t82m8$s836$1@ID-
65612.news.dfncis.de:
> How can I shorten or merge this pattern matching statement into one?
>
> if (($line =~ /(^192.168.)/) && !($line =~ /(0\.0KB\/s.*0\.0KB\/s)/)) {
> ...
> }
if ( $line =~ /^192.168./ && $line !~ m#(0\.KB/s).*\1# ) { ... }
if ( $line !~ m#^(?=192.168.).*(0\.KB/s).*\1# { ... }
------------------------------
Date: Sun, 18 Nov 2001 11:40:42 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: shorten a pattern-matching-statement
Message-Id: <3BF79EFA.93D7F40F@acm.org>
Rene Scheibe wrote:
>
> How can I shorten or merge this pattern matching statement into one?
>
> if (($line =~ /(^192.168.)/) && !($line =~ /(0\.0KB\/s.*0\.0KB\/s)/)) {
> ...
> }
$_ = $line;
if ( /^192\.168\./ && !m#0\.0KB/s.*0\.0KB/s# ) {
...
}
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sun, 18 Nov 2001 12:45:26 +0100
From: "Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: shorten a pattern-matching-statement
Message-Id: <9t870m$fsc$00$1@news.t-online.com>
On Sun, 18 Nov 2001 11:34:10 +0100, Rene Scheibe wrote:
> How can I shorten or merge this pattern matching statement into one?
>
> if (($line =~ /(^192.168.)/) && !($line =~ /(0\.0KB\/s.*0\.0KB\/s)/)) {
> ...
> }
Lacoon already gave you an answer using a look-ahead condition. However,
your regex is (probably) not doing what you want.
It will also match "19221681" whereas I assume you want to test for IPs
from your LAN or so. Then better escape '.' with '\.' to be on the safe
side. You should also remove the ( and ) from your regex unless you are
doing anything with the thus saved sub-matches (using $1, $2... or \1,
\2... for backreferences on the left side).
Tassilo
--
God made the integers; all else is the work of Man.
-- Kronecker
------------------------------
Date: 18 Nov 2001 12:59:18 GMT
From: fxn@retemail.es (F. Xavier Noria)
Subject: Re: shorten a pattern-matching-statement
Message-Id: <9t8bb6$4be052@news1s.iddeo2.es>
On Sun, 18 Nov 2001 11:34:10 +0100, Rene Scheibe <Rene.Scheibe@gmx.net> wrote:
: How can I shorten or merge this pattern matching statement into one?
:
: if (($line =~ /(^192.168.)/) && !($line =~ /(0\.0KB\/s.*0\.0KB\/s)/)) {
: ...
: }
Perhaps using a zero-width negative lookahead assertion:
# untested
if ($line =~ m{ (^192.168.) (?! .*0\.0KB/s .*0\.0KB/s ) }x) {
# ...
}
In your original code, remember that the rightmost predicate can be
expressed more concisely using the !~ operator.
-- fxn
------------------------------
Date: Sun, 18 Nov 2001 06:53:32 GMT
From: shb*NO*SPAM*@comporium.net (Si Ballenger)
Subject: Re: Talking to serial ports?
Message-Id: <3bf75a46.370880169@news.comporium.net>
On Sun, 18 Nov 2001 01:41:21 GMT, "Graham W. Boyes - TOAO.net"
<me@REMOVETHIStoao.net> wrote:
>Picked up a secondhand 3Com ADSL modem. (Yes, legally.) I can't
>Telnet into it because it is password protected. I found this page
>
>http://www.securiteam.com/exploits/5JP0N0U4UO.html
>
>Which brute-forces the password out of the modem. However it tries to
>connect by IP and I need it to connect via the serial port (COM1).
>Ideas?
>
>If it helps, there is little or no delay between it checking to see if
>I've put in a correct password and asking for the prompt for a new
>one. There is no limit to the number of passwords you can guess at a
>time, which should make it easy to brute force.
>
>Graham W. Boyes
From a win95/98 machine that has the DUN 1.3 upgrade, you might
try connecting to it via a null modem serial cable using DCC. The
DCC 1.3 upgrade includes the tcp/ip protocall.
------------------------------
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 2152
***************************************