[16247] in Perl-Users-Digest
Perl-Users Digest, Issue: 3659 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 13 21:10:28 2000
Date: Thu, 13 Jul 2000 18:10:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <963537015-v9-i3659@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 13 Jul 2000 Volume: 9 Number: 3659
Today's topics:
Re: PRINTing " "" " (jason)
Re: PRINTing " "" " (Keith Calvert Ivey)
Qs for professional Perl/CGI developers (Pjtg0707)
Re: reg expression not working. WHY??? <pdmos23@geocities.com>
Re: String length? (Tad McClellan)
Re: sub selects <makarand_kulkarni@my-deja.com>
UDP / ICMP checksum generation - 1's complement sum <wizard_oz@gmx.net>
Re: using %ENV with CGI <trent.mankelow@unisys.com>
Re: Using ASP objects with Perl modules (jason)
Re: Using variables in regexps (Tad McClellan)
Re: w32 module (jason)
Re: Why $|++ instead of $|=1 ? (Keith Calvert Ivey)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 14 Jul 2000 00:04:36 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: PRINTing " "" "
Message-Id: <MPG.13d8f661936a7f39989698@news>
Jeff Boes wrote ..
>Note that
>
> print q(I've got a \("secret"\));
>
>isn't much better, but you can always change delimiters:
the (), {} and [] delimiters support nesting .. so
print q(blah (blah) blah);
works perfectly well .. the only time you need to change the delimiters
is where it's unclear .. the following will (obviously) fail
print q(the close paren character ')' will screw this one up);
the nesting behaviour of the paren, bracket and brace pairs makes them
preferrable to all the q/blah/ style delimiters in all but the rarest
circumstances (although I tend to use the brackets to avoid confusion
with function parens and variable delimiting braces)
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Fri, 14 Jul 2000 00:54:09 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: PRINTing " "" "
Message-Id: <3971644a.3196231@nntp.idsonline.com>
Jeff Boes <jboes@eoexchange.com> wrote:
>Note that
>
> print q(I've got a \("secret"\));
>
>isn't much better, but you can always change delimiters:
>
> print q{I've got a ("secret")};
Or you can just drop the unnecessary backslashes:
print q(I've got a ("secret"));
works fine. That's an advantage of paired delimiters: you don't
need to escape them unless they're unbalanced within the string.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: Fri, 14 Jul 2000 00:01:47 GMT
From: Pjtg0707@Netscape.net (Pjtg0707)
Subject: Qs for professional Perl/CGI developers
Message-Id: <smsm3begnd6170@corp.supernews.com>
I am wondering how many of you guys are professional Perl/CGI developers?
If you work as a contractor, how do you make sure you don't get stiffed
by your clients? Have you ever been stiffed before?
Is Perl the only thing you do?
What is the general going rate for a Perl developer?
------------------------------
Date: Fri, 14 Jul 2000 00:21:51 GMT
From: Pasquale <pdmos23@geocities.com>
Subject: Re: reg expression not working. WHY???
Message-Id: <396E5EC6.6660AA7A@geocities.com>
Yes. The example you mention below does not work, which is hard to
understand.
<DS>=Drew Simonis
<DS>So what you are saying is that, for example, print $address, "\n";
<DS>outputs 3434 Joyce Rd.
<DS>and print $cells[3], "\n"; outputs 3434 Joyce Rd. but doing
<DS>a comparision of these identical terms fails?
Is it having trouble with $cells[3]? The reason I ask is because in
another script I have the conditional statement works.
foreach $rowadr(@addr) {
chomp($rowadr);
if ($address eq $rowadr) {
stuff
}
}
Drew Simonis wrote:
> Pasquale wrote:
> >
> > Thanks, but it still is not working.
>
> What is hapening instead?
>
> > Do I really need to use CGI.pm to
> > get this to work? I'm not too familiar with linking to that module.
>
> It is very easy:
>
> use CGI;
>
> > The variables you suggested to be printed are
> > printing OK.
>
> So what you are saying is that, for example, print $address, "\n";
> outputs 3434 Joyce Rd.
>
> and print $cells[3], "\n"; outputs 3434 Joyce Rd. but doing
> a comparision of these identical terms fails?
>
> Have you tried changing the conditional to read:
>
> if ("$address" eq "$cells[3]")
>
> I seem to recall reading that double quotes will force stringification
> of the terms, which may be helpfull since you are doing a string
> comparision. But then again, I may be wrong. I don't see any mention
> in perlop of that behaviour.
------------------------------
Date: Thu, 13 Jul 2000 17:51:22 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: String length?
Message-Id: <slrn8mseeq.c0u.tadmc@magna.metronet.com>
On Thu, 13 Jul 2000 16:43:12 -0500, Jim Kauzlarich <o1technospam@skyenet.nospam.net> wrote:
>
>"Craig Berry" <cberry@cinenet.net> wrote in message
>news:sms11e6qnd629@corp.supernews.com...
>> Jim Kauzlarich (o1technospam@skyenet.nospam.net) wrote:
>> : So, with a little last minute re-vamping, here is my creation: (though
>> : without the do loop, and the extra if/then evaluation it feels un-Perl.
>The
>> : little bit I know.)
>>
>> Nicely horrid. One tweak (unless the extra warning was intentional, of
>> course):
>
>Thank you!
>
>> : if ( @_[$count] ne "" ) {
>>
>> s/\@/\$/
>
>Regular expression I assume? I haven't really delved into them yet. Is
>that a substitution?
Yes.
But it is a substitution that _you_ (not perl) should make.
Instead of saying "change the @ to a $" in English, we tend
to say the same thing in Perl instead.
i.e. if ( $_[$count] ne "" ) {
^
^ scalar, not array slice as you have above
>I'm a bit surprised that no one snapped at my mis-attempt at using strict.
>"use strict();" I'd been up for about 20 hours, and when I attempted to add
>strict. It came back with the following err that I'm still not sure what
>means (mee tawk gud englush, eh?)
Are you sure?
use strict();
should turn on NO strictness (i.e. it is worthless when written that way).
>Global symbol "x" requires explicit package name at count3.cgi line 22.
All of the messages that perl might issue (and even some that are
NOT issued by perl) are documented in the perldiag.pod standard doc.
perldoc perldiag
---------------------
=item Global symbol "%s" requires explicit package name
(F) You've said "use strict vars", which indicates that all variables
must either be lexically scoped (using "my"), declared beforehand using
"our", or explicitly qualified to say which package the global variable
is in (using "::").
---------------------
>What is an "explicit package name"?
It is the name of the package that contains the 'x'.
I dunno what you did to get that message, so I'll make up
something else.
If it was complaining about $x, then strict wants you to
give the package name as well as the variable name:
$main::x; # the $x variable in the 'main' package
$MyPackage::x; # the $x variable in the 'MyPackage' package
type:
perldoc perlmod
and see the "Packages" section.
>I figured that I'd added in strict incorrectly, and changed it.
You figured correctly.
>I also
>don't understand why I didn't get an error when I put "use strict()" at the
>top of my program.
Probably because it is not a (syntax) error!
It is, however, a logic error :-)
perldoc -f use
perldoc strict
You can supply a LIST to "use".
It lists the things that you want to use.
If the list is empty, you are saying that you don't want to use
any of it.
>> --
>> | Craig Berry - http://www.cinenet.net/users/cberry/home.html
>> --*-- "Beauty and strength, leaping laughter and delicious
>> | languor, force and fire, are of us." - Liber AL II:20
Please do not quote .sigs. It is bad netiquette.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 13 Jul 2000 16:58:41 -0700
From: Makarand Kulkarni <makarand_kulkarni@my-deja.com>
To: Tad McClellan <tadmc@metronet.com>
Subject: Re: sub selects
Message-Id: <396E57B1.DAFF9212@my-deja.com>
> >Does anyone know if mySQL supports sub-selects, and if so, what the
> >syntax is?
as of ver 3.23.21-beta subselects were still on the TODO list.
------------------------------
Date: Thu, 13 Jul 2000 17:34:17 -0700
From: "Ingmar Koecher" <wizard_oz@gmx.net>
Subject: UDP / ICMP checksum generation - 1's complement sum
Message-Id: <smsnr08qnd6150@corp.supernews.com>
I am trying to send out UDP and ICMP packets manually and therefor need to
calculate the checksum for those packets manually. I am using RawIP perl
module on LINUX.
I already looked into the RFC 1071 that explains the generation and the
algorithm, but I still can't make it work. One problem is that I don't know
exactly how I calculate a 1's complement sum of hex values. One source I
have explains it like this:
1. Treat the data as a stream of 16-bit words
2. Compute the 1's complement sum of the 16-bit words
3. Take the 1's complement of the computed sum
I have a source code in C (at the bottom), but that doesn't help me either
since I can't program C.
What I tried:
I calculated the 1's complement like: $a_compl = ~$a;
I added all 16-bit words complements
I added the carry-over bit to the sum
I created the 1's complement of the previously generated sum
However, it doesn't work. I also tried not complementing the first value,
but no success, my calculation never matches the correct one (I know because
I'm using a sniffer).
Well, I'm at the end. I've tried for appr. 2 days now, installed linux in a
4day session just for this reason and here I fail, sitting on a table with
papers full of hex code.
If anybody out there can help me I would be very happy.
Below the C code,
many thanks,
Ingmar.
====================== C - code ====================================
unsigned short in_cksum( void *addr, int len ) {
long sum = 0;
unsigned short *ip = (unsigned short *) addr;
while ( len > 1 ) {
sum += *((unsigned short *) ip)++;
if (sum & 0x80000000) /* if high-order bit
set, fold */
sum = (sum &0xFFFF) + (sum >> 16);
len -= 2;
}
if ( len ) sum += (unsigned short) *(unsigned char *) ip;
while ( sum >> 16 ) sum = ( sum & 0xFFFF ) + ( sum >> 16 );
return ~sum;
}
====================== C - code ====================================
------------------------------
Date: Fri, 14 Jul 2000 11:40:07 +1200
From: "Trent Mankelow" <trent.mankelow@unisys.com>
Subject: Re: using %ENV with CGI
Message-Id: <8kljvg$i06$1@mail.pl.unisys.com>
Yeah, that's how I've been doing it, but I really want to make the whole
system more portable. The lib directory shouldn't have to be hardcoded. Any
ideas?
At the moment, like I said, I've got the location of the root of the
directory encoded as an environment variable. I also have a cfg file that I
read in that could potentially tell me the location of the lib directory,
but it's a bit of a dilemma, b/c to get the cfg file, I'm going to have to
know where that lives, so once again I'll need to know $NIKAUHOME! Aaargh!
Any ideas?
"Dan Wilga" <dwilgaREMOVE@mtholyoke.edu> wrote in message
news:dwilgaREMOVE-AFA52B.13192913072000@news.mtholyoke.edu...
> In article <8kj8al$ovj$1@mail.pl.unisys.com>, "Trent Mankelow"
> <trent.mankelow@unisys.com> wrote:
>
> > I'm sourcing it by simply typing "source setup.csh" at the moment, and
then
> > restarting the server afterwards, by typing "/etc/init.d/httpd stop"
> > followed by "/etc/init.d/httpd start".
>
> That's your problem. You can't expect the environment of the process
starting
> the web server to be inherited by the server or its children (at least not
> with Apache.)
>
> What works for me is to do this within my Perl code:
>
> BEGIN {
> push( @INC, "/home/peri/nikau/lib" );
> }
>
> I can then use any modules stored in that directory. Of course, this may
not
> work for all OSes.
>
> Dan Wilga dwilgaREMOVE@mtholyoke.edu
> ** Remove the REMOVE in my address address to reply reply **
------------------------------
Date: Fri, 14 Jul 2000 00:28:22 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Using ASP objects with Perl modules
Message-Id: <MPG.13d8fbf84ebae18c98969a@news>
Alex T. wrote ..
> $Response->Write("<h3>".$to_print."</h3>");
I'm no expert on PerlScript at all (never used it) - but isn't that
meant to be $Response->write() ?? .. ie. lowercase 'w'
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Thu, 13 Jul 2000 17:34:41 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Using variables in regexps
Message-Id: <slrn8msdfh.c0u.tadmc@magna.metronet.com>
On 13 Jul 2000 21:14:02 +0200, Marc Schaefer <marc.schaefer@warwick.ac.uk> wrote:
>However, if you only want to delete single characters, you should have
>a look at tr/// (also in perlop):
> $charToStrip = '$';
> $price = '$59.95';
>
> $price =~ tr/$charToStrip//d;
You should read the description of tr/// before advising
others to read the description of tr///!
"neither the SEARCHLIST nor the REPLACEMENTLIST are
subjected to double quote interpolation"
What you have above is equivalant to:
$price =~ tr/$STachioprt//d;
So that _does_ remove the dollar sign, but it has a good deal
of collateral damage associated with it :-)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 14 Jul 2000 00:36:33 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: w32 module
Message-Id: <MPG.13d8fddd369c499098969b@news>
Sergio Sanchez wrote ..
>I am trying to install the AdminMisc extension for Win32 Perl and
>according to the instruction s in the readme file it references a file i
>dont have in the zip.
don't install it manually if you don't have to (not sure how up to date
those instructions are) .. at the command prompt - type the following
(paste it back together - I'm sure my newreader will have cut it)
ppm install --location=http://www.roth.net/perl/packages/ Win32-
AdminMisc
btw .. when I last checked - none of Roth's XS modules had been updated
for Perl v5.6 .. so unless you're still using 5.005_03 then you might
not have any luck
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Fri, 14 Jul 2000 00:15:14 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Why $|++ instead of $|=1 ?
Message-Id: <396e5aa1.722429@nntp.idsonline.com>
mjtg@cus.cam.ac.uk (M.J.T. Guy) wrote:
>$| is magical and can only take values 0 or 1. An attempt to set
>any nonzero value sets it to 1.
And "nonzero" here does mean nonzero, not true. so setting $| to
things like 'true' or '0 but true' results in a 0 value.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 3659
**************************************