[10743] in Perl-Users-Digest
Perl-Users Digest, Issue: 4342 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 2 13:07:32 1998
Date: Wed, 2 Dec 98 10:00:23 -0800
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, 2 Dec 1998 Volume: 8 Number: 4342
Today's topics:
Re: AAH Re: How to use Perl-script as filter? (I R A Aggie)
Re: Converting HTML tag and attribute case - Regular Ex <kadi0012@fh-karlsruhe.de>
Cookie problem <WeAreUs@Ibm.net>
Re: decimal to binary (Steffen Beyer)
Re: decimal to binary <tbriles@austin.ibm.com>
Re: die() message available at END time? chess@watson.ibm.com
Re: Difficult Pattern Matching <newsposter@cthulhu.demon.nl>
Re: field selection using "split" - question <tbriles@austin.ibm.com>
Re: field selection using "split" - question (Bart Lateur)
Help... broken dbmopen going from 5.004 to 5.005_02 <mgrommet@insolwwb.net>
Re: html vs. cgi via perl (Leslie Mikesell)
more on cookie problem reported earlier <WeAreUs@Ibm.net>
Re: Need 5.003 source code for UNIX <jth@sci.fi>
newbie question dennishancy@eaton.com
Re: newbie question <ebohlman@netcom.com>
Perl DBI and Flex/ODBC Driver dwells@ints.com
Re: PERL is TOO flexible <kadi0012@fh-karlsruhe.de>
Re: Perl on Solaris 2.5.1 (#!/opt/LWperl/bin)? <Dave.Carrigan@cnpl.enbridge.com>
Re: Perl on Solaris 2.5.1 (#!/opt/LWperl/bin)? (Casper H.S. Dik - Network Security Engineer)
Re: Perl on Solaris 2.5.1 (#!/opt/LWperl/bin)? <ljz@asfast.com>
Re: PerlScript-Cookies??? <jamesht@idt.net>
Raw socket mutilates datagrams <jurgen@pallas.tid.es>
Re: Serial programming question <letual@hotmail.com>
server side includes for banner ad script <nospam23_skidoo@geocities.com>
Re: shopping cart <jamesht@idt.net>
Re: Simple Security <richgrise@entheosengineering.com>
Sorting VERY large files effeciently andy-markham@mindspring.com
Re: Sorting VERY large files effeciently <garethr@cre.canon.co.uk>
spider framework? <jamesht@idt.net>
Re: Substitute <jc@eddie.mit.edu>
Re: unsubscribe <rkoehler@osmre.gov>
Untainting Question (Mike D.)
Re: Why is "... @foo ..." occasionally a syntax error? <jc@eddie.mit.edu>
Re: Why is "... @foo ..." occasionally a syntax error? <jc@eddie.mit.edu>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 02 Dec 1998 11:02:41 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: AAH Re: How to use Perl-script as filter?
Message-Id: <fl_aggie-0212981102410001@aggie.coaps.fsu.edu>
In article <36655476.E3E52F1D@amdiv.de>, Kay Molkenthin
<k.molkenthin@amdiv.de> wrote:
+ open (IN, <STDIN>); ?Correct???
+ Read it into an array
+ close (IN);
Close, but not quite. From _The Perl Cookbook_, 7.7 Writing a Filter:
Read lines with <>:
while(<>) {
#do something with the line
}
+ Do something with the text in the array:
+ Print ???? the array back again to <STDOUT> ???
Yes. Since that's the default, you merely need to:
print;
in the while() loop - that will allow you to process the incoming data stream
line-by-line, which may be useful on very large files...
James
------------------------------
Date: Wed, 02 Dec 1998 19:01:08 +0100
From: Dirk Kaufmann <kadi0012@fh-karlsruhe.de>
Subject: Re: Converting HTML tag and attribute case - Regular Expression help
Message-Id: <36658063.C181C7AC@fh-karlsruhe.de>
Jonathan Stowe wrote:
> On Tue, 10 Nov 1998 00:34:21 GMT Lee Borkman <borkman@usa.net> wrote:
> > Hi all,
> >
> > I am trying to make an RE to convert all HTML tag names and tag
> > attribute names to upper case. The attribute values must be
> > unchanged. For example, I want to convert:
> >
>
> As Tom has already pointed out you really dont want to be be using a
> Regular Expression to do this - but as luck would have it I already have
> made a script that will do what you want (and a little more).
>
> <URL:http://www.btinternet.com/~gellyfish/resources/htbeauty.htm>
>
> It probably could do with a little work but hey !
>
> /J\
> --
> Jonathan Stowe <jns@btinternet.com>
> Some of your questions answered:
> <URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
in order to give compression tools a better chance doing their job
you should prefer to set tags down case.
this might be important in future if scripts are sent through slow network
areas
in the consumer market. I think of sattelite links for handys and tv. the
pure
mass of this "future users" might cause a significant slow down on net
transfers,
so it becomes impossible not to use compression.
of course upper case tags look prettier, but have you ever wrote upper case
by
your own hand ?
I think you only want to highlight the tags for visuability during
programming.
if so, use an editor that can use different color.
and always remember: you can write better code than any generator !
------------------------------
Date: Wed, 02 Dec 1998 16:24:36 GMT
From: "Warren Baker" <WeAreUs@Ibm.net>
Subject: Cookie problem
Message-Id: <8Rd92.1966$Q92.2063055@news.rdc1.bc.wave.home.com>
Hi all!
I've fallen in love with Perl and CGI. In the 3 weeks or so that I've been
studying it I've had great success with it and am quite impressed with the
power of the language and the speed with which one can develop apps.
However! I currently have this evil problem that I can't see to get
through. I'm trying to set a cookie (I know that I should have code to
detect prior existence of said cookie before setting it, but right now I
just want to figure a way to actually set the cookie on my own machine for
experimental purposes).
Can someone point me in a more positive direction? Here is my code:
#!/usr/bin/perl
$|=1;
$theDomain = 'www.WarrenB.com';
print "HTTP/1.0 200 OK \n Content-type: text/html \n Set-Cookie:\"IDENT\"=5;
expires='Wednesday, 02-Dec-98 23:12:40 GMT'; path=\"/\"; domain=$TheDomain;"
;
print "<head></head>";
print "</HTML></BODY>";
It stikes me that this is the simplest formulation possible, yet it doesn't
work. . .
Any advice will be appreciated. Thanks very much!
Cheers!
--Warren Baker
------------------------------
Date: 2 Dec 1998 16:47:17 GMT
From: sb@engelschall.com (Steffen Beyer)
Subject: Re: decimal to binary
Message-Id: <743qul$184$1@en1.engelschall.com>
Aaron Young <ayoung@sigg.com> wrote:
> I'm sure this has more to do with my misunderstanding of the
> documentation than anything else
> but
> I am just not understanding what I've read, so I come to CLPM for
> clarification
> How would one convert 7 to 00000111?
> or even 00000000000000000000000000000111
> granted, I do not have a lot of experience with binary representations
> of decimals, but I need to be able to convert back and forth between the
> two
> I know it has something to do with the pack operator (or at least I
> believe it does) but I'm not getting out of the docs what it probably
> glaringly obvious
> assistance is appreciated
Perl modules are your friend.
You might want to check out the Bit::Vector module which does
binary <-> decimal conversions very efficiently.
Available from
http://www.engelschall.com/u/sb/download/
http://www.perl.com/CPAN/authors/id/STBEY/
HTH.
Yours,
--
Steffen Beyer <sb@engelschall.com>
Free Perl and C Software for Download:
http://www.engelschall.com/u/sb/download/
New: Build'n'Play 2.1.0 (all-purpose Unix batch installation tool)
------------------------------
Date: Wed, 02 Dec 1998 11:31:05 -0600
From: Tom Briles <tbriles@austin.ibm.com>
Subject: Re: decimal to binary
Message-Id: <36657959.89396659@austin.ibm.com>
Aaron Young wrote:
> I'm sure this has more to do with my misunderstanding of the
> documentation than anything else
>
> but
>
> I am just not understanding what I've read, so I come to CLPM for
> clarification
>
> How would one convert 7 to 00000111?
>
> or even 00000000000000000000000000000111
>
> granted, I do not have a lot of experience with binary representations
> of decimals, but I need to be able to convert back and forth between the
> two
>
> I know it has something to do with the pack operator (or at least I
> believe it does) but I'm not getting out of the docs what it probably
> glaringly obvious
>
> assistance is appreciated
>
> Aaron
>From perldoc -f pack :
Quote:
sub bintodec {
unpack("N", pack("B32", substr("0" x 32 . shift, -32)));
}
Unquote.
If you have a variable name, you would similarly use:
$decimal = unpack("N", pack("B32", substr("0" x 32 . $binary, -32)));
For decimal to binary:
$binary = unpack("B*", pack("N", $decimal));
HTH,
Tom B.
------------------------------
Date: Wed, 02 Dec 1998 16:07:57 GMT
From: chess@watson.ibm.com
Subject: Re: die() message available at END time?
Message-Id: <743okr$r74$1@nnrp1.dejanews.com>
In article <MPG.10ce2f87f6c6916f98974a@news.scescape.net>,
dragons@scescape.net (Matthew Bafford) wrote:
>
> $SIG{__DIE__} = sub { # msg in @_
> # ...
> # ...
> };
>
> be of any use?
Thanks! I have an irrational fear of $SIG. Also, I'd like to have all
the end-time processing code together, regardless of the reason for ending
(hence my desire to do it in an END{}). It occurs to me that this
should work:
eval {
# absolutely everything goes here
};
$diemsg = $@;
END {
# stuff using $diemsg
};
Any caveats in that? Or, if I weren't afraid of $SIG, I could use
your suggestion instead of one big eval, and do
$SIG{__DIE__} = sub { $diemsg = shift };
# stuff
END {
# stuff using $diemsg
}
DC
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 02 Dec 1998 11:04:05 +0100
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: Difficult Pattern Matching
Message-Id: <36651094.8A2FAA4D@cthulhu.demon.nl>
Ronald J Kimball wrote:
> > After solving this problem, I have an interesting followup assignment:
>
> Is that "assignment" as in "homework assignment"?
I should have added 'for <name of person starting thread>' at the end
of that 'After solving ...' sentence. Sorry about the confusion.
> We're not here to do your homework assignments for you.
The only homework assignments I get are doing the dishes and taking out
the garbage. But anyone is welcome to do that for me :)
Erik
------------------------------
Date: Wed, 02 Dec 1998 10:12:47 -0600
From: Tom Briles <tbriles@austin.ibm.com>
Subject: Re: field selection using "split" - question
Message-Id: <366566FF.6F9ED561@austin.ibm.com>
Tom Phoenix wrote:
> On Mon, 30 Nov 1998, Jonathan Cook wrote:
>
> > Does anyone know a more elegant way of selecting the last field from
> > an arbitrary length string like this:
> >
> > $str = "/dir1/dir2/filename";
> >
> > @tmp_array = split(m:/:, $str);
> > $last_field = $tmp_array[$#tmp_array]; # $last_field = "filename"
>
> use File::Basename;
>
> Sure, you could do this unportably, but why? Hope this helps!
>
> --
> Tom Phoenix Perl Training and Hacking Esperanto
> Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Tom P.'s way is portable, and definitely the best way to go.
However, I'll throw this in, since the "-" element feature may be new to you.
$str = "/dir1/dir2/filename";
$last_field = (split(m:/:, $str))[-1];
HTH,
Tom B.
------------------------------
Date: Wed, 02 Dec 1998 16:37:04 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: field selection using "split" - question
Message-Id: <36666b99.2691050@news.skynet.be>
Tom Briles wrote:
>However, I'll throw this in, since the "-" element feature may be new to you.
>
>$str = "/dir1/dir2/filename";
>
>$last_field = (split(m:/:, $str))[-1];
Which reminds me... :-)
The [-1] subscript is very nice for taking the last element of an array.
But it |!#|@!~ doesn't work for ranges.
For example, this does not work to take everything but the first array
element:
@ary[1..-1]
You HAVE to use
@ary[1..$#ary]
which is very irritating if you need it for temporary arrays with no
name; like (split /\//).
(Yes, I KNOW I can also use shift or splice, it's just an example.)
Bart.
------------------------------
Date: Wed, 2 Dec 1998 10:49:01 -0600
From: "Mike" <mgrommet@insolwwb.net>
Subject: Help... broken dbmopen going from 5.004 to 5.005_02
Message-Id: <743ueb$4nb$1@alpha.insolwwb.net>
Hi guys... doing a server upgrade here.
I have several scripts that utilize the dbmopen function
but when I moved these scripts over to my new machine,
it seems to ignore the dbmfiles...
I get absolutely nothing out of them...
The old machine (which works) is running 5.004something
and the new one is a newly compiled 5.005_02 with gdbm support...
but still no dice...
heres a snippit of source:
dbmopen(%addresses,'/cgi-bin/christianmovies/emails',0666);
@keys = keys %addresses;
$i=1;
foreach $key (sort(keys %addresses))
{ print $i++;
print "\n"; }
which should count the # of records in the file, but I get NOTHING.
no errors, no anything...
what am I missing here?
------------------------------
Date: 2 Dec 1998 10:38:59 -0600
From: les@MCS.COM (Leslie Mikesell)
Subject: Re: html vs. cgi via perl
Message-Id: <743qf3$1otm$1@Mars.mcs.net>
In article <MPG.10c97e132ecbe95098968d@news.ndh.com>,
Mike <mike@lovetalk.de> wrote:
>Does anyone have any idea on how to ping a cgi-script ?? (not just the
>ip)
>
>I would like to write a script that compares html vs. cgi response times
>on a server.....
>
The apache distribution comes with a program called ab (apache benchmark)
in the support directory. It is pretty good for simple timings - LWP
based requests can be slower on the client than what the server can
actually do. However, ab doesn't handle authentication as far as I
can tell. Is there a similar program that can access protected pages
at high speed?
Les Mikesell
les@mcs.com
------------------------------
Date: Wed, 02 Dec 1998 17:21:08 GMT
From: "Warren Baker" <WeAreUs@Ibm.net>
Subject: more on cookie problem reported earlier
Message-Id: <8Ge92.1970$Q92.2094696@news.rdc1.bc.wave.home.com>
A little more on the previously reported cookie problem that I'm having.
The code below "flies" in terms of CGI and syntax. BUT all it does is print
"Set-Cookie ...blah blah" and it doesn't set the cookie. This is a
problem I had earlier with print "location: blah blah"; as well. What am
I doing wrong? This printing vs. setting problem has been a mystery to me
for a good 10 days and I've been "hacking" a solution by means of javascript
for any setting that is done via print.
Thanks!
syntactically correct but logic-ly wrong code follows:
#!/usr/bin/perl
$|=1;
use CGI qw(:standard);
print header(), start_html(' '),, h1(" ");
print "<BODY>";
print "Set-Cookie:IDENT=5; path=/; expires='Wednesday, 02-Dec-98 23:12:40
GMT' ";
print "<body>";
print "Test the cookie";
print "</BODY></HTML>";
------------------------------
Date: Wed, 2 Dec 1998 18:23:32 +0200
From: "Jouni Honkala" <jth@sci.fi>
Subject: Re: Need 5.003 source code for UNIX
Message-Id: <743pda$orf$1@tron.sci.fi>
You got lucky, it's still there!
See http://www.cpan.org/src/5.0/maint/ or the respective directory on
your nearest CPAN site.
Mail Server Administrator kirjoitti viestissd
<3663F30C.CF50EDA6@moody.edu>...
>Where can I get Perl 5.003 source code for UNIX?
>
------------------------------
Date: Wed, 02 Dec 1998 16:22:08 GMT
From: dennishancy@eaton.com
Subject: newbie question
Message-Id: <743pfb$ru1$1@nnrp1.dejanews.com>
I have a CGI script that looks like this:
open(STATS,">>../stats.txt");
$mydate = `date`;
print STATS "$mydate"." "."$ENV{HTTP_USER_AGENT} \n";
close STATS;
How come when I run this script, my output looks like this?
Wed Dec 2 11:28:46 GMT 1998
Mozilla/4.06 [en] (Win95; I)
Shouldn't everything be on the same line?
Dennis
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 2 Dec 1998 16:50:05 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: newbie question
Message-Id: <ebohlmanF3CK3H.3oB@netcom.com>
dennishancy@eaton.com wrote:
: I have a CGI script that looks like this:
: open(STATS,">>../stats.txt");
: $mydate = `date`;
: print STATS "$mydate"." "."$ENV{HTTP_USER_AGENT} \n";
: close STATS;
: How come when I run this script, my output looks like this?
: Wed Dec 2 11:28:46 GMT 1998
: Mozilla/4.06 [en] (Win95; I)
: Shouldn't everything be on the same line?
The output captured from the `date` command has a trailing newline.
Some comments:
1) You should always check that an attempt to open a file was successful.
2) Relative paths in CGI scripts are a bad idea; they often wind up being
relative to something other than what you expected.
3) There are better, more platform-independent ways of getting the
current date.
4) You should read up a little more on variable interpolation. Your
print could have been done with only one quoted string.
------------------------------
Date: Wed, 02 Dec 1998 16:04:52 GMT
From: dwells@ints.com
Subject: Perl DBI and Flex/ODBC Driver
Message-Id: <743of1$qs9$1@nnrp1.dejanews.com>
I am trying to use FlexQuarters' Flex/ODBC driver to connect to DataFlex
databases. I have been able to connect using their supplied sample programs,
but so far have been unable to establish a connection with PERL and DBI. Has
anyone used this driver?
Doug Wells
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 02 Dec 1998 18:32:44 +0100
From: Dirk Kaufmann <kadi0012@fh-karlsruhe.de>
Subject: Re: PERL is TOO flexible
Message-Id: <366579BC.26BB558A@fh-karlsruhe.de>
Jerome O'Neil wrote:
> Andrew Johnson wrote:
>
> > I don't know why people always insist on programs being readable by
> > those who don't know, or are new to, the given language --- sure, its
> > a mark of readability if a programmer unfamiliar with language X can
> > read language X to some degree ... but, come on, language X was
> > designed to be read by language X programmers---people who have
> > learned at least something about language X. I'm sure German is
> > perfectly readable to those who know German, but is it more or
> > less readable than English?
>
> I would go so far as to say that for any given non-perl programmer, perl
> is far more readable than most other languages. I try to write
> maintainable code, knowing that the person maintaining it behind me
> might not be so perly. It's a great language as far as that goes.
think about that there are always beginners, otherwise the laguage is gonna
die.
------------------------------
Date: 02 Dec 1998 09:32:06 -0700
From: Dave Carrigan <Dave.Carrigan@cnpl.enbridge.com>
Subject: Re: Perl on Solaris 2.5.1 (#!/opt/LWperl/bin)?
Message-Id: <8667bubj3t.fsf@cnpl.enbridge.com>
>>>>> "Mike" == Mike Marshall <removeMike@SinglepointSys.com> writes:
Mike> On Solaris 2.5.1, I'm loading Perl from the sunfreeware.com site.
Mike> I'm curious.
Mike> This package loads into /opt/LWperl. Perl scripts, in general,
Mike> have a sh-bang line (#!/usr/bin/perl) of /usr/bin/perl, or
Mike> /usr/local/perl, etc...
I put it in /opt/perl and have a symlink to it as /usr/bin/perl. I
personally do not like to put everything in /usr/local because I end up
with 1000s of files in /usr/local/bin, so I split off the big packages
into /opt/pkgname and live with a much longer search path.
Our site has software that makes it easy to manage your environment with
respect to variaus software packages, so dealing with a huge search path
isn't a big deal.
--
Dave Carrigan (Dave.Carrigan@cnpl.enbridge.com)
Sr. Technical Analyst, Technology Services
Enbridge Pipelines Inc.
------------------------------
Date: 2 Dec 1998 16:50:39 GMT
From: Casper.Dik@Holland.Sun.Com (Casper H.S. Dik - Network Security Engineer)
Subject: Re: Perl on Solaris 2.5.1 (#!/opt/LWperl/bin)?
Message-Id: <casper.912617413@nl-usenet.sun.com>
[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]
Aleksandar Milivojevic <alex@srce.hr> writes:
># ln -s /opt/LWperl/bin/perl /usr/bin/perl
>Usualy, perl scripts either expect to find /usr/bin/perl or have some
>wired paths so you'll have to change them anyway.
That's why I like:
#!/usr/bin/env perl
best. (As long as perl is in your PATH, it works)
Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
------------------------------
Date: 02 Dec 1998 12:29:49 -0500
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Perl on Solaris 2.5.1 (#!/opt/LWperl/bin)?
Message-Id: <ltemqi8naq.fsf@asfast.com>
Casper.Dik@Holland.Sun.Com (Casper H.S. Dik - Network Security Engineer) writes:
> Aleksandar Milivojevic <alex@srce.hr> writes:
>
> ># ln -s /opt/LWperl/bin/perl /usr/bin/perl
>
> >Usualy, perl scripts either expect to find /usr/bin/perl or have some
> >wired paths so you'll have to change them anyway.
>
> That's why I like:
>
> #!/usr/bin/env perl
>
> best. (As long as perl is in your PATH, it works)
The only pitfall is that on a few OS's that support the `#!'
mechanism, you cannot have any arguments following `perl' on that
line.
For example, this sometimes doesn't work:
#!/usr/bin/env perl -w
Of all the Unix-based OS's I have access to, here are the ones
it works on:
FreeBSD 2.2.7
BSDI 3.0
Solaris 2.5.1
It doesn't work on this one:
Linux 2.0.31
--
Lloyd Zusman ljz@asfast.com
perl -le '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
$t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
$x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x"'
------------------------------
Date: Wed, 02 Dec 1998 11:44:04 -0500
From: jamesht <jamesht@idt.net>
To: rohan666@my-dejanews.com
Subject: Re: PerlScript-Cookies???
Message-Id: <36656E54.B5BEDE58@idt.net>
Hello,
When the url gets to the server, it has no idea whether or not the request came
from a link or a javascript or a spider, etc... . You would handle the request
same as always...
There are a few ways to do this. Let me know if you need to be pointed to one.
As for the Javascript side, it's like this:
if you want it to be GET:
query = "http://www.test.com/cgi-bin/script.cgi?thisvalue=" + variable;
document.location.href = query;
if you want it to be POST:
put this in the form:
<INPUT TYPE="hidden" NAME="thisvalue" VALUE="">
<INPUT TYPE="button" NAME="submit_button" VALUE="Submit"
onclick="load_javascript_variables();">
then do something like this:
function load_javascript_variables() {
document.forms[0].thisvalue.value = a_javascript_variable;
document.forms[0].submit();
}
I hope this helps. If not, let me know. I've done this exact thing.
James
rohan666@my-dejanews.com wrote:
> I have a problem.... I need to GET users input from a shopping cart web site
> done in JavaScript and take their selection to another domain where a secure
> server can process the order. I am working on a Perl Script that can redirect
> those selected items to another domain, but I have no clue how to correctly
> code the PerlScript on grabbing variables from a JavaScript. AAARRRGGGHHH!!!
> If you think you have a plan of action, pleeezz let me know... You can see
> the site in question at http://www.wholesalerestaurant.com
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 02 Dec 1998 15:16:20 +0000
From: Jurgen Koeleman <jurgen@pallas.tid.es>
Subject: Raw socket mutilates datagrams
Message-Id: <366559C4.2AA24BDE@pallas.tid.es>
I am not sure whether this problem is directly related to perl, but
anyway ...
I am trying to send an UDP datagram via a raw socket, and according to
the output of tcpdump I succeed in doing that, although the datagram is
modified. In the IP header the fields "identification" and "checksum" are
different from what I sent and in the UDP header the checksum is different
(wrong I would say) as well.
Why is the datagram modified and how can I prevent the data from being
modified?
The following example shows (hopefully) more clearly what I mean. The data
for the datagram was taken from a tcpdump of a UDP ping (with Net::PING).
I try to send a datagram with the following data:
IP_Version 4
IP_IHL 5
IP_TOS 0
IP_tot_len 29
IP_Id 18835
IP_Flags "010" (Don't fragment)
IP_FragOff 0
IP_TTL 255
IP_proto 17 (UDP)
IP_checksum 0x1c8d
IP_src_addr 1.0.8.251
IP_dst_addr 1.0.10.181
UDP_src_port 35949
UDP_dst_port 7 (echo)
UDP_length 9
UDP_checksum 0x5cb8
DATA 0x01
The perl script:
############################# SCRIPT #########################################
#!/usr/bin/perl -w
#
use strict;
use diagnostics;
use Socket;
my ($dest, $data);
my ($t, $cnt);
# Open raw socket
socket(S, PF_INET, SOCK_RAW, 255) or die $!;
# Set up datagram
$data = pack("C C S S B16 C C S L L S S S S C",
# IP header
0x45, 0, 29,
18835, "010" . "0000000000000",
255, 17, 0x1c8d,
0x010008fb,
0x01000ab5,
# UDP header
35949, 7,
9, 0x5cb8,
# Data
0x01,
);
# Print datagram for debugging
foreach $t (unpack("C*", $data)) {
printf "%.2x%s", $t, ($cnt++ % 2) ? " " : "" ;
}
print "\n";
# Set destination to whatever, for the destination is already included
# in the datagram. It's that send requires it
$dest = sockaddr_in(0, inet_aton("0.0.0.0"));
die $! unless defined $dest;
send(S, $data, 0, $dest) or die $!;
close(S);
########################## END OF SCRIPT #####################################
The script tries to send the following datagram:
4500 001d 4993 4000 ff11 1c8d 0100 08fb 0100 0ab5 8c6d 0007 0009 5cb8 01
According to the tcpdump is sent:
15:55:27.990959 pallas.35949 > jerte.echo: udp 1 (DF) (ttl 255, id 15832)
4500 001d 3dd8 4000 ff11 2848 0100 08fb
0100 0ab5 8c6d 0007 0009 0009 01
So the identifier (0x4993) is changed in 0x3dd8, the IP checksum from 0x1c8d
into 0x2848 (I suppose due to the fact that id in header changed) and
the UDP checksum modified from 0x5cb8 into 0x0009.
How can I prevent the datagram is modified? Should I open or set a socket
in a different way?
Is there somebody who could help me?
Thanks in advance,
Jurgen Koeleman
------------------------------
Date: Wed, 02 Dec 1998 12:28:11 -0500
From: letual <letual@hotmail.com>
Subject: Re: Serial programming question
Message-Id: <366578AB.77E498A2@hotmail.com>
<layman advice>
If you check out your camera cable you _might_ find that all pins map to one another
except for pins two and three, which cross. If this is the case, you have a null
modem cable (the same cable you use to hook up say, a dumb terminal to your serial
port). Pin 2 and 3 are Transmitted Data and Received Data. A (data) bit sent from
your computer will leave the computer via pin 3 and enter your camera (or dumb
terminal or whatever) riding pin 2. You can set up the serial port with setserial,
and send a BREAK to get your attn/reset thinger. I've never dealt with a serial
camera (although I'de love to), only dumb terminals (a really cool Volker-Craig
circa 1975). I may, therefore, be full of shit.
As for dealing with the serial port in perl, I've never done that, but my first
assumption would be to treat /dev/cuaX like any other file...
</layman advice>
Peace,
Jamie
------------------------------
Date: Wed, 02 Dec 1998 16:54:18 +0000
From: 23_skidoo <nospam23_skidoo@geocities.com>
Subject: server side includes for banner ad script
Message-Id: <366570B0.7907@geocities.com>
hi,
i'm fairly new to server side includes but it seems to me that they'd be
a great way to rotate ad banners on a number of pages across a site. so
far so what.... i'd like to know if you can use SSI to make a page on
one site run a script to deliver content on another server.
if not, how would you approach the problem of having a script on my
server that could place randomly selected ads on sites on other servers?
did that make sense? hope so. cheers to anyone who takes the time to
answer
-23
p.s. remove nospam from my return address to mail me.
------------------------------
Date: Wed, 02 Dec 1998 11:57:13 -0500
From: jamesht <jamesht@idt.net>
To: Dustin Puryear <dpuryear@usa.net>
Subject: Re: shopping cart
Message-Id: <36657169.7AA65CA7@idt.net>
Hello,
Selena Sol has a ton of free scripts, including a well-documented cart.
There's also a book on that script, CGI for Commerce, if you need it, but
most of the book comes as documentation in the code...
http://btgix8.bgi.uni-bayreuth.de/~joku/selena/.webdocs/Scripts/index.html
James
Dustin Puryear wrote:
> I'm looking for a free shopping cart program that is well documented. Any
> suggestions?
>
> Regards, Dustin
>
> --
> Dustin Puryear, student, Louisiana State University
> dpuryear@usa.net * ICQ 6644253
> Help Crack Government Encryption: www.distributed.net
------------------------------
Date: Wed, 02 Dec 1998 11:30:29 +0000
From: Rich Grise <richgrise@entheosengineering.com>
Subject: Re: Simple Security
Message-Id: <366524D5.772CEDF1@entheosengineering.com>
Martien Verbruggen wrote:
>
> In article <73hog9$dq0$1@nnrp1.dejanews.com>,
> bkraymond@geocities.com writes:
> > How may I compile my perl application out of its original text format? >
[...]
> # perldoc perlfaq3
> =head2 How can I compile my Perl program into byte code or C?
[...]
> Martien
> --
Well, I'll be! So that's what "perldoc" means. Where in
the HOWTOs or man perl was I supposed to read about the
perldoc command? I just tried it and found out that it
works, but I had to find out about it in this NG.
Oh, well, whatever works. :)
--
Rich Grise
richgrise@entheosengineering.com
(No need to futz with my e-mail: I have a "delete" button!)
------------------------------
Date: Wed, 02 Dec 1998 15:48:14 GMT
From: andy-markham@mindspring.com
Subject: Sorting VERY large files effeciently
Message-Id: <743nft$q1u$1@nnrp1.dejanews.com>
I have recently started working with a group that does some work on an
HP3000. Since there is a 4GB limit on that machine, they have to find a new
way to do some effecient sorting of data files that exceed that limit. They
have been looking at a couple of packages on HPUX to do the job, CoSORT
(~$2K) and something else that is on the order of $20K. It turns out that
CoSORT can't handle it, so they are thinking about writing a $20K check to
solve the problem.
My first thought is, can't Perl be used to sort a really large flat file in
an effecient manner? Hell, Perl can do everything else I've ever asked it to
do...
I don't plan on writing and testing out a bunch of sort routines, so
basically I'm hoping that someone on this group has already tackled this
problem and has a really good response. I'd really like for us to find a
solution in Perl, but if we end up having to write the check, so be it.
So, is Perl up to the task? Please say YES!
- Andy (andy-markham@mindspring.com)
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 2 Dec 1998 17:31:02 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
Subject: Re: Sorting VERY large files effeciently
Message-Id: <si7lwaa1t4.fsf@cre.canon.co.uk>
andy-markham@mindspring.com wrote:
> I have recently started working with a group that does some work on an
> HP3000. Since there is a 4GB limit on that machine, they have to find
> a new way to do some efficient sorting of data files that exceed that
> limit.
Whatever tool you use, you'll need to know the right algorithm to use.
Fast sorting algorithms like quicksort, heapsort and hashsort depend on
fast random access to data in memory and don't work well when it takes
time to access data.
A good start is to read section 5.4 of Knuth's "Sorting and Searching"
("Art of Computer Programming", volume 3). Knuth talks about tape
storage, but you can think about disk storage as tape storage with a
fast rewind time...
--
Gareth Rees
------------------------------
Date: Wed, 02 Dec 1998 12:00:23 -0500
From: jamesht <jamesht@idt.net>
Subject: spider framework?
Message-Id: <36657227.CD3D079C@idt.net>
Hello all!
I'm looking for a spider framework written in perl. Is there such a
thing freely available, possibly a pm?
Thanks for the help,
James
------------------------------
Date: Wed, 02 Dec 1998 12:03:51 -0500
From: John Chambers <jc@eddie.mit.edu>
To: Martien Verbruggen <mgjv@comdyn.com.au>
Subject: Re: Substitute
Message-Id: <366572F7.7BACB2E0@eddie.mit.edu>
Martien Verbruggen wrote:
>
> #!/usr/local/bin/perl -w
> use strict;
>
> open(DATA, $0) || die "Couldn't open $0: $!";
>
> while (<DATA>)
> {
> print;
> }
>
> __DATA__
> foo
> bar
>
> The above neatly outputs the program itself.
Hmmm ... Self-generating programs are sort of a minor
industry in some circles, ever since Ken Thompson told
us how to use such programs to subvert just about any
system's security. The above leads to a good entry
in a contest for a minimal self-producing program:
#!/usr/bin/perl
open(F,$0);while(<F>){print}
I don't think I've seen one smaller. Of course, it
is a special case: It only works when it's in a file
and run from that file, so that $0 contains the path.
But it's a nice example, and not even obscure.
------------------------------
Date: Wed, 2 Dec 1998 17:02:12 GMT
From: "Rick Koehler" <rkoehler@osmre.gov>
Subject: Re: unsubscribe
Message-Id: <F3CKnK.KLK@igsrsparc2.er.usgs.gov>
Basil S Mullings wrote in message <10698659@xmail.ha.osd.mil>...
>unsubscribe perl-users
>
Well, if that works, then I might as well do this:
INSTANTLY TRANSPORT immense-wealth-to-me
or even this:
SUBSCRIBE Perl Journal
=8^)
------------------------------
Date: Wed, 02 Dec 1998 17:49:56 GMT
From: sprintfer@yahoo.com (Mike D.)
Subject: Untainting Question
Message-Id: <36657780.788878096@nntp.cts.com>
While learning more and more about perl, I have developed a practice
"Customer" class. One of the things the class does is generate an ID
similar to Internic's format (based on first and last name). Now I am
writing a simple CGI (with the CGI module) where a Customer can create
an account by entering in his first and last name. Piece of cake.
I have the Taint mode on and untaint the fname and lname using the
example in Programming Perl page 358 (referencing subpattern
variables). I then generate the ID based on the untainted fname and
lname.
Here is where I am running into problems:
## If the ID was pm00045 then directory will equal "pm"
my ($directory) = unpack("a2", $self->{id});
if (! (-d "$BASE_DIR/records/$directory")) {
mkdir("$BASE_DIR/records/$directory", 0777);
}
sysopen(FILE, "$BASE_DIR/records/$directory/$self->{id}",
O_WRONLY|O_CREAT|O_EXLOCK) || die("$self->{id} :$! in customer
class\n");
I get the error:
Insecure dependency in mkdir while running with -T switch.
Is there a way I can get around this without creating 676+ (a-za-z)
directories? Or basically, is it possible to create directories and
files while in taint mode?
I've read "Cleaning up your Path" (pg. 359) in Programming Perl and
have added $BASE_DIR/records to $ENV{PATH} and this doesn't help. Do
I need to add something else?
Thank you for any help!
Mike D.
sprintfer@yahoo.com
------------------------------
Date: Wed, 02 Dec 1998 11:31:26 -0500
From: John Chambers <jc@eddie.mit.edu>
Subject: Re: Why is "... @foo ..." occasionally a syntax error?
Message-Id: <36656B5E.BA3F79E4@eddie.mit.edu>
Tk Soh wrote:
>
> [posted to c.l.p.m and copy emailed]
>
> Perl is trying to be nice to tell you that your code 'may' break if
> he/she/it(?) allows you to proceed, hence the syntax error.
Hmmm ... How could it break? The expression "@foo" seems to be very
well defined in perl; it is an idiomatic way of converting an array to
a string (with $" as the separator). If @foo doesn't exist, the result
is (and should be) a null string. There doesn't seem to be much of any
way for this to "break". Is there a version of perl around that treats
this expression any other way?
> It seems to me that the solution to you problem is quite simple - just
> 'declare' @resource like you always do. You may want to look at 'use
> strict' and my(), though it isn't always necessary, I believe you will,
> some days, appreciate their helpfulness.
So why is adeclaration needed here? When I consult "man perlsyn", one
of the first statements is:
A Perl script consists of a sequence of declarations and statements. The
only things that need to be declared in Perl are report formats and
subroutines. ...
This seems very clear and unambiguous, and in my experience, except for
this little problem of "@foo" occasionally bombing, it seems true.
> Why not just try to see if it helps. And if it doesn't, you are welcome
> to discuss on the topic of "declaration" later.
I think I'm getting an inkling of what the problem is here. It seems to
be that the above quote from "man perlsyn" is in fact not quite correct.
The compiler seems to choke on "@foo" unless it has seen @foo outside of
quotes. This is a compile-time error, and seems to be the only case (that
I know of so far) in which perl doesn't treat an undefined @foo as a null
array. I've found that by merely adding the line
@foo;
to the start of the module, the syntax error goes away. This seems to me
to be obviously a bug, especially in light of the above quote, but it also
appears from comments here that others think it is some sort of feature.
As far as I can tell, this bug/feature isn't documented in the man pages.
The best answer I can think of to the "Why not ...?" type question is that
it's sorta like when you walk up to a building with 6 or 8 doors, try one,
find it locked, try the others, and eventually find one unlocked. The folks
inside are, of course, smirking all the while. "Why didn't you try the
one that was unlocked, dummy?"
The "man perldata" page states that
... The following are equivalent:
$temp = join($",@ARGV);
system "echo $temp";
system "echo @ARGV";
As with the "man perlsyn" quote, there is no clue here that the second will
bomb if the compiler hasn't seen @ARGV. Well, of course, for @ARGV, the
compiler knows about it a priori. But the implication is that these are
two equivalent ways of converting an array to a string. There seems to be
no clue that one has a subtle extra qualification. ("Hey, that Chambers
idiot thought that those were equivalent for any array. Boy, did we reel
that sucker in!" ;-)
So can say "Well, why didn't you use the other one, dummy?" That's exactly
like those folks sitting behind the row of doors watching me test each one
to find out which one works. Stumbling around testing different "equivalent"
expressions to find the one that works is both a violation of the perl
mantra "There's more than one way to do it", and it's also a big waste of
programmer time. (And now I just wasted a bunch of y'all's time by asking
"What the hell's going on here?" ;-)
Well, I guess it's one more entry in my archive of perversities in various
languages. It's starting to take up a lot of disk space. But the perl
gang is way behind. I have a much larger tcl collection, despite having
only used tcl half as long as perl ...
------------------------------
Date: Wed, 02 Dec 1998 11:50:06 -0500
From: John Chambers <jc@eddie.mit.edu>
Subject: Re: Why is "... @foo ..." occasionally a syntax error?
Message-Id: <36656FBE.3CEEEC98@eddie.mit.edu>
Bart Lateur wrote:
>
> Russ Allbery wrote:
>
> >Er, that's perfectly legal Perl. It means the same thing as:
> >
> > $extra = join ($", @resource) if ($typ eq 'lab');
> >
> >His meaning isn't ambiguous in this case, provided that there's actually
> >an array @resource in his program.
>
> That's just it, I think. My guess is that @resource is ONLY used (and
> set) in one of the reuired files, besides this one statement in the main
> script.
>
> "Mention" this array in the main script in plain form as well, and you
> should have no more problems.
This seems to be the crux of the matter. The module in question is
require'd by any number of CGI scripts and a few others. The @resource
array is built at run-time, and will be defined by the time the line
in question is executed. But in this case, the offending line was the
first time that the *compiler* had seen @resource. It was the lexically
first occurrence of the array, but at run time would not be anywhere
near the first use of the array. In some cases, of course, @resource
will be empty, and the intent is to get a null string in those cases.
References to @resource are scattered throughout the code, including
in several other sub in the same module. So one of the curious effects
of this bug/feature is that if I move the subs around in the module,
the error may go away. (I much prefer my subs in alphabetical order,
for obvious reasons.)
The basis of the problem seems to be that in this one situation, perl
doesn't treat @foo as a valid array reference unless it has been seen
in some other context already. I can't seem to find anything in TFM
that explains it. @foo should come into existence when it is used,
right? And its value should be an empty array, right? Apparently
not. But I did find that by merely adding the dummy line
@resource;
at the start of the module, the problem went away. I also tried
if (0) {@resource}
and that worked, too, despite the obvious fact that the reference
to @resource can never be evaluated at run time. It seems to be just
the appearance of @resource that satisfies the compiler, and any sort
of context other than a quoted string is acceptable.
I'll add this to my slowly-growing directory of perl perversities. (The
directory of tcl perversities is larger and growing much faster, and of
course I have a rather large directory for C perversities. ;-)
--
Unix puzzle of the day: What does the following command do?
find . '*.bak' -exec rm -f {} \;
Hint: Don't try this at $HOME.
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 4342
**************************************