[19199] in Perl-Users-Digest
Perl-Users Digest, Issue: 1394 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 27 18:06:24 2001
Date: Fri, 27 Jul 2001 15:05:15 -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: <996271514-v10-i1394@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 27 Jul 2001 Volume: 10 Number: 1394
Today's topics:
5.6.1 on IRIX 6.5 <ashley@pcraft.com>
Re: [Fixed] DBD:ODBC, Openlink->MSSQL, and LongReadLen (Sebastian)
Re: a* vs .* regex behavior question <iltzu@sci.invalid>
Re: CGI:standard <greenbd@u.washington.edu>
Data Interchange Format (Robert Goff)
DeleteKey() <boogiemonster@usa.net>
Re: errata for book "PERL DEBUGGED"? (no url in book!) <cowdrick@toto.net>
FAQ: How do I reverse a string? <faq@denver.pm.org>
Re: Is there anyway? <mjcarman@home.com>
Re: Is there anyway? <bop@mypad.com>
Re: Linux Web Administration Interface <gnarinn@hotmail.com>
Re: Linux Web Administration Interface <mischief@velma.motion.net>
Re: local and tie <iltzu@sci.invalid>
Re: Need help on processing some data <gnarinn@hotmail.com>
Re: Pattern Search and Replace nth Occurance (Randal L. Schwartz)
Perl books for sale (jb)
question with arrays (Balaji)
Re: question with arrays <pne-news-20010727@newton.digitalspace.net>
Re: Regular Expression <iltzu@sci.invalid>
Returning Query Results of multiple pages <AHALL5@nc.rr.com>
Re: Returning Query Results of multiple pages <jeff@vpservices.com>
Re: Socket and TCP_NODELAY <d_munzinger@yahoo.de>
Sorting problem <jonathan.sala@wichita.boeing.com>
Re: Sorting problem <jeff@vpservices.com>
Re: sortlen -- filter to sort text by line length (Yves Orton)
Re: sprintf <strawNOSPAMman@plexi.com>
Re: sprintf <strawNOSPAMman@plexi.com>
Re: sprintf <godzilla@stomp.stomp.tokyo>
Re: Unlinking lockfiles safely [was: Another flock que (Richard J. Rauenzahn)
win32.c:1631: structure has no member named `u' <jacobjf@cistron.nl>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 27 Jul 2001 15:10:53 -0700
From: "Ashley M. Kirchner" <ashley@pcraft.com>
Subject: 5.6.1 on IRIX 6.5
Message-Id: <3B61E6ED.C405ECEE@pcraft.com>
I'm trying to compile perl 5.6.1 on an IRIX 6.5 machine, which has
gcc-3.0 (from freeware.sgi.com) installed. Somewhere during the
configure, it reaches the following stage and just stops:
----------
<dirent.h> found.
Your directory entries are struct dirent.
Your directory entry does not know about the d_namlen field.
dlerror() found.
<dlfcn.h> found.
On a few systems, the dynamically loaded modules that perl generates and
uses
will need a different extension than shared libs. The default will
probably
be appropriate.
What is the extension of dynamically loaded modules [so]
Checking whether your dlsym() needs a leading underscore ...
----------
That's it, nothing else after that.
When I look at my process list, I see these three:
root 55223 53863 0 14:50:41 pts/1 0:00 gcc -E - -o
dyna.so -mabi=n32 -shared -L/usr/local/lib32 -L/usr/local/lib -L/us
root 55592 55223 0 14:50:42 pts/1 0:00
/usr/freeware/lib/gcc-lib/mips-sgi-irix6.5/3.0/cpp0 -lang-c -D__GNUC__=3
-D__GN
root 53863 49552 0 14:45:44 pts/1 0:09 /bin/sh
./Configure
...okay...so what's going on? Why'd it freeze?
--
W | I haven't lost my mind; it's backed up on tape somewhere.
+--------------------------------------------------------------------
Ashley M. Kirchner <mailto:ashley@pcraft.com> . 303.442.6410 x130
IT Director / SysAdmin / WebSmith . 800.441.3873 x130
Photo Craft Laboratories, Inc. . 3550 Arapahoe Ave. #6
http://www.pcraft.com ..... . . . Boulder, CO 80303, U.S.A.
------------------------------
Date: 27 Jul 2001 14:00:25 -0700
From: dethtoll@yahoo.com (Sebastian)
Subject: Re: [Fixed] DBD:ODBC, Openlink->MSSQL, and LongReadLen
Message-Id: <ea245403.0107271300.10baf3ee@posting.google.com>
dethtoll@yahoo.com (Sebastian) wrote in message news:<ea245403.0107270752.5137e3cd@posting.google.com>...
> Erland Sommarskog <sommar@algonet.se> wrote in message news:<Xns90EB6559D031Yazorman@127.0.0.1>...
> > Sebastian (dethtoll@yahoo.com) writes:
> > > I'm using perl DBI, DBD::ODBC, and OpenLink drivers to connect to a
> > > Win2k MS SQL Server. DBI's LongReadLen method seems to have no effect,
> > > I still get <255 characters when retrieving data from long memo
> > > fields. Has anyone run into this?
> >
> > How old is the OpenLink driver?
> >
> > If the client is speaking an earlier version of the TDS protocol than
> > TDS7, then SQL Server will revert to 6.5 behaviour, and only return
> > the datatypes available in 6.5. Which for varchar and char means
> > 255 character at most.
> >
> > Now, you say "memo", which is usually means "text", and even with
> > an old driver you should be able to get back data > 255.
> >
> > But I have not used DBI nor Openlink, so I don't know if there any
> > issue with these.
>
> The Openlink request broker (the server component) is version 2.14
> release 4.0, dated March 8 2001. I can't find the version info for the
> client driver on Linux, but it was the version packaged with the
> server side, so it's pretty recent.
>
> A field in question has a MSSQL type of varchar(7000). This is a field
> where I can only get <255 chars, regardless of DBI's
> $dbh->{LongReadLen} value. I am setting this value just after my
> connect statement, but before any preparing.
>
> Thanks, Sebastian
FYI:
Openlink's excellent support system provided an updated driver file
for the server side (link below). Add that to oplrqb.ini as:
[generic_sql6]
Program=sql2k_mv.exe
And a quick restart of the broker service, worked like a charm.
ftp://38.233.242.132/pub/win32/sql2k_mv.exe
------------------------------
Date: 27 Jul 2001 18:45:48 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: a* vs .* regex behavior question
Message-Id: <996257811.16942@itz.pp.sci.fi>
In article <Pine.GSO.4.32.0107261753170.29264-100000@mintaka.iern.disa.mil>, W. James Showalter, Jr. wrote:
>
>$_ = "aaaaa";
>/a*(?{$foo = pos($_);print " " x $foo, "position using a = $foo\n"})[\n]/;
>print "\n\n";
>/.*(?{$foo = pos($_);print " " x $foo, "position using . = $foo\n"})[\n]/;
In general, "use re 'debug';" is a more versatile approach to debugging
regexp behavior like this.
perl -Mre=debug -e '$_="aaa"; /a*[\n]/; /.*[\n]/;'
>Unfortunately, I can't figure out why the following two patterns
>backtrack differently. The only difference is the use of 'a' vs '.'
>at the beginning of each pattern. In both cases it seems '.*' and
>'a*' should match "aaaaa" and neither should match [\n].
The reason is that .* at the start of a regexp is subject to a special
optimization. The relevant code, and a pithy comment, con be found in
regcomp.c:
else if ((OP(first) == STAR &&
PL_regkind[(U8)OP(NEXTOPER(first))] == REG_ANY) &&
!(r->reganch & ROPT_ANCH) )
{
/* turn .* into ^.* with an implied $*=1 */
int type = OP(NEXTOPER(first));
if (type == REG_ANY)
type = ROPT_ANCH_MBOL;
else
type = ROPT_ANCH_SBOL;
r->reganch |= type | ROPT_IMPLICIT;
first = NEXTOPER(first);
goto again;
}
If you anchor the regexps explictly, both will behave the same:
perl -Mre=debug -e '$_="aaa"; /^a*[\n]/; /^.*[\n]/;'
Interestingly enough, a+ is also subject to a different optimization,
but .+ is not!
perl -Mre=debug -e '$_="aaa"; /a+[\n]/; /.+[\n]/;'
(I've omitted the output in all cases, since it gets quite verbose. Run
the commands yourself to see it.)
BTW, in case anyone's wondering, I didn't know any of this until I tried
your example and spent a few minutes grepping the regexp engine code. I
still can't claim to understand any of it except for these few bits.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post something,
we discuss its implications. If the discussion happens to answer a question
you've asked, that's incidental." -- nobull in comp.lang.perl.misc
------------------------------
Date: Fri, 27 Jul 2001 12:09:26 -0700
From: "Brian D. Green" <greenbd@u.washington.edu>
Subject: Re: CGI:standard
Message-Id: <Pine.A41.4.33.0107271200300.37604-100000@dante24.u.washington.edu>
On Fri, 27 Jul 2001, Alan J. Flavell wrote:
> On Jul 26, Brian D. Green delicately tapped the keys:
>
> > > > $netid = $ENV{'REMOTE_USER'};
> > >
> > > > open(SAVE, ">>$netid.out") || die("Can't open $netid.out for writing:
> > > > $!\n");
> > >
> > > It's *not* a good idea to open a file for writing or appending when its
> > > name comes from outside your program and you haven't checked the name to
> > > make sure it's reasonable.
> >
> > Thanks for the reminder. The user id's in this situation are all limited
> > to alphanumerics with a maximum of eight characters, so I think they're
> > pretty safe.
>
> Don't do that. You're in a security-exposed situation here. Apply a
> defensive strategy, rather than trying to think of excuses for not
> doing so.
How would someone manage to fake their $ENV{'REMOTE_USER'}? The University
of Washington's authentication security is some of the best in the world,
and I've further limited access to the site via .htaccess and .htgroup
files. Only students enrolled in this simulation have their id's in the
file, so I'm able to check and make sure that they won't interfere. Would
it be a situation of people entering commands into the text fields to
redefine $netid?
Brian Green http://students.washington.edu/greenbd/
O-----------------------------------------------------------------------O
|"I am not ashamed of the gospel, because it is the power of God for the|
| salvation of everyone who believes: first for the Jew, then for the |
| Gentile." --Romans 1:16, NIV |
O-----------------------------------------------------------------------O
------------------------------
Date: 27 Jul 2001 13:33:08 -0700
From: beast@avalon.albuquerque.nm.us (Robert Goff)
Subject: Data Interchange Format
Message-Id: <55f4cea3.0107271233.3192c675@posting.google.com>
I've looked and looked, but I haven't found code that will parse a DIF
file, the DIF that is produced by spreadsheet programs and FileMaker
Pro, specificially. Any suggestions? Thanks.
--
If we are what we eat, I'm cheap, fast and easy.
======================================================================
Robert Goff http://aisling.cc/resume/
Technical Writer/Editor, Webmaster 505-564-8959
------------------------------
Date: Fri, 27 Jul 2001 16:01:20 -0400
From: "Joseph" <boogiemonster@usa.net>
Subject: DeleteKey()
Message-Id: <9jsh8s$m4$1@usenet01.srv.cis.pitt.edu>
I'm trying to connect to a remote machine using Win32::Registry. I want to
delete key and all its sub key. Is there way to do this without expanding
each individual trees and delete one at a time then finally to the root? is
there a easier method? following is my code....any help would be
appreciated...
use Win32::Registry;
%KeyName =
SoftwareRoot => 'Software\Microsoft',
LaunchPath => 'Windows\CurrentVersion\Run',
);
$Root = $HKEY_LOCAL_MACHINE;
if ($Machine = $ARGV[0])
{
$HKEY_LOCAL_MACHINE->Connect ($Machine, $Root ) || die "Could not
connect to the Registry on '$Machine'\n;"
}
if ( $Root->Open ($KeyName{SoftwareRoot}, $Links))
{
$Links->DeleteKey("test1"); #there are sub keys in both of these
keys....
$Links->DeleteKey("test");
if ($Links->Open ($KeyName{LaunchPath}, $Links2))
{
$Links2->DeleteValue("SMS Application Launcher");
}
$Links2->Close;
}
$Links->Close;
------------------------------
Date: Fri, 27 Jul 2001 20:55:31 GMT
From: Charles Cowdrick <cowdrick@toto.net>
Subject: Re: errata for book "PERL DEBUGGED"? (no url in book!)
Message-Id: <3B61D56D.BAA3093A@toto.net>
David Combs wrote:
> I bought a copy of this new book, "Perl Debugged", and
> have found what I (mistakenly?) think are errors in
> his example programs.
>
> But unlike O'Reilly books, which have easy-to-find
> errata, and they tell you so in the intro, with
> this book (addison wesley), there is NO mention at
> all of any errata, or where to send any you might find,
> or where to get a copy of what's been turned in --
> OR even where to get already-typed-in code from the
> book.
>
> [snip]
> Anyway, does anyone here know the url for the errata,
http://www.perldebugged.com/errata.html
errata@perldebugged.com
------------------------------
Date: Fri, 27 Jul 2001 18:17:48 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How do I reverse a string?
Message-Id: <gfi87.106$os9.189217280@news.frii.net>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.
+
How do I reverse a string?
Use reverse() in scalar context, as documented in the reverse entry in
the perlfunc manpage.
$reversed = reverse $string;
-
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to
news:news.answers
or to the many thousands of other useful Usenet news groups.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-1999 Tom Christiansen and Nathan
Torkington. All rights reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
04.22
--
This space intentionally left blank
------------------------------
Date: Fri, 27 Jul 2001 12:48:54 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Is there anyway?
Message-Id: <3B61A986.9F3FA25A@home.com>
Robert Sherman wrote:
>
> flash wrote:
> >
> > Is there a way that a perl script can use a graphical program.
> > Like fill in certain feilds and hit done or something?
> > (If there is a module just tell me the name)
> > Will setupsup work?
>
> Tk (cross-platform)
>
> Win32::GUI (win32)
No, those are modules for *creating* programs with graphical user
interfaces. The OP wants to interact with one.
I'm not aware of a general solution. On Win* platforms you can use
Win32::OLE to interact with programs that support OLE embedding (Word,
Excel, etc.)
-mjc
------------------------------
Date: Fri, 27 Jul 2001 15:37:04 -0400
From: "flash" <bop@mypad.com>
Subject: Re: Is there anyway?
Message-Id: <knj87.2467$uw3.132898@news20.bellglobal.com>
I found Win32::GUI::ctrl
or something, I will keep looking.
"Michael Carman" <mjcarman@home.com> wrote in message
news:3B61A986.9F3FA25A@home.com...
> Robert Sherman wrote:
> >
> > flash wrote:
> > >
> > > Is there a way that a perl script can use a graphical program.
> > > Like fill in certain feilds and hit done or something?
> > > (If there is a module just tell me the name)
> > > Will setupsup work?
> >
> > Tk (cross-platform)
> >
> > Win32::GUI (win32)
>
> No, those are modules for *creating* programs with graphical user
> interfaces. The OP wants to interact with one.
>
> I'm not aware of a general solution. On Win* platforms you can use
> Win32::OLE to interact with programs that support OLE embedding (Word,
> Excel, etc.)
>
> -mjc
------------------------------
Date: Fri, 27 Jul 2001 19:06:55 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: Linux Web Administration Interface
Message-Id: <996260815.771707132924348.gnarinn@hotmail.com>
In article <9130a43b.0107260219.5966bfd2@posting.google.com>,
Hannes Schulz <h_schulz@gmx.de> wrote:
>
>I'm planning to write a Linux administration interface controlled by
>perl CGI scripts on a http server in my local net. I know that sounds
>like Webmin, but I want to restrict certain actions to special users,
>and create my own more userfriendly design (not speaking of wanting to
>learn more about perl).
>
>Now the scripts run by the webserver can not execute or modify any
>system stuff.
except for suid scripts
>I considered writing everything into a file and letting
>a cronjob check that file, but since I need the changes fast, this is
>not the best Idea, or is it? A deamon process controlled by signals?
>Or one that waits for socket connections from localhost? I could not
>figure out what Webmins foreign_call() procedure does, but I guess
>that is what I need. And, after all that, what would be most secure?
>
by far the most insecure part is the transfer of data and commands
over HTTP. maybe you want to use HTTPs
also you must protect yourself from simultaneous calls
in any case you should use taint checking, and check all
input carefully before acting on it. do not do:
system(param('command'));
gnari
------------------------------
Date: Fri, 27 Jul 2001 20:58:10 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Linux Web Administration Interface
Message-Id: <tm3lf2ssp5nade@corp.supernews.com>
gnari <gnarinn@hotmail.com> wrote:
> In article <9130a43b.0107260219.5966bfd2@posting.google.com>,
> Hannes Schulz <h_schulz@gmx.de> wrote:
>>
>>I'm planning to write a Linux administration interface controlled by
>>perl CGI scripts on a http server in my local net. I know that sounds
>>like Webmin, but I want to restrict certain actions to special users,
Webmin can limit different users to different levels of access.
>>and create my own more userfriendly design (not speaking of wanting to
>>learn more about perl).
>>
>>Now the scripts run by the webserver can not execute or modify any
>>system stuff.
> except for suid scripts
Or if the 'admin' *cough* is sily enough to run the web server as a
priveleged user.
>>I considered writing everything into a file and letting
>>a cronjob check that file, but since I need the changes fast, this is
>>not the best Idea, or is it? A deamon process controlled by signals?
>>Or one that waits for socket connections from localhost? I could not
>>figure out what Webmins foreign_call() procedure does, but I guess
>>that is what I need. And, after all that, what would be most secure?
>>
Perhaps you should write chanegs to a file, and have a program which
reads from the file. This could be done in a tail-like fashion, or
you could use fifos on systems which support them. UDP,
Unix domain sockets, or TCP are options, but they could be overkill.
> by far the most insecure part is the transfer of data and commands
> over HTTP. maybe you want to use HTTPs
Good suggestion. Webmin (newer versions) can use SSL.
> also you must protect yourself from simultaneous calls
Very good suggestion. Webmin already takes care of this.
> in any case you should use taint checking, and check all
> input carefully before acting on it. do not do:
> system(param('command'));
Ouch! That advice is so good that the example is painful to
read.
OP: if you really want to learn more Perl, consider updating Webmin
and sending your patches to the project maintainer(s). I'm not a
huge fan of Webmin, but it is used a lot, and it's already a wheel.
gnari: You gave some of the best advice I've seen lately in your followup.
The OP would be wise to follow it.
Chris
--
If they can get you asking the wrong questions, they don't
have to worry about the answers.
-- Thomas Pynchon, Gravity's Rainbow
------------------------------
Date: 27 Jul 2001 20:53:26 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: local and tie
Message-Id: <996266499.20126@itz.pp.sci.fi>
In article <9jrgn4$evj$1@mamenchi.zrz.TU-Berlin.DE>, Anno Siegel wrote:
>
>[1] I intend to tie $SIG{ __WARN__} and $SIG{ __DIE__} in such a
> way that, in addition to the coderef a user stores there,
> certain (logging-) activities also happen. Storing to the
> tied location would squirrel away the handler in the tied
> object. Reading would always return the same subref, a closure
> that does some logging and then calls the user's handler.
> In most cases, an unsuspecting program that uses one of these
> handlers would continue to work, but it would fail badly if
> a user tried (as they should) to make the change local.
Well, it would also fail if I "localized" the tied variable manually:
tie $SIG{__DIE__}, 'Tie::Whatever';
{
my $die = $SIG{__DIE__};
$SIG{__DIE__} = sub { ... };
# ...
$SIG{__DIE__} = $die;
}
I'd suggest working around the problem by creating a new anonymous sub
at every STORE, and by having the module recognize the subs it creates
and storing those unchanged. (You could bless the sub, perhaps.)
What *I* would really like is if tied scalars could somehow atomically
handle the assignment variants of operators. That would let me fix a
minor but irritating bug in Time::Stopwatch.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post something,
we discuss its implications. If the discussion happens to answer a question
you've asked, that's incidental." -- nobull in comp.lang.perl.misc
------------------------------
Date: Fri, 27 Jul 2001 19:53:27 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: Need help on processing some data
Message-Id: <996263607.244317119941115.gnarinn@hotmail.com>
In article <21724be2.0107262055.1aab4bc2@posting.google.com>,
>Could someone help me on this ?
>
>I have a sample input as follow:
>
>companyXYZ:ABC:1
>companyXYZ:DEF:3
>companyZZZ:ABC:5
>companyZZZ:DEF:7
>
>
>I would like to have the output as follow:
>
> companyXYZ companyZZZ
>ABC 1 5
>DEF 3 7
>
>
>
>Any help/hint would be greatly appreciate !
so what is your problem? the formatting? you forgot to chomp?
try this:
use strict;
use diagnostics;
my (%c,%l,%v);
while (<DATA>) {
chomp;
my ($c,$l,$v)=split /:/;
$c{$c}=1;
$l{$l}=1;
$v{"$c:$l"}=$v;
}
my @c=sort keys %c;
my @l=sort keys %l;
my $f="%-16s";
printf($f,"");
foreach my $c (@c) {
printf($f,$c)
}
print "\n";
foreach my $l (@l) {
printf($f,$l);
foreach my $c (@c) {
printf($f,$v{"$c:$l"});
}
print "\n";
}
__DATA__
companyXYZ:ABC:1
companyXYZ:DEF:3
companyZZZ:ABC:5
companyZZZ:DEF:7
------------------------------
Date: 27 Jul 2001 11:27:55 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Pattern Search and Replace nth Occurance
Message-Id: <m1zo9q9qhg.fsf@halfdome.holdit.com>
>>>>> "Ed" == Ed Robisheaux <eroby@webpositioning.com> writes:
Ed> I need to find the nth occurance of $pat in $line where $line may have
Ed> many occurances of $pat. The task here is to replace the nth occurance,
Ed> and not all of the occurances or just the first one.
Ed> Can someone offer an example of doing this?
Ed> This code always replaces all occurances:
Ed> while ($line=~/$pat/g) {
Ed> $line=~s/$pat/$repl/;
Ed> }
Ed> I want to replace, say, just the 3rd or 4th occurance.
my $n = 3; # 3rd occurance
$line =~ s/($pat)/ --$n ? $1 : $repl /ge;
print "Just another Perl hacker,";
--
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: 27 Jul 2001 14:26:30 -0700
From: jerzy_brzezicki@hotmail.com (jb)
Subject: Perl books for sale
Message-Id: <6791eac5.0107271326.c8486b5@posting.google.com>
Perl books for sale.
Used, but in good condition. May have my name written with marker or
some notes inside.
The list price is about 240. Amazon price is about 150.
Will sell all of them (together) for 75$. Will add Perl pocket
reference for free.
Please email to: jerzy_brzezicki@hotmail.com
1.
Learning Perl (2nd Edition)
by Randal L. Schwartz, Tom Christiansen, Larry Wall
ISBN: 1565922840
List Price: $29.95
Amazon Price: $20.96
2.
Effective Perl Programming: Writing Better Programs With Perl
by Joseph N. Hall
ISBN: 0201419750
List Price: $34.95
Amazon Price: $24.46
3.
Programming Web Graphics with Perl & GNU Software (O'Reilly Nutshell)
by Shawn P. Wallace, Richard Koman
ISBN: 1565924789
List Price: $32.95
Amazon Price: $23.06
4.
Programming the Perl DBI
by Alligator Descartes, Tim Bunce
ISBN: 1565926994
List Price: $34.95
Amazon Price: $24.46
5.
Writing Apache Modules with Perl and C: The Apache API and mod_perl
(O'Reilly Nutshell)
by Lincoln Stein, Doug MacEachern, Linda Mui
ISBN: 156592567X
List Price: $39.95
Amazon Price: $27.96
6.
Object Oriented Perl
by Damian Conway, Randal L. Schwartz
ISBN: 1884777791
List Price: $42.95
Amazon Price: $30.06
ALSO:
Perl 5 Pocket Reference (2nd Edition)
FREE
------------------------------
Date: 27 Jul 2001 11:44:50 -0700
From: srinivasanbala@netscape.net (Balaji)
Subject: question with arrays
Message-Id: <86e0f1f4.0107271044.5b514222@posting.google.com>
Hi comp.lang.perl.misc folks
my @nvp = split /&/, $ENV{QUERY_STRING};
This one gives me NAME=VALUE
if i split again
my @nvpnew = split /=/, $nvp[0];
and if i refer back with $nvpnew[0] , it gives NAME VALUE.How will i
get VALUE only from this array?
How will i directly create arrays for VALUES only so that I can refer
back later as $array[0],$array[1] etc..
I can create array from a file, but not directly from above said.
Thanks
------------------------------
Date: Fri, 27 Jul 2001 22:07:10 +0200
From: Philip Newton <pne-news-20010727@newton.digitalspace.net>
Subject: Re: question with arrays
Message-Id: <4ei3mtonkjbfls3l9pe2i4eahuvtoi4cs5@4ax.com>
On 27 Jul 2001 11:44:50 -0700, srinivasanbala@netscape.net (Balaji)
wrote:
> How will i get VALUE only from this array?
Looks like CGI stuff. If you use CGI.pm, you get the value with
$q->param('NAME').
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: 27 Jul 2001 20:59:32 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Regular Expression
Message-Id: <996267379.20496@itz.pp.sci.fi>
In article <996237059.10050.0.nnrp-14.c2de1f0e@news.demon.co.uk>, Lee Osborne wrote:
>"Lee Osborne" <osbornelee@hotmail.com> wrote in message
>news:996079173.11940.0.nnrp-01.c2de1f0e@news.demon.co.uk...
>>
>> What is the regular expresssion to check whether a string contains ONLY
>> numbers?
>
>$idLengthIn = length($input);
>if ($input{'document_id'} =~ /\d{$idLengthIn}/) {
> print "Digits ONLY!";
>}
>else {
> print "Not just digits!";
>}
That works. This should be simpler and quicker, however:
if ($input{document_id} !~ /\D/) {
print "Digits only. Could be empty..\n";
} else {
print "Contains a non-digit.\n";
}
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post something,
we discuss its implications. If the discussion happens to answer a question
you've asked, that's incidental." -- nobull in comp.lang.perl.misc
------------------------------
Date: Fri, 27 Jul 2001 18:21:10 GMT
From: "Antoine Hall" <AHALL5@nc.rr.com>
Subject: Returning Query Results of multiple pages
Message-Id: <qii87.24127$TM5.2265909@typhoon.southeast.rr.com>
I need to query a database based on the number of results a user wants to
see per page. So if a user wants 10 records per page and the query returns
back 40, how do I create a page with a next link to the next 10 query
results or how do I make a previous link to go back to the previous 10
results?
Thanks,
==
'Toine
------------------------------
Date: Fri, 27 Jul 2001 11:22:24 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Returning Query Results of multiple pages
Message-Id: <3B61B160.AAA8AC82@vpservices.com>
Antoine Hall wrote:
>
> I need to query a database based on the number of results a user wants to
> see per page. So if a user wants 10 records per page and the query returns
> back 40, how do I create a page with a next link to the next 10 query
> results or how do I make a previous link to go back to the previous 10
> results?
See my answer to the identical question in the thread "DBI:vvp-How to
display sql table results?".
--
Jeff
------------------------------
Date: Fri, 27 Jul 2001 20:34:52 +0200
From: Dirk Munzinger <d_munzinger@yahoo.de>
To: Samuel Kilchenmann <skilchen@swissonline.ch>
Subject: Re: Socket and TCP_NODELAY
Message-Id: <3B61B44C.7392C7E7@yahoo.de>
Hi Samuel,
> > I am using this code
> >
> > setsockopt($toClient,SOL_SOCKET,TCP_NODELAY,1)
> >
> TCP_NODELAY isn't exported by default in Socket.pm.
> SOL_SOCKET is the wrong level. Use IPPROTO_TCP (6) instead.
>
> try something like:
>
> use Socket;
> setsockopt($toClient, &Socket::IPPROTO_TCP, &Socket::TCP_NODELAY,
Great. Works fine now.
Thank you for the hint.
Tschau, Dirk
------------------------------
Date: Fri, 27 Jul 2001 20:12:04 GMT
From: Jonathan Sala <jonathan.sala@wichita.boeing.com>
Subject: Sorting problem
Message-Id: <3B61CB14.22B89759@wichita.boeing.com>
Is there a sort module that will sort the following first by
alphanumerically and then the last part numerically.
Example: Sort the following
abc23 abc113 cde34 abc5 cde4 def77 abc1
Into the following:
abc1 abc5 abc23 abc113 cde4 cde34 def77
Is there some sort module I should use to do this or just create my own
routine to do this?
Thanks,
Jonathan
------------------------------
Date: Fri, 27 Jul 2001 14:16:34 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Sorting problem
Message-Id: <3B61DA32.DE70B1D3@vpservices.com>
Jonathan Sala wrote:
>
> Is there a sort module that will sort the following first by
> alphanumerically and then the last part numerically.
>
> Example: Sort the following
> abc23 abc113 cde34 abc5 cde4 def77 abc1
>
> Into the following:
> abc1 abc5 abc23 abc113 cde4 cde34 def77
my @old = qw(abc23 abc113 cde34 abc5 cde4 def77 abc1);
my @new = sort {
my($charsA,$numsA) = $a =~ /^(\D*)(\d*)$/;
my($charsB,$numsB) = $b =~ /^(\D*)(\d*)$/;
$charsA cmp $charsB || $numsA <=> $numsB;
} @old;
print join ' ', @new;
--
Jeff
------------------------------
Date: 27 Jul 2001 11:06:51 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Re: sortlen -- filter to sort text by line length
Message-Id: <74f348f7.0107271006.200403df@posting.google.com>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<9jrso7$mp8$2@mamenchi.zrz.TU-Berlin.DE>...
> According to Yves Orton <demerphq@hotmail.com>:
<SNIP>
> > Can you point me to some references or should I just trawl usenet for
> > references to GRT?
>
> It's basically one paper, to be found at
>
> http://www.sysarch.com/perl/sort_paper.html
>
> among other places.
Cool thanks.
>
> > Also, its interesting that the GRT is not mentioned in books like Perl
> > Cookbook or Algorithyms in Perl (or whatever its called, I left it at
> > home.) The Cookbook covers the ST with quite a bit of depth, as does
> > Algorithyms... Seems like the GRT should at least have been mentioned.
>
> The GRT paper is newer than both these books.
Aha, that explains it all...
Cheers Anno.
------------------------------
Date: Fri, 27 Jul 2001 14:53:57 -0400
From: Edward Little Titan/SRC x4621 <strawNOSPAMman@plexi.com>
Subject: Re: sprintf
Message-Id: <3B61B8C5.174671E@plexi.com>
"Godzilla!" wrote:
> Edward Little Titan/SRC x4621 wrote:
>
> > How can I print a floating point number with leading zeros?
>
> (snipped)
>
> Others have provided good answers. However, I am curious
> why you would lead zero pad a whole number or a decimal
> number which is whole / decimal, such as 123.4 as an
> example. For a decimal number, .4 , this makes sense
> as in 0.4 to indicate whole number accuracy.
>
> Use of a zero padding is usually reserved for indication
> of accuracy of decimal places, this is, a trailing zero.
> Perhaps you are doing this for a database format.
>
> The quickest way to lead zero pad is,
>
> print "0$number";
>
> or
>
> $number = "0$number";
>
> However, a plus sign or minus sign or other number related
> characters would be a problem, if included in variable $number.
>
> Nonetheless, be careful about numbers returned in
> scientific notation. Simple testing will disclose
> why this is a problem.
>
> Godzilla!
------------------------------
Date: Fri, 27 Jul 2001 14:58:06 -0400
From: Edward Little Titan/SRC x4621 <strawNOSPAMman@plexi.com>
Subject: Re: sprintf
Message-Id: <3B61B9BE.495F0D74@plexi.com>
>
Sorry for the blank response.
I am constructing a string that represents a latitude or logitude number
in degree:minutes:seconds format.
I must have exactly 2 digits for minutes and two digits to the left of
the decimal for seconds.
Thanks for the help.
------------------------------
Date: Fri, 27 Jul 2001 13:31:20 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: sprintf
Message-Id: <3B61CF98.BDF7E317@stomp.stomp.tokyo>
Edward Little Titan/SRC x4621 wrote:
(snipped)
> I am constructing a string that represents a latitude or logitude number
> in degree:minutes:seconds format.
It is spelled "longitude."
> I must have exactly 2 digits for minutes and two digits to the left of
> the decimal for seconds.
Unless your returns are in decimal degree format, your format
will always be one or two digits for minutes. Why would you have
more than two digits for minutes? This is not possible unless
your methodology is in error. Your seconds can only have one
digit left of a decimal if seconds are less than ten. Simply
pad a leading zero if this is the case. Same simplicity applies
for minutes.
Based on what you have written within this article of yours,
my sincere suggestion is research and read about geometrical
coordinate systems employing latitude and longitude. It is
clear you are sorely lacking knowledge of this topic area.
Here are some search terms to assist you in learning.
latitude and longitude
cartography
maps
map making
map projections
geodesy
gnomonic projection
conic projection
Lambert conic projection
cylindrical projections
Mercator projections
Gerardus Mercator
Goode interrupted homolosine
Eckert equal area projection
azimuthal projection
Godzilla! Former UCR Geodesic Lab Wage Earner.
------------------------------
Date: 27 Jul 2001 20:14:26 GMT
From: nospam@hairball.cup.hp.com (Richard J. Rauenzahn)
Subject: Re: Unlinking lockfiles safely [was: Another flock question]
Message-Id: <996264865.614822@hpvablab.cup.hp.com>
Ilmari Karonen <usenet11530@itz.pp.sci.fi> writes:
>In article <996105779.145627@hpvablab.cup.hp.com>, Richard J. Rauenzahn wrote:
>>start:
>>open file (O_CREAT/O_EXCL)
>>if creation failed
>> open file
>> if success
>> lock it
>> remove (should usually fail with file not found)
>> close
>> endif
>> go back to start
>>else
>> lock it
>> do stuff
>> unlink
>> close
>>end
>>
>>This kind of puts you into a two stage lock scenario, but the flock
>>attempt lets you detect and remove stale lock files.
>
>You've still got race conditions. In particular, a process might steal
>a lockfile that has been created but not yet locked by another process.
I thought I allowed for that -- In order for another process to steal,
it would have to hit the if block (because the exclusive create would
fail), it would then open the already existing file.
That file gets unlinked before it gets unlocked (by a different
process)... Ah, so you could have a lock on a handle to an unlinked
file, and a new file could get created -- giving you two processes in
the critical section.
Perhaps theres a scheme using LOCK_SH and LOCK_EX where you could not
remove the file if it is currently LOCK_SH.. but I'm not even sure that
would work, and I seem to remember some recent controversy regarding
whether promotion works on all platforms.
The original poster was trying to limit the number of lock files in his
directory -- if his site isn't busy, he could try just having one lock
file for all access. =-)
Rich
--
Rich Rauenzahn ----------+xrrauenza@cup.hp.comx+ Hewlett-Packard Company
Technical Consultant | I speak for me, | 19055 Pruneridge Ave.
Development Alliances Lab| *not* HP | MS 46TU2
ESPD / E-Serv. Partner Division +--------------+---- Cupertino, CA 95014
------------------------------
Date: Fri, 27 Jul 2001 23:23:10 +0200
From: "J.Jacob" <jacobjf@cistron.nl>
Subject: win32.c:1631: structure has no member named `u'
Message-Id: <9jsm0d$og9$1@ncc1701.cistron.net>
I would like to use perl and to be able to convert my perl programs to C
code.
You have to build perl from source then, am i right ?
A new computer with winNT, upgraded to sp6a
Using gcc version 2.95.3-4 (mingw special)
I did everything like the README.win32 said, and did dmake in the win32/
directory.
Everything did look fine but then....
Oh well, i have to use the binary distribution now? And what is the deal
with crypt(), maybe
they could just distribute perl from Canada ?
Maybe i can still produce C code with the ActiveState Perl but as far as i
understand that is
not possible
Here is the error from dmake:
_EXTERNAL_GLOB -o.\mini\perlio.o ..\perlio.c
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -g
-O2 -o.\mi
ni\win32.o win32.c
win32.c: In function `win32_uname':
win32.c:1631: structure has no member named `u'
win32.c:1636: warning: unreachable code at beginning of switch statement
win32.c: In function `Nt4CreateHardLinkW':
win32.c:2486: warning: initialization from incompatible pointer type
win32.c:2505: union has no member named `u'
win32.c:2506: union has no member named `u'
win32.c: In function `win32_link':
win32.c:2537: warning: assignment from incompatible pointer type
win32.c: In function `w32_DomainName':
win32.c:3675: warning: assignment from incompatible pointer type
win32.c:3677: warning: assignment from incompatible pointer type
win32.c:3695: warning: passing arg 2 of `WideCharToMultiByte' makes integer
from point
er without a cast
win32.c:3699: warning: passing arg 2 of `WideCharToMultiByte' makes integer
from point
er without a cast
dmake.exe: Error code 1, while making '.\mini\win32.o'
------------------------------
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 1394
***************************************