[23174] in Perl-Users-Digest
Perl-Users Digest, Issue: 5395 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 20 09:05:46 2003
Date: Wed, 20 Aug 2003 06:05:11 -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 Wed, 20 Aug 2003 Volume: 10 Number: 5395
Today's topics:
Re: ##Not interested in Bangin' Code?## <abigail@abigail.nl>
Best practice: initialisation of variables <valid-till-end-Aug@dpw.clara.co.uk>
Catching Apache error with a Perl script <Papabear@Filternet.nl>
Re: Catching Apache error with a Perl script <no@email.com>
Re: Catching Apache error with a Perl script <PapaBear@Filternet.nl>
Re: Catching Apache error with a Perl script (Tony)
Re: comp.lang.perl.open.discussion rfc in alt.config (Randal L. Schwartz)
Re: dogma....re: modules (James Willmore)
Re: dogma....re: modules <peter@semantico.com>
Re: dogma....re: modules <peter@semantico.com>
Re: dogma....re: modules <me@privacy.net>
Re: Encrypting a superuser (UK\)
Re: Encrypting a superuser (UK\)
Explain the method for a newbie <narendranath.ts@in.bosch.com>
Re: Explain the method for a newbie <noreply@gunnar.cc>
Re: file upload in cgi <me@privacy.net>
Re: fuck this little sicko newsgroup <uri@stemsystems.com>
Re: fuck this little sicko newsgroup <spamblock@junkmail.com>
Re: fuck this little sicko newsgroup <jurgenex@hotmail.com>
Let's reflect and re-read the posting guidelines (James Willmore)
Re: Low-level way of fetching UDP datagram as a unit (John Ramsden)
Re: Order of evaluation of expressions <abigail@abigail.nl>
OS/2 line feed question <dave.nospam@ntlworld.com>
Regular expression, getting href which is followed by i (fatted)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 20 Aug 2003 08:18:44 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: ##Not interested in Bangin' Code?##
Message-Id: <slrnbk6bn4.i02.abigail@alexandra.abigail.nl>
Tony (res1kymn@verizon.net) wrote on MMMDCXLI September MCMXCIII in
<URL:news:BB6883CB.3257%res1kymn@verizon.net>:
// Wow! did I get someones attention?
Yes, and goodbye. If you aren't interested in coding, what are you
doing here? This group isn't about support of scripts gotten from
the web. Get your application support from the vendor.
Abigail
--
my $qr = qr/^.+?(;).+?\1|;Just another Perl Hacker;|;.+$/;
$qr =~ s/$qr//g;
print $qr, "\n";
------------------------------
Date: Wed, 20 Aug 2003 10:18:10 +0100
From: RA Jones <valid-till-end-Aug@dpw.clara.co.uk>
Subject: Best practice: initialisation of variables
Message-Id: <j6owhABSzzQ$EwSM@nildram.co.uk>
This is a question about initialization of variables. Below is an
extract of my code (using 'strict' & 'warnings' of course), and it's
looking for changes in the submission form compared to existing data in
a MySQL db:
my %in = $q->Vars(); # stuff that comes in from the web-page
my $ref = query_db(); # gets a hashref from MySQL db via DBI
foreach( @field_names ) { # this array contains the db col names
# initialization of variables line omitted here - see below
if ($in{$_} ne $ref->{$_}) { # do something here, lets say:
print "$_: IN='$in{$_}'; PREV='$ref->{$_}'\n";
}
}
This works fine on UNIX running Apache 1.3.x, but hangs on Win32 running
the same server version. I have grown used to this difference, and I
know that it is probably caused by some 'Use of uninitialized value in
concatenation (.) or string' warnings going to the server error logs.
Presumably the problem occurs whenever I try to use one of the variables
in %in or $ref that does not contain a value.
Although the script runs fine on the production server, I am trying to
get it ready for a mod_perl environment, so need to remove all warnings,
so I have included the following line after the 'foreach' statement :
$in{$_} ||= ''; $ref->{$_} ||= '';
I cannot risk doing a global '$in{$_} ||= '' foreach keys %in' as soon
as %in is defined, in case some of the variables contains a legitimate
'0'. So I do it only when I know the variable cannot contain '0'.
This gets rid of the warnings. But the problem is I have a great many
functions using %in and $ref throughout my script. The question is, do I
have to use the same line as above every time I use %in or create a new
%ref (huge duplication), and is this the correct way to do it anyway, or
should I do this instead:
if ($in{$_} && $in{$_} ne $ref->{$_}) { etc
Or something better still?
--
RA Jones
ra(dot)jones(at)dpw(dot)clara(dot)co(dot)uk
------------------------------
Date: Wed, 20 Aug 2003 12:52:18 +0200
From: "PapaBear" <Papabear@Filternet.nl>
Subject: Catching Apache error with a Perl script
Message-Id: <bhvk23$d56$1@news>
Hi y'all,
I'm handling Apache errors through seperate shtml files. That surely looks
better than the standard error pages by the browser etc. I did this by
coding in httpd.conf lines like:
ErrorDocument 403 http://levi.prodeo/errors/err_403.shtml
ErrorDocument 404 http://levi.prodeo/errors/err_404.shtml
ErrorDocument 405 http://levi.prodeo/errors/err_405.shtml
etcetera.
Now, I would like to handle those through a Perl script file.
For that purpose I coded in httpd.conf lines like:
ErrorDocument 404 http://levi.prodeo/cgi-bin/http_err.pl?err=403
ErrorDocument 404 http://levi.prodeo/cgi-bin/http_err.pl?err=404
ErrorDocument 405 http://levi.prodeo/cgi-bin/http_err.pl?err=405
It does not complain about this URL, but the big question is:
How do I get that error number into my Perl program?
Please spare me the CPAN modules, I think they're overweight. I'd like to
see what I'm coding, so simple solutions if possible...
Tnx in advance,
PapaBear
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GAT/CS/CM/O d+(--) s++:+>: a? C++(+++)$ UL++(+++) P++>+++ L++>+++ E- W+++$
N++ !o !K w !O M- V? PS->$ PE+(-) Y+ PGP t+ 5? !X R- tv b+(+++) DI? !D G(-)
!e h---- r+++ y?
------END GEEK CODE BLOCK------
http://www.geekcode.com
__________________________________
Never mind the bear, beware of Papa!
------------------------------
Date: Wed, 20 Aug 2003 12:09:49 +0100
From: "Brian Wakem" <no@email.com>
Subject: Re: Catching Apache error with a Perl script
Message-Id: <bhvku6$3m44b$1@ID-112158.news.uni-berlin.de>
"PapaBear" <Papabear@Filternet.nl> wrote in message
news:bhvk23$d56$1@news...
> Hi y'all,
>
> I'm handling Apache errors through seperate shtml files. That surely looks
> better than the standard error pages by the browser etc. I did this by
> coding in httpd.conf lines like:
>
> ErrorDocument 403 http://levi.prodeo/errors/err_403.shtml
> ErrorDocument 404 http://levi.prodeo/errors/err_404.shtml
> ErrorDocument 405 http://levi.prodeo/errors/err_405.shtml
>
> etcetera.
>
>
> Now, I would like to handle those through a Perl script file.
> For that purpose I coded in httpd.conf lines like:
>
> ErrorDocument 404 http://levi.prodeo/cgi-bin/http_err.pl?err=403
> ErrorDocument 404 http://levi.prodeo/cgi-bin/http_err.pl?err=404
> ErrorDocument 405 http://levi.prodeo/cgi-bin/http_err.pl?err=405
>
> It does not complain about this URL, but the big question is:
>
> How do I get that error number into my Perl program?
>
>
> Please spare me the CPAN modules, I think they're overweight. I'd like to
> see what I'm coding, so simple solutions if possible...
>
> Tnx in advance,
>
> PapaBear
my ($error_number) = $ENV{QUERY_STRING} =~ /err=(\d+)/;
--
Brian Wakem
------------------------------
Date: Wed, 20 Aug 2003 14:18:19 +0200
From: "PapaBear" <PapaBear@Filternet.nl>
Subject: Re: Catching Apache error with a Perl script
Message-Id: <bhvp3c$ffe$1@news>
Brian Wakem <no@email.com> schreef in berichtnieuws
bhvku6$3m44b$1@ID-112158.news.uni-berlin.de...
>
> my ($error_number) = $ENV{QUERY_STRING} =~ /err=(\d+)/;
>
That works like a charm, tnx a lot Brian!
___________________________________
Never mind the Bear, beware of papa...
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GAT/CS/CM/O d+(--) s++:+>: a? C++(+++)$ UL++(+++) P++>+++ L++>+++ E- W+++$
N++ !o !K w !O M- V? PS->$ PE+(-) Y+ PGP t+ 5? !X R- tv b+(+++) DI? !D G(-)
!e h---- r+++ y?
------END GEEK CODE BLOCK------
http://www.geekcode.com
------------------------------
Date: 20 Aug 2003 05:56:43 -0700
From: ts@relson.net (Tony)
Subject: Re: Catching Apache error with a Perl script
Message-Id: <63073ce9.0308200456.6092c660@posting.google.com>
"PapaBear" <Papabear@Filternet.nl> wrote in message news:<bhvk23$d56$1@news>...
> Hi y'all,
>
> I'm handling Apache errors through seperate shtml files. That surely looks
> better than the standard error pages by the browser etc. I did this by
> coding in httpd.conf lines like:
>
> ErrorDocument 403 http://levi.prodeo/errors/err_403.shtml
> ErrorDocument 404 http://levi.prodeo/errors/err_404.shtml
> ErrorDocument 405 http://levi.prodeo/errors/err_405.shtml
>
> etcetera.
>
>
> Now, I would like to handle those through a Perl script file.
> For that purpose I coded in httpd.conf lines like:
>
> ErrorDocument 404 http://levi.prodeo/cgi-bin/http_err.pl?err=403
> ErrorDocument 404 http://levi.prodeo/cgi-bin/http_err.pl?err=404
> ErrorDocument 405 http://levi.prodeo/cgi-bin/http_err.pl?err=405
>
> It does not complain about this URL, but the big question is:
>
> How do I get that error number into my Perl program?
>
>
> Please spare me the CPAN modules, I think they're overweight. I'd like to
> see what I'm coding, so simple solutions if possible...
>
> Tnx in advance,
>
> PapaBear
>
> -----BEGIN GEEK CODE BLOCK-----
> Version: 3.1
> GAT/CS/CM/O d+(--) s++:+>: a? C++(+++)$ UL++(+++) P++>+++ L++>+++ E- W+++$
> N++ !o !K w !O M- V? PS->$ PE+(-) Y+ PGP t+ 5? !X R- tv b+(+++) DI? !D G(-)
> !e h---- r+++ y?
> ------END GEEK CODE BLOCK------
> http://www.geekcode.com
> __________________________________
> Never mind the bear, beware of Papa!
if you are calling the page like http://levi.prodeo/cgi-bin/http_err.pl?err=405
I would have though that you could just do something like this
#!/usr/bin/perl
use CGI qw(:standard);
$ErrorCode = param('err');
## do what ever on value of $ErrorCode
Regards
Tony
------------------------------
Date: Wed, 20 Aug 2003 10:03:40 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: comp.lang.perl.open.discussion rfc in alt.config
Message-Id: <560bfec6738efbae3232b631dbc2b586@news.teranews.com>
>>>>> "hudson" == hudson <scripts_you_know_the_drill_@hudsonscripting.com> writes:
hudson> I accept that. But I think I know enough to delete a directory
No, apparently not. See my other post.
hudson> or
hudson> parse CGI.
That is being called into question repeatedly.
hudson> Why is everyone confusing doing a simple task with general
hudson> abstraction?
Why are you using hand-written buggy code instead of shorter code
that does the job right?
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 20 Aug 2003 00:41:40 -0700
From: jwillmore@cyberia.com (James Willmore)
Subject: Re: dogma....re: modules
Message-Id: <e0160815.0308192341.3b73bd28@posting.google.com>
hudson <scripts_you_know_the_drill_@hudsonscripting.com> wrote in message news:<9h06kv0d16r2vuqscct4perakmuer2c7t3@4ax.com>...
> Well...having had a bit of experience with this group, and looking
> through some google searches I am a little shocked to see this same
> attitude about modules from as far back as 1998....
>
> I see the same closed minded "it is too hard, so trust the module"
> attitude. The thread that caught my eye was about deleting a
> directory...but just the same attitude overall.
You are just like an admin here at work. It pains me to no end that
he makes all these system calls in Perl when Perl has everything built
in or you can use a module for the same tasks. "Why use a module -
write real code yourself", he says. "Why do all you Perl guys make
things so difficult - just use (grep|awk|sed|head|tail|etc.)", he
says. ARGH!!
It's called "Object Oriented Design". Please read up on it (and I
hope one day this admin will too) and you'll find this to be a rather
pointless discussion -and- that it's not dogma. However, until you do
this, you will always find it to be dogma - just like this admin I
have to deal with.
Now I have to have a smoke and take a couple of asprin ...
Jim
------------------------------
Date: Wed, 20 Aug 2003 09:11:53 +0100
From: Peter Hickman <peter@semantico.com>
Subject: Re: dogma....re: modules
Message-Id: <3f432d49$0$12638$afc38c87@news.easynet.co.uk>
hudson wrote:
> Well...I am told not to do SOAP by myself, not to do CGI by myself,
> not to delete a directory by myself, etc, etc....makes you kind of
> wonder.........
A lot of people here are professional programmers and they got that way
because they knew when to roll their own and when to visit cpan.
For example
Boss: We need an ecommerce site
Hudson: I'm on to it boss
* A week passes *
Boss: Hows the ecommerce site coming along
Hudson: Well the CGI bit is working but the SSL code is flakey and
it's best not to talk about the database interface
Against
Boss: We need an ecommerce site
Me: I'm on to it boss
* Later the same day *
Boss: Hows the ecommerce site coming along
Me: I've visited CPAN and we've got Mason up and running talking to
the database and SSL is working. We have sessions, cookies and
CC processing - when will we be getting the data to load.
In my experience being productive is about knowing which tools to use not
being a l33t coder. Learn CPAN - template toolkit, Class::DBI and the like
will turn you into a superhero. Spend a week coding your own CGI module when
there is a perfectly good module on CPAN will get you sacked!
And the data is always late and in the wrong format :-(
You learn Perl so that you can use CPAN, the only coding that you should be
doing in knitting it all together.
------------------------------
Date: Wed, 20 Aug 2003 09:16:40 +0100
From: Peter Hickman <peter@semantico.com>
Subject: Re: dogma....re: modules
Message-Id: <3f432e68$0$12638$afc38c87@news.easynet.co.uk>
hudson wrote:
> that's not my point Bob, and you know it. My point is I am smart
> enough to write stuff for CGI or SOAP or delete a simple directory and
> people in this newsgroup have this kneejerk attitude that "no...you
> can't do that by yourself" and I think that's wrong.
But your example of deleting a file
hudson> `rm -r $directory`
shows that you are not smart enough to delete a file. It shows that you
haven't the faintest idea of the issues involved. You are not smart you are
l33t (and that is not a complement).
------------------------------
Date: Wed, 20 Aug 2003 23:09:07 +1200
From: "Tintin" <me@privacy.net>
Subject: Re: dogma....re: modules
Message-Id: <bhvkpu$39dou$1@ID-172104.news.uni-berlin.de>
"hudson" <scripts_you_know_the_drill_@hudsonscripting.com> wrote in message
news:bl46kvg0om99o9m1ukf72o9v2ea01cmu6s@4ax.com...
> On Tue, 19 Aug 2003 23:03:00 -0700, hudson
> <scripts_you_know_the_drill_@hudsonscripting.com> wrote:
>
> >Well...I am told not to do SOAP by myself, not to do CGI by myself,
> >not to delete a directory by myself, etc, etc....makes you kind of
> >wonder.........
>
> I mean, come on...I can delete a directory as follows:
>
> `rm -r $directory`
And that works well under Windows, VMS, etc?
------------------------------
Date: Tue, 19 Aug 2003 18:50:24 +0100
From: "JJ \(UK\)" <gee@i.cant.think.why.you'd.want.my.email.address.com>
Subject: Re: Encrypting a superuser
Message-Id: <lHH0b.425$lT.180@newsfep1-gui.server.ntli.net>
Now you've got me thinking....so you mean the flag file could also contain
the name of the latest input file...all I then need to do is make sure that
once it's done, the script deletes the flag file and the input file...nice
Now all I've got to do is learn Perl (well, OK, it doesn't have to be Perl,
but I think I'd like to anyway)
--
JJ (UK)
"Bill" <wherrera@lynxview.com> wrote in message
news:239ce42f.0308190536.30440315@posting.google.com...
> "JJ \(UK\)" <gee@i.cant.think.why.you'd.want.my.email.address.com> wrote
in message news:<u0l0b.883$tS2.747653@newsfep2-win.server.ntli.net>...
> > > Can you not just set up a scheduled task for the script and let it run
as
> > a
> > > more powerful user?
> > >
> > > Matt
> >
> > Nice idea, but no, there is a certain amount of manual checking and the
name
> > of the input file changes from month to month.
>
> So run a script as superuser as a periodic service. The superuser
> script checks for a flag file's existence (-e filename) and reads the
> flag file, if it exists for an input file name and then does the task
> on that named input file. It then deletes the flag file. Might be good
> to use flock() and sleep() here.
>
> The manual checking might still be a problem, but perhaps you can
> extend the above to include two phases. I have something of the sort
> running here. HTH.
------------------------------
Date: Wed, 20 Aug 2003 11:30:58 +0100
From: "JJ \(UK\)" <gee@i.cant.think.why.you'd.want.my.email.address.com>
Subject: Re: Encrypting a superuser
Message-Id: <E3I0b.485$lT.480@newsfep1-gui.server.ntli.net>
"Matt Garrish" <matthew.garrish@sympatico.ca> wrote in message
news:Zet0b.3580$HB4.457370@news20.bellglobal.com...
>
> What exactly is it that this batch file does that requires a more
privileged
> user, then?
Disables accounts (they have the rights to do this)
Renames accounts (not sure)
Deletes H: drive shares (no rights)
Renames H: drive folder and Profile folder (mixed rights depending on
server/local resource domain group membership)
Creates replacement H: drive share based on renemed account (no rights)
> Is there any way you can grant the privileges they need without
> changing their group?
Possibly, but not easy. As you may have gathered from the above list, the
domain in question is in a bit of a mess (before my time! before my time!)
and it's big too...
> Is there any way to rewrite the script so that it
> doesn't require the users to be accessing restricted
files/folders/whatever
> it is you don't want them having access to?
Nope.
> Compiling to an executable, as noted by another poster, is not a
> particularly safe way to hide your passwords, but if that is all you are
> looking for check out perl2exe.
Cool! That may be enough...
--
JJ (UK)
------------------------------
Date: Wed, 20 Aug 2003 15:39:16 +0530
From: "Naren" <narendranath.ts@in.bosch.com>
Subject: Explain the method for a newbie
Message-Id: <bhvhcn$sch$1@ns2.fe.internet.bosch.com>
Hello Grp,
I dont know anything of perl.
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'
This code prints prime if the input is prime
I dont know what is happening
Can anyone kindly give me the C implementation of the same or the algo
followed
Thaanx in advance
Rgds,
Naren.
------------------------------
Date: Wed, 20 Aug 2003 12:31:16 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Explain the method for a newbie
Message-Id: <bhvip4$3l46k$1@ID-184292.news.uni-berlin.de>
Naren wrote:
> Hello Grp,
> I dont know anything of perl.
In that case, why on earth did you post here?
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Wed, 20 Aug 2003 23:06:42 +1200
From: "Tintin" <me@privacy.net>
Subject: Re: file upload in cgi
Message-Id: <bhvkld$39o0k$1@ID-172104.news.uni-berlin.de>
"hudson" <scripts_you_know_the_drill_@hudsonscripting.com> wrote in message
news:e406kvsb6k5r1e9uhke1r6oqqt87eiht4m@4ax.com...
> On Sun, 17 Aug 2003 23:11:26 +1200, "Tintin" <me@privacy.net> wrote:
>
> >
> >"Hudson" <scripts_you-know-the-drill_@hudsonscripting.com> wrote in
message
> >news:bhprjvok773hasvlrngbdug10vp9r7mumm@4ax.com...
> >> very easy...I did it yesterday...if a file is over x bytes, stop the
> >transfer
> >> and unlink the file...what's so hard?
> >
> >Did you use you CGI parsing code that you previously posted to do the
job?
> >
>
> oh...you will hate me for this, but it was a rewrite of some Matt's
> script....but I did get it working. I didn't pay attention to the CGI
> parsing part and just focused on the download part.
So do you see why most of us were telling you that incomplete, hand rolled
CGI parsers are not a good idea?
------------------------------
Date: Wed, 20 Aug 2003 07:23:41 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: fuck this little sicko newsgroup
Message-Id: <x7wud8x05e.fsf@mail.sysarch.com>
>>>>> "TvP" == Tassilo v Parseval <tassilo.parseval@rwth-aachen.de> writes:
TvP> Other than that, I think it's time for you to call in for a
TvP> doctor. You need help.
actually a good spanking would be useful. he is just spoiled little rich
script kiddie who just won't learn from experienced people. and he keeps
promising to shut up and doesn't. amazing how he really thinks he knows
something but doesn't. oh well. we will have to endure his extended
childhood in public. bring out your diapers.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Wed, 20 Aug 2003 00:50:19 -0700
From: "David Oswald" <spamblock@junkmail.com>
Subject: Re: fuck this little sicko newsgroup
Message-Id: <vk6altlvdt2808@corp.supernews.com>
"Uri Guttman" <uri@stemsystems.com> wrote in message
news:x7wud8x05e.fsf@mail.sysarch.com...
> >>>>> "TvP" == Tassilo v Parseval <tassilo.parseval@rwth-aachen.de>
writes:
>
> TvP> Other than that, I think it's time for you to call in for a
> TvP> doctor. You need help.
>
> actually a good spanking would be useful. he is just spoiled little rich
> script kiddie who just won't learn from experienced people. and he keeps
> promising to shut up and doesn't. amazing how he really thinks he knows
> something but doesn't. oh well. we will have to endure his extended
> childhood in public. bring out your diapers.
>
Not sure if 'rich' is even accurate. His Beverly Hills address is actually
an office building. The building houses A A Toys, an Attorney, a tanning
salon, a video store, and numerous other businesses. I wasn't able to find
(on Google) any mention of Suite 389 though. 382 was the closest
numerically, and that was an attorney.
By the way, did you notice in another of his posts that he admitted to using
one of Matt's scripts, editing it here and there, but not looking into the
CGI portion of it? I give up!
------------------------------
Date: Wed, 20 Aug 2003 11:51:24 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: fuck this little sicko newsgroup
Message-Id: <0hJ0b.20736$Bo6.19265@nwrddc03.gnilink.net>
hudson wrote:
> aw...you know what...I'm not going to let you run me off like
> that...fuck that...I'm staying
Ok, now it's certainly time:
*PLONK*
jue
------------------------------
Date: 20 Aug 2003 01:48:15 -0700
From: jwillmore@cyberia.com (James Willmore)
Subject: Let's reflect and re-read the posting guidelines
Message-Id: <e0160815.0308200048.17799df0@posting.google.com>
Others (myself included) have been caught up in various discussions
that have, shall we say, been less than technical. There's a part of
the posting guidelines that goes something like....
Count to ten before posting.
I find myself being baited into NOT counting to ten. Maybe it's lack
of sleep (12 hours is a long shift to work - no matter how busy and
slow you are - at least that's the way it's been for the last 4 days),
maybe it's a full moon, whatever.
Might I suggest that all who come here and those who are here count to
ten (maybe a million in some cases) before posting.
Please don't reply to this and add to the clutter ... just count to
ten before posting in the future :)
If you feel this pressing urge to respond, please do so in private.
Again, save the bandwidth :)
Jim
------------------------------
Date: 20 Aug 2003 02:57:55 -0700
From: john_ramsden@sagitta-ps.com (John Ramsden)
Subject: Re: Low-level way of fetching UDP datagram as a unit
Message-Id: <d27434e.0308200157.15c2b273@posting.google.com>
Benjamin Goldberg <ben.goldberg@hotpop.com> wrote in message news:<3F42C1E6.652053BC@hotpop.com>...
> John Ramsden wrote:
> >
> > I am writing an SNMP trap handler, using Graham Barr's Convert::BER
> > module (which looks excellent, from what I can see) to translate the
> > PDUs from binary to a manageable structure.
> >
> > When reading raw traps from a socket connection, Convert::BER relies
> > on the datagram length which appears near the start of the raw trap
> > string.
> >
> > But, as Barr points out in a source code comment, what is to stop a
> > hacker (or just an erroneous program) sending to an SNMP trap port
> > an SNMP trap datagram with a length longer than tha actual length
> > of the datagram, thus causing the trap handler to hang while it
> > waits for the rest of the datagram which may never appear?
>
> I don't know anything about SNMP, so this is off the top of my head...
>
> A udp datagram arrives in full, or not at all. Thus, "wait for the
> rest of the datagram" doesn't make sense, if it's referring to a udp
> datagram.
That's exactly what I thought, until I started snooping at the source
of Convert::BER. This has its own recv() function, in which a comment
near the start states:
# We do not know the size of the datagram, so we have to PEEK --GMB
# is there an easier way to determine the packet size ??
and then further down in the same function:
# now we know the size, get it again but without MSG_PEEK
# this will cause the kernel to remove the datagram from it's queue
# If the data on the socket doesn't correspond to a valid BER
# object, the loop above could have read something it thought was
# the length and this loop could then block waiting for that many
# bytes, which will never arrive. What do you do about something
# like that?
It appears the author thought that specifying a length larger than
the packet length would cause the following packet to be read or
waited for, like a TCP connection, rather than maintaining a 1-1
correspondence between recv() calls and UDP packets. Or maybe the
Perl Socket module has changed its functionality in relation to
UDP since BER.pm was written? Seems less likely. But anyway,
I'm now reassured. Thanks!
> Thus, you must mean, "waits for the rest of the PDU," which I assume
> is allowed to consist of multiple UDP packets.
The SNMP standards (RFC 1157 for v1 and RFC 1902 for v2) specify that
each PDU ('Protocol Data Unit', i.e. SNMP message) should fit in one
UDP packet, although the latter could be split at lower TCP/IP levels
if the TCP MTU is less than the maximum UDP packet size and exceeded
by a PDU size. (Of course, some SNMP requests, such as 'get bulk' can
result in more than one message being returned.)
Cheers
John Ramsden (john_ramsden@sagitta-ps.com)
------------------------------
Date: 20 Aug 2003 08:09:36 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Order of evaluation of expressions
Message-Id: <slrnbk6b60.i02.abigail@alexandra.abigail.nl>
John W. Krahn (krahnj@acm.org) wrote on MMMDCXLI September MCMXCIII in
<URL:news:3F42BCBC.276477FC@acm.org>:
() Abigail wrote:
() >
() > John W. Krahn (krahnj@acm.org) wrote on MMMDCXL September MCMXCIII in
() > <URL:news:3F417BDC.7F24A9F3@acm.org>:
() > ==
() > == Just going by perlop.pod, shift() is a named unary operator which has
() > == lower precedence than . and . is left associative which would mean it
() > == would evaluate the left side first. Correct me if I'm wrong. :-)
() >
() > Precedence isn't the same as order of evaluation.
()
() Yes I know. What I was trying to say is that the concatenation operator
() is left associative so that:
()
() shift(@a) . shift(@b) . shift(@c) . shift(@d)
()
() will be always be evaluated as:
()
() ( ( shift(@a) . shift(@b) ) . shift(@c) ) . shift(@d)
()
() unless you explicitly parenthesise the expression. So it should follow
() that if shift(@a) . shift(@b) . shift(@c) is always evaluated before
() shift(@d) and shift(@a) . shift(@b) is always evaluated before
() shift(@c), shouldn't it follow that shift(@a) is evaluated before
() shift(@b)?
No, now you are confusing precedence and order of evaluation again.
Abigail
--
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
"\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
"\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
------------------------------
Date: Wed, 20 Aug 2003 13:42:54 +0100 (BST)
From: "Dave Saville" <dave.nospam@ntlworld.com>
Subject: OS/2 line feed question
Message-Id: <qnirfnivyyragyjbeyqpbz.hjxiji2.pminews@text.news.ntlworld.com>
Needing to remove line feeds, but actually having both CRLF & LF data I
did some poking about.
#!/usr/local/bin/perl -w
$crlf = "\x0d\x0a";
$lf = "\x0a";
print "lf\n" if $lf eq "\n";
print "crlf\n" if $crlf eq "\n";
while (<>)
{
s/$crlf/- crlf -/gs; # clean crlf
s/$lf/- lf -/gs; # clean lf
print ">$_<\n";
}
1) $lf is *always* equal to \n
2) The \n in the print statements, checked with a hexdumper *always*
writes CRLF
3) irrespective of the input data having crlf or lf it *always* says
its LF
I ran the same tests on Solaris
1) is still true
2) \n produces lf - as expected
3) It can see the difference between crlf data & lf data
So whats wonky in the OS/2 port?
Further - on the web what would I get from $cgi->param if the browser
sent a line feed? I am thinking a comments field on a form. Do they
send platform specific line feeds?
Regards
Dave Saville
NB switch saville for nospam in address
------------------------------
Date: 20 Aug 2003 03:04:38 -0700
From: fatted@yahoo.com (fatted)
Subject: Regular expression, getting href which is followed by img tag with specific src
Message-Id: <4eb7646d.0308200204.61f63d61@posting.google.com>
From a html file, I'd like to extract a href value of an <a> tag which
contains an <img> tag who's src value I'm searching on.
Basically (but theres more!):
<a href="IwantThis.html"><img src="importantimage.gif"></a>
(Un)Interesting part:
I first match a line from the html file containing importantimage.gif,
I then try to find my href value on this line.
But this line contains multiple <a> tags, (which have href values and
might also have an <img> tag with associated src value). Also all of
the <a> tags and <img> tags have more than one attribute.
So the line actually looks something like this:
<a class="red" href="uninteresting.html" target="_new">Not so exciting
text</a><a href="equallyboring.html" class = "blue">yawn</a><a
class="green" href="IwantThis.html"><img border="0"
src="importantimage.gif" alt="MeMe"></a>
My code:
use warnings;
use strict;
open(FILE,"<","4body.html");
while(<FILE>)
{
my $line = $_;
if($line =~ /importantimage\.gif/i)
{
if($line =~ /<a.+?href="(.+?)".+?src="importantimage\.gif".+?><\/a>/)
{
print $1."\n";
}
}
}
which results in:
uninteresting.html
I think I understand why it gets this value, but I can't get the value
I want :)
------------------------------
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 5395
***************************************