[21922] in Perl-Users-Digest
Perl-Users Digest, Issue: 4126 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 15 18:06:48 2002
Date: Fri, 15 Nov 2002 15:05:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 15 Nov 2002 Volume: 10 Number: 4126
Today's topics:
Re: [Q] Script to search auction sites? (Sir Loin of Beef)
Re: [Q] Script to search auction sites? <usenet@dwall.fastmail.fm>
Re: A vision for Parrot (Peter da Silva)
Calling CGI script in restrcted dir (.htaccess) from ou <none@none.com>
Re: Calling CGI script in restrcted dir (.htaccess) fro <nobull@mail.com>
dealing with multiple entires in a multi-dimensional ha (Randy Rostie)
Re: dealing with multiple entires in a multi-dimensiona <nobull@mail.com>
Re: Deleting from a fixed Length Flat File Database usi <nobull@mail.com>
dynamic class loading in perl making me INSANE!!! (shaneholland)
Re: dynamic class loading in perl making me INSANE!!! <nobull@mail.com>
Re: how do I turn off unicode on file I/O? (Jamie Zawinski)
Re: In a Perl script executing a c-shell script to exec (Vorxion)
Re: In a Perl script executing a c-shell script to exec (Walter Roberson)
Re: installing perl on winxp (Alan Barclay)
Re: installing perl on winxp (thebladerunner)
Re: Is there something like the sh -x option in perl? <nobull@mail.com>
minor update: lace/spandit client <th@sanger.ac.uk>
OS/390 perl 5.8.0 help? <gohabsgoNOSPAM@mailandnews.com>
Re: Perl searching a huge mySQL database... ctcgag@hotmail.com
Re: Reading an input file as scalar. <nobull@mail.com>
Re: Reading an input file as scalar. <nobull@mail.com>
Re: Reading an input file as scalar. <krahnj@acm.org>
Re: Socket client/server example not working on Windows <goldbb2@earthlink.net>
Re: Sort multidimensional hash? <nobull@mail.com>
Re: Sort multidimensional hash? ctcgag@hotmail.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 15 Nov 2002 19:33:47 GMT
From: NOSPAMmdknight@pacific.net.sg (Sir Loin of Beef)
Subject: Re: [Q] Script to search auction sites?
Message-Id: <3dd54ba3.1156514@news.pacific.net.sg>
>You said you've used Basic + Turbo Pascal; how would you solve the problem
>in one of those languages?
>
>You might look at scalar value constructors in perldata, and also in perlop
>under additive operators.
>
In basic, it'd be easy.
This is the line in perl:
get("http://www.interauct.com.sg/searcheng/auc?region=1&item=mySearchTerm");
I'd send the following line out for BASIC:
outputline$="http://www.interauct.com.sg/searcheng/auc?region=1&item="
+ $mySearchTerm
get(outputline$)
but in Perl, mySearchTerm is sent out directly rather than replaced
with the value it contains.
------------------------------
Date: Fri, 15 Nov 2002 20:08:46 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: [Q] Script to search auction sites?
Message-Id: <Xns92C79A134DA6Ddkwwashere@216.168.3.30>
Sir Loin of Beef <NOSPAMmdknight@pacific.net.sg> wrote on 15 Nov 2002:
>
>>You said you've used Basic + Turbo Pascal; how would you solve the
>>problem in one of those languages?
>>
>>You might look at scalar value constructors in perldata, and also in
>>perlop under additive operators.
Use the docs, Loin.
> In basic, it'd be easy.
>
> This is the line in perl:
>
> get("http://www.interauct.com.sg/searcheng/auc?region=1&item=mySearchTerm
> ");
>
>
> I'd send the following line out for BASIC:
>
> outputline$="http://www.interauct.com.sg/searcheng/auc?region=1&item="
> + $mySearchTerm
>
> get(outputline$)
>
> but in Perl, mySearchTerm is sent out directly rather than replaced
> with the value it contains.
So in Basic you would use a string concatenation operator. Perl also has a
string concatenation operator, but it isn't '+'.
You can also use variable interpolation inside double-quoted strings.
The mention of specific sections in perldata and perlops wasn't just a
gratuitous nod to the docs, it was meant to point you to exactly the
sections you need to read to learn how to do what you want. Was there
something in them you didn't understand?
--
David K. Wall - usenet@dwall.fastmail.fm
"Oook."
------------------------------
Date: 15 Nov 2002 22:05:02 GMT
From: peter@abbnm.com (Peter da Silva)
Subject: Re: A vision for Parrot
Message-Id: <ar3r2e$kr0@web.eng.baileynm.com>
In article <3DD01A21.2E4968D7@earthlink.net>,
Benjamin Goldberg <goldbb2@earthlink.net> wrote:
> > A binding isn't a procedure.
> That depends on your interface to Tk ... in perl, a binding *is* a
> procedure.
In Tcl it isn't. It's a string.
--
I've seen things you people can't imagine. Chimneysweeps on fire over the roofs
of London. I've watched kite-strings glitter in the sun at Hyde Park Gate. All
these things will be lost in time, like chalk-paintings in the rain. `-_-'
Time for your nap. | Peter da Silva | Har du kramat din varg, idag? 'U`
------------------------------
Date: Fri, 15 Nov 2002 20:55:08 GMT
From: "MR" <none@none.com>
Subject: Calling CGI script in restrcted dir (.htaccess) from outside shtml (SSI) ?
Message-Id: <MadB9.318$G_2.42811510@newssvr14.news.prodigy.com>
I have a script in a dir in my /cgi-bin that is password restricted by my
.htaccess file:
--- .htaccess ---
<limit GET POST PUT>
require valid-user
</limit>
AuthType Basic
AuthName SR-CGI-BIN
AuthUserFile /www1102/web/htpasswd
AuthGroupFile /dev/null
--- End ---
( /www1102/web/ is my absolute web dir)
If manually try to run the script by just typing it's url in the address bar
ofa browser, I'll be asked for a name and pass. Ok, fine. But if I want to
call the script in a .shtml file (ssi) out side my cgi-bin, I get the
standard "[an error occurred while processing this directive]" where the
script's output should be. This works fine if I rename or remove the
.htaccess file in question.
My question is how can I allow a specific shtml page to ru na protected
script like this? Or is there a way to pass a name/pass?
The line in the shtml is:
<!--#exec cgi="/cgi-bin/SR/CAON/caon_aa.cgi" -->
Can anything be added to it to pass name or pass?
Or is there some way I can edit my .htaccess file to allow the shtml (
/caon/aa/index.shtml relative to by web dir; /caon is parallel to /cgi-bin)
Thanks a lot in advance!
------------------------------
Date: 15 Nov 2002 21:14:57 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Calling CGI script in restrcted dir (.htaccess) from outside shtml (SSI) ?
Message-Id: <u9fzu2zga6.fsf@wcl-l.bham.ac.uk>
"MR" <none@none.com> writes:
> Newsgroups: comp.lang.perl.misc
This is a Perl news group. Here we discuss matters relating, in at
least some way, to Perl
> Subject: Calling CGI script in restrcted dir (.htaccess) from outside shtml (SSI) ?
This question does not relate to Perl in any way.
The fact that the CGI script could be is written in Perl doe not alter
this any more that the fact that the HTML page was written in Japanese
would make this a question about Unicode.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 15 Nov 2002 12:39:46 -0800
From: nospam@rostie.net (Randy Rostie)
Subject: dealing with multiple entires in a multi-dimensional hash
Message-Id: <f2f84e1f.0211151239.49071a1@posting.google.com>
Thanks for the help with figuring our how multi-dimensional hashes
work.
Now I need help with the next step.
First a brief overview of what the script does. It builds a
multi-dimensional hash from a list of users and files, and some
information about the files.
Each line looks something like the following (without the spaces)
$user /t/t $file /t/t $safe /t/t $version
Here is the code I have so far, which lists the files
#!/usr/bin/perl -w
use strict;
my %users;
#my $user,$file,$safe,$version;
# Replace whatever with filename from other script.
my $filename = "files.found";
open(FILE, "$filename")||die("Opening File: $!");
my($hostname,$randate,$rantimestamp) = split /\t\t/, <FILE>;
while(<FILE>){
chomp;
my ($user,$file,$safe,$version) = split /\t\t/;
$users{$user}{file} = $file;
$users{$user}{safe} = $safe;
$users{$user}{version} = $version;
}
close(FILE);
foreach my $user (keys %users) {
#this line doesn't affect the output if it's uncommented
#next if $users{$user}{safe} eq 'yes';
print "User $user\n";
print "File $users{$user}{file}\n";
print "Safe $users{$user}{safe}\n";
print "Version $users{$user}{version}\n\n";
}
I am rewritng a script that someone else did for me for a related
issue.
What it eventually does is look up the account information in a mysql
database, and send an email to each user telling them about certain
scripts they need to remove or upgrade.
The problem I have now is how to keep from sending each user a
seperate email.
The original script prefixed lines where the the user was already in
the hash index with 3 \t characters, but this made it difficult for me
to get the info back put of the hash:
# Check to see if this user has another script in here
if (exists $users{$user}){
# Yes they do, add this file to it.
$users{$user} .= "\t\t\t$file\t\t$safe\t\t$version";
}else{
# No they don't
$users{$user} = "$file\t\t$safe\t\t$version";
}
Isn't there any easier way to do this?
------------------------------
Date: 15 Nov 2002 21:07:34 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: dealing with multiple entires in a multi-dimensional hash
Message-Id: <u9k7jezgmh.fsf@wcl-l.bham.ac.uk>
nospam@rostie.net (Randy Rostie) writes:
> Thanks for the help with figuring our how multi-dimensional hashes
> work.
>
> Now I need help with the next step.
>
> First a brief overview of what the script does.
[ snip lots of context relating to multi-dimensional hashes ]
> # Check to see if this user has another script in here
> if (exists $users{$user}){
> # Yes they do, add this file to it.
> $users{$user} .= "\t\t\t$file\t\t$safe\t\t$version";
> }else{
> # No they don't
> $users{$user} = "$file\t\t$safe\t\t$version";
> }
>
> Isn't there any easier way to do this?
That's not a multi-dimensional hash and doesn't seem to relate to the
stuff that went before.
It's therefore impossible to figure out to what "do this" refers.
I'm going to guess that "do this" is "store a mapping from a scalar
to a list of tuples".
The more natural Perl structure for this would be a
hash-of-arrays-of-hashes.
push @{$user{$users}} => {
file => $file,
safe => $safe,
version => $version,
};
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 15 Nov 2002 19:04:57 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Deleting from a fixed Length Flat File Database using Perl and HTML
Message-Id: <u9heei1wo6.fsf@wcl-l.bham.ac.uk>
Dan, I've given you a lot of advice which, if followed, will help you
a lot. If you doen't want a lot of advice and just want to know why
your program fails go ditrectly to the point marked [XXX].
thrupwelder@hotmail.com (Dan) writes:
> I have a HTML page created dynamically which produces a table of member
> details for my Website. This includes name, e-mail, password, etc. Each
> row of this table is created as a seperate form, in order to post info to
> another perl script which controls the deletion of a single record.
>
> When I click delete, the script 'del.pl' is called, but fails to function
> correctly. From the command line, the script appears to work fine
> (including the file manipulation), except I am unsure how to pass
> parameters 'a la POST method' in this way.
No problem, just consult the documentation for the module you are
using to parse the CGI request to see how to use it in command line
debug mode. Oh, you are not using the standard module, you are
rolling your own... then you'll have to roll your own debug mode too.
> When called via a Web page,
> the script executes up until the files are accessed. If I put the HTML
> code before the file access, it is displayed, any HTML after the file
> access is ignored. If I place all HTML code after the file access, I get
> an "Internal Server Error".
You mean the one that say to look in the server error log?
What did you find there when you did that?
> Someone suggested two things to me on the PlusNet discussion forum:
> 1- There is a problem with the parsing on the post info.
> BUT- The post info is fine, I get the HTML to display it for testing
> purposes
>
> 2- The HTML header is being sent incorrectly.
You mean CGI not HTML.
> BUT- Surely HTML wouldn't display at all if this was the case,
Are you saying that part of your script's output appears on the same
page as "Internal Server Error" message?
> and
> besides, I use the same HTML header for all my scripts and have never had
> this problem before.
You mean CGI and HTML headers.
So of course you've put it in a module haven't you? That way if you
discover a mistake in it (or just decide you'd like to change it) you
only have to change it once.
But if your program prints anything before the CGI header then the web
server will try to interpret this as part of the CGI header.
> I thought it may be permissions, but have tried a few different
> combinations. It is now 755 for the script and 766 for the data file.
766 is rwxrw-rw-
Why would anyone want execute permission on the datafile?
> I have included the listing, and I hope someone can help :o)
>
> Dan
>
>
> ********** The listing to the program is below **********
>
> NOTE: You will notice some lines are commented out, this is just me trying
> to simplify things. If you think putting the lines back in will help,
> please tell me.
>
>
> #!/usr/bin/perl --
You forgot:
use strict;
use warnings;
Declare all variables in the smallest enclosing lexical scope.
These are standard safety precautions. Like using ropes when climbing
they will slow you down at first until you get used to them. And like
ropes when climbing the time invested will be more than paid back the
first time you slip. After that you are in profit.
> #writetofile.pl program
> #From Bob's Notes 6/11/01
> #Seperates all values sent from form
>
> #uses a module to define a record structure for the form details
> require ("memstruct.pm") || die ("Can't find structure file :$1\n");
require() does not return false on failure. It dies. No need to add
your own die() in this case. And WTF is $1 doing in thre?
For loading files with a .pm extension the bareword syntax is more
conventional:
require memstruct;
> #Get POSTed info. from html form - if this prog is called from cgi-bin
> read (STDIN, $postinfo, $ENV{'CONTENT_LENGTH'} );
[ snip home-rolled CGI parser ]
Don't do that, use the standard module.
> # Find and delete address
>
> #Open database file for reading, may need to provide full path
> open LOOK, "../members.dat" or die "Can't find file look\n";
You don't know that the file couldn't be _found_ you know it couldn't
be opened. The reason couldn't opened is in the $! variable. "not
found" is just one possibility.
Is there a particular reason you don't want the line number in your
error message or do you just like to make life hard for yourself?
You are using a relative path. Do you know what current working
directory the webserver set when it calls the script? (The CGI
standard doesn't define what the current working directory should
be[XXX]. IMHO this is a bad thing.)
BTW: You forgot to lock the file. That will create a race contition.
> #Read all records
> while (<LOOK>) {
> ($fname, $sname, $age, $email, $pass1) = unpack($memstruct, $_);
> #($fname, $sname, $age, $email, $pass1) =~ s/\0//g;
> #$email =~ tr/+/ /;
> #$email =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack("C", hex($1))/eg;
> #$email =~ tr/A-Z/a-z/;
>
> #When e-mail is found, skip to next element in infoarray1.
That comment seems to have nothing to do with the code.
> if ($infoarray[0] ne $email) {
> $newarray[$a] = $_;
> $a = $a + 1;
perldoc -f push
> }
> else {
> next;
> }
> } #End of While
Why do you have a next() just before the end of the loop block?
> close LOOK;
Had you not forgotten to lock the file in the first place that would
have released the lock prematurely.
> #Open temp database file for writing
> open TEMP, ">../members.tmp" or die "Can't find file temp\n";
This is even better than last open()! Not only do you not print the
actual reason but the guessed reason you do print is not even a
possible reason!
> for($a=0; $a<=$#newarray; $a++) {
> print TEMP $newarray[$a];
> }
Do not use the C-style for in Perl unless you have a reason to do so.
for ( @newarray ) {
print TEMP;
}
> close TEMP;
>
> unlink("../members.dat");
There is no need to unlink a file before you rename over the top of
it. At least not on a real OS :-). Doing so creates a race condition.
> chmod "502", "../members.tmp";
Why do you want is 502 treated as a string? It won't be anyhow,
chmod will convert the string "502" into the number 502.
It would aid readability to write it as 0766.
> rename("../members.tmp", "../members.dat");
>
> &html_header ();
Why are you telling Perl to ignore the prototype defined for
&html_header? It hasn't got one anyhow and if it had it wouldn't work
because you have to declare prototypes before the call.
> print "<body bgcolor=\"#FFCC22\" text=\"#330000\">\n";
> #print "<font face=\"verdana, arial, helvetica, sans-serif\"
> size=\"2\">\n";
> print "<p>$infoarray[0]</p><h2>Details have now been deleted</h2>\n";
> #print "<br><br>\n";
> #print "</font>\n";
> # Find and delete address
> #Print back navigator
> print "<br><br><center><a href=\"javascript: history.go(-1)\"><< Click
> here to go back</a></center><br>\n";
> &html_ender();
>
> exit 0;
This is the default behaviour when execution reaches the end of the
file. There's no need to say it explicitly.
> sub html_header
> {
> print "Content-type:text/html \n\n";
>
> # Put up standard HTTP opening line.
> # Specify HTML document
> print "<HTML> \n\n";
>
>
> print "<STYLE><!--\n";
> print "A {text-decoration:none; color:#330000;}\n";
> print "A:hover {text-decoration:underline; color:#330000;} --></STYLE>\n";
> # Specify header section
> print "<HEAD>\n";
Hmmm... remember what I said about having to fix it in lots of places
when you found a mistake in html_header? Well I've just found one.
In valid HTML the <STYLE> element must appear _inside_ the <HEAD>
element.
> # Put up the title line
> print "<TITLE>", "@_", "</TITLE>\n\n";
Is there any particular reason you choose to print() three strings
rather than one?
> # End header section
> print "</HEAD>\n";
> } #end html_header routine
You seem to be suffering form an affliction that is all to common.
You are not using comments correctly. The perpose of a comment is to
explain what the code is doing where this is not obvious to somebody . The trouble
is that when people are first learning they see programming examples
intened for people unfamiliar with languages involved. In such
examples the comments explain the language in minute detail. Such
comments should only appear in such examples! It is not good (or even
sane) practice to put then in real programs.
Also try to adopt a consitant commenting convention. Most people put
comments above or to the right of the what they describe. You follow
this most of the time but not all of the time.
The only comment that in your html_header subroutine is of any value
was the final one. Although on such a short subroutine that too would
be redundant if you'd employed sensible indentation.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 15 Nov 2002 13:24:46 -0800
From: shane@shaneholland.com (shaneholland)
Subject: dynamic class loading in perl making me INSANE!!!
Message-Id: <ed02563d.0211151324.5f7c128f@posting.google.com>
why cant i get this to work? ...
package AbstractPackage;
sub lookupMethod {
my ($self, $obj) = @_;
$className = $obj->getSomeRelatedClassName(); # works
eval "require $className"; # no idea
return $className->new(); # bombs
}
1;
---
package ConcretePackage;
our @ISA = qw(AbstractPackage);
sub someMethod {
my ($self, $fooObj) = @_;
my $relatedObj = $self->lookupMethod( $fooObj);
}
1;
----------------------
Now the problem is that when i call new on relatedObj i get an error
like: Can't locate object method "new" via package ... my className
... at ... AbstractPackage.pm line ..
i guess the package isnt loaded and cant find the new method, although
i dont see why since i told perl to load it with 'eval "require
$className"' right? is there a way to force the package to load using
some method other than require?
if i change it to 'eval "use $className"' i get the same error with
the addition of "(perhaps you forgot to load ... className ... )" ...
which makes NO sense to me either since the path and filename are
spelled correctly and @INC is correct.
------------------------------
Date: 15 Nov 2002 22:21:07 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: dynamic class loading in perl making me INSANE!!!
Message-Id: <u9y97ueap8.fsf@wcl-l.bham.ac.uk>
shane@shaneholland.com (shaneholland) writes:
> Now the problem is that when i call new on relatedObj i get an error
> like: Can't locate object method "new" via package ... my className
> ... at ... AbstractPackage.pm line ..
This may seem like a silly question but you did define the new()
method somewhere didn't you?
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 15 Nov 2002 15:03:05 -0800
From: jwz@jwz.org (Jamie Zawinski)
Subject: Re: how do I turn off unicode on file I/O?
Message-Id: <8ef0bdd0.0211151503.39df03df@posting.google.com>
Benjamin Goldberg wrote:
>
> So, in conclusion, you need to set the mode of the file you're reading
> from to ":bytes" (or maybe ":encoding(latin1)" (though only after
> loading the Encode.pm module)), and you need to set the mode of STDOUT
> to either ":bytes" or ":utf8" or whatever you're xterm or whatever will
> understand.
This worked, thanks!
open (IN, "</tmp/a") || die;
binmode(IN, ":bytes");
binmode(STDOUT, ":bytes");
------------------------------
Date: 13 Nov 2002 23:22:39 -0500
From: vorxion@fairlite.com (Vorxion)
Subject: Re: In a Perl script executing a c-shell script to execute a fortran program, how to?
Message-Id: <3dd3250f$1_2@news.iglou.com>
In article <1037240673.756473@elaine.furryape.com>, Alan Barclay wrote:
>In article <3dd2fb76$1_2@news.iglou.com>, Vorxion <vorxion@fairlite.com> wrote:
>>In article <aquqq9$msr$1@canopus.cc.umanitoba.ca>, Walter Roberson wrote:
>>#!/bin/csh -f
>>
>>...The -f prevents it from reading any user's .cshrc and thus possibly
>>driving something whacky. It (-f) should generally always be used in
>>both csh and tcsh scripts.
>
>But even with -f, csh scripts can do wacky things. See 'csh programming
>considered harmful' by some guy called Tom Christiansen.
I programmed in csh/tcsh for a decade before switching to perl. With the
exception of lack of being able to redirect stderr without redireting
stdout, I found the rest of the arguments against it pretty weak.
It was never meant to be as powerful as perl. With the facilities it
provides, it's easy to do some pretty complex stuff though. Problem being
that most of it is relying on externals.
I prefer it to Bourne, let's put it that way.
I've read the paper...I don't agree with any of it except the redirect
issue, which is my only pet peeve with it.
--
Vorxion - Member of The Vortexa Elite
------------------------------
Date: 15 Nov 2002 20:26:31 GMT
From: roberson@ibd.nrc.ca (Walter Roberson)
Subject: Re: In a Perl script executing a c-shell script to execute a fortran program, how to?
Message-Id: <ar3l9n$4ju$1@canopus.cc.umanitoba.ca>
In article <3dd3250f$1_2@news.iglou.com>, Vorxion <vorxion@fairlite.com> wrote:
:I programmed in csh/tcsh for a decade before switching to perl. With the
:exception of lack of being able to redirect stderr without redireting
:stdout, I found the rest of the arguments against it pretty weak.
:I've read the paper...I don't agree with any of it except the redirect
:issue, which is my only pet peeve with it.
The paper has a lot of "X doesn't work in csh". When you say that
you "don't agree with" the paper, you are implicitly asserting that
you *can* do those things in csh (in a reasonable manner). If
you *can* do them, then publish a rebuttal to the paper with code
snippets.
My guess is that it isn't the case that you "don't agree with any of"
the paper: my guess is that you simply don't agree that the particular
issues pointed out are -significant-.
--
You have reached The Usenet Community. Please have your contract
information available. If you know your party's extention, you may
enter it at any time. To reach a support specialist, please enter 1
now. For an accounting, please enter 2. For sales, please enter 3.
------------------------------
Date: 15 Nov 2002 18:27:07 GMT
From: gorilla@elaine.furryape.com (Alan Barclay)
Subject: Re: installing perl on winxp
Message-Id: <1037384827.396506@elaine.furryape.com>
In article <3dd4d1f7.2619814734@news.cis.dfn.de>,
Helgi Briem <helgi@decode.is> wrote:
>The "workstation" version, which is a minor upgrade of
>Win2K/NT, does have access restrictions and ordinary
>users can *not* install programs or can only write to
>registry keys in the "CURRENT USER" hive. I was assuming
>this version, but of course there is the "home" type that
>I have never used and forgot about.
And as Indigoperl doesn't write to the registry at all, this
isn't a problem.
All Indigoperl's install script does is create entries on the start
menu, and change the path, both of which are non-essential.
------------------------------
Date: 15 Nov 2002 13:50:41 -0800
From: thebladerunner@hotmail.com (thebladerunner)
Subject: Re: installing perl on winxp
Message-Id: <4968ad8e.0211151350.27e1d9b1@posting.google.com>
helgi@decode.is (Helgi Briem) wrote in message news:<3dd4d1f7.2619814734@news.cis.dfn.de>...
> On Thu, 14 Nov 2002 20:44:56 -0600, "William Alexander
> Segraves" <wsegrave@mindspring.com> wrote:
>
> >"Helgi Briem" <helgi@decode.is> wrote in message
> >news:3dd3c762.2551564425@news.cis.dfn.de...
> >> On Thu, 14 Nov 2002 06:54:46 -0600, "William Alexander
> >> Segraves" <wsegrave@mindspring.com> wrote:
> <snip>
> >> >You might try installing IndigoPerl, www.indigostar.com, on your XP box.
> It
> >> >worked fine when I did this on my son's (similar) XP system.
> >>
> >> No, if he is only an ordinary user he is not allowed to
> >> set up any programs. He has to ask the administrator
> >> to allow him to do that.
> >
> >Helgi, I'd have to defer to your expertise on WinXP. All I know is that I
> >was able to install and use IndigoPerl on my son's WinXP Dell system. IIRC,
> >I was logged in under my own user name, not his (; but I could be wrong).
> >
> >What you appear to be suggesting is that a user of WinXP cannot install a
> >program under his own user name unless he has admin privileges. Do you know
> >that to be true?
>
> OK, WinXP does have a "home" version, I can't remember
> what it's called, that basically has no acccess
> restrictions, similar to the Win95/98/Me family. Any
> user is probably able to install stuff on that. Whether
> it is accomplished by putting all users in the Administrator
> group or by doing away with access restrictions altogether
> by using the FAT system instead of NTFS, I don't know.
>
> The "workstation" version, which is a minor upgrade of
> Win2K/NT, does have access restrictions and ordinary
> users can *not* install programs or can only write to
> registry keys in the "CURRENT USER" hive. I was assuming
> this version, but of course there is the "home" type that
> I have never used and forgot about.
Helgi is correct, you must have installed on XP Home edition, not the
Professional edition. I have had no luck whatsoever with either
version of Perl. I think the general concensus is that I am screwed.
As my old programming guru was fond of telling me, "sucks to be you."
-- thebladerunner
------------------------------
Date: 15 Nov 2002 19:22:58 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Is there something like the sh -x option in perl?
Message-Id: <u93cq21vu5.fsf@wcl-l.bham.ac.uk>
reg@orion.dwf.com (Reg Clemens) writes:
> The command line says it all, is there a way to run perl such that it
> prints out lines as it executes them? I have a perl script here that
> worked, but has stopped. Seeing where/what its is doing would be
> a big help...
PERLDB_OPTS="NonStop AutoTrace" perl -d myscript.pl
For more information about the Perl debuger...
perldoc perldebug
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 15 Nov 2002 14:31:26 -0600
From: Tim Hubbard <th@sanger.ac.uk>
Subject: minor update: lace/spandit client
Message-Id: <3DD55A08@webmail.bcm.tmc.edu>
Forwarded Message from: Tim Hubbard <th@sanger.ac.uk>
Dear Zhengdong, Lisa,
I've just done a tiny bit of tidying up. I've repackaged the tar
file (so it unpacks in a subdirectory), renamed it and moved it.
There's also an unofficial alpha versions of acedb binaries for
macosx (these work on my machine - there are a few issues with what
is on the www.acedb.org site - but beware - normal warnings of alpha
software). New location is:
ftp://ftp.sanger.ac.uk/pub/th/lace-spandit/
Best wishes,
Tim
--
-------------------------------------------------------------------------
Dr Tim Hubbard email: th@sanger.ac.uk
Wellcome Trust Sanger Institute Tel (direct): +44 1223 494983
Wellcome Trust Genome Campus Tel (switch): +44 1223 834244
Hinxton Fax: +44 1223 494919
Cambridgeshire. CB10 1SA. URL: http://www.sanger.ac.uk/Users/th
-------------------------------------------------------------------------
------------------------------
Date: 15 Nov 2002 20:41:12 GMT
From: GoHabsGo <gohabsgoNOSPAM@mailandnews.com>
Subject: OS/390 perl 5.8.0 help?
Message-Id: <Xns92C79F7D1CC22gohabsgomailandnewsc@130.133.1.4>
Has anyone installed perl-5.8.0 on OS/390?
I have gone as far as running the Configure script and I run into an
error
right after these prompts.
++++ start of errors
What libraries to use? [-lm -lc]
By default, perl5 compiles with the -O flag to use the optimizer.
Alternately, you might want to use the symbolic debugger, which uses
the -g flag (on traditional Unix systems). Either flag can be
specified here. To use neither flag, specify the word "none".
What optimizer/debugger flag should be used? [none]
eval: Configure 4650: FSUM7345 no file descriptor available
CA09999//perl/perl-5.8.0:>
++++ end of errors
Can anyone shed any light. Don't know where else to go for an aswer.
Thanks,
Larry
------------------------------
Date: 15 Nov 2002 20:09:02 GMT
From: ctcgag@hotmail.com
Subject: Re: Perl searching a huge mySQL database...
Message-Id: <20021115150902.745$fY@newsreader.com>
krakle@visto.com (krakle) wrote:
> I'm about to work on a project that will allow many users to enter
> rows and fields into a mySQL database from a Perl script. I need to
> make the database searchable for quick and easy finding. Speed and
> time is very crucial. With Perl, is it possible to search a large
> database with in a reasonable amount of time?
Searching databases is what the database engine is for. If you have a
mySQL database, you search it with mySQL. Perl may initiate the searches
and format the results, but it doesn't perform the search[*], so your
concern is misplaced.
> Any additional modules
> to look into? Any tips and insight for me?
Additional to what? We don't what modules you already looked into.
Xho
* Some things are ill-suited to searching in normal SQL, so you can
sometimes split a search criteria in two, using some conditions to pull
out a restricted result set from mySQL, then using Perl to apply the other
conditions to this set.
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service
------------------------------
Date: 15 Nov 2002 19:14:44 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Reading an input file as scalar.
Message-Id: <u97kfe1w7v.fsf@wcl-l.bham.ac.uk>
Tina Mueller <usenet@tinita.de> writes:
> Brian McCauley <nobull@mail.com> wrote:
>
> > I'm curious where whe OP found this. It's not the answer given to
> > this question in the FAQ: "How can I read in an entire file all at
> > once?"
>
> it is in version 5.6.1:
> | On very rare occasion, you may have an algorithm that
> | demands that the entire file be in memory at once as one
> | scalar. The simplest solution to that is
> | $var = `cat $file`;
> [...]
>
> seems that it has been removed since 5.8.0
Ah! I forgot that although my perl is currently 5.6.1 my perldoc is
currently 5.8.0. Oops.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 15 Nov 2002 19:12:35 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Reading an input file as scalar.
Message-Id: <u9bs4q1wbg.fsf@wcl-l.bham.ac.uk>
Arnar Mar Hrafnkelsson <addi@umich.edu> writes:
> > > > Code:
> > > > $ui = `cat $file`;
> > >
>
> I'm not sure if the actual question has been answered already.
> My apologies if so.
I has, the FAQ.
> What about something like:
[ snip same answer as in the FAQ ]
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 15 Nov 2002 21:40:06 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Reading an input file as scalar.
Message-Id: <3DD56991.D6B03178@acm.org>
Arnar Mar Hrafnkelsson wrote:
>
> > > > Code:
> > > > $ui = `cat $file`;
> > >
>
> I'm not sure if the actual question has been answered already.
> My apologies if so.
>
> What about something like:
>
> { local (*FH,$/); open(FH, "<$file") or die "$!\n"; $ui = <FH>; }
>
> That is completely platform independant and should work everywhere,
> right?
Close, but it should be:
my $ui = do { local( *FH, $/ );
open FH, $file or die "$file: $!";
binmode FH;
<FH> };
Note that binmode() is required on some platforms.
John
--
use Perl;
program
fulfillment
------------------------------
Date: Fri, 15 Nov 2002 15:45:11 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Socket client/server example not working on Windows 2K
Message-Id: <3DD55CD7.617C2408@earthlink.net>
John Ramsden wrote:
> Rocco Caputo wrote:
> > On 12 Nov 2002 11:23:27 -0800, John Ramsden wrote:
> > > I prepared a short pair of prototype socket client-server
> > > programs, planning to expand them into what is required
> > > for a project I am engaged on at work.
> > >
> > > On Unix (SunOS) everything works fine with one or more clients
> > > each with a TCP socket connection to the server at once, which
> > > is the intention.
> > >
> > > On Windows 2K (using ActiveState Perl v5.6.1 build 631,
> > > MSWin32-x86-multi-thread) the pair work fine with a single
> > > client; but if _two_ clients are started then the server
> > > displays all output from the first client immediately,
> > > but buffers all output for the second client (and only
> > > displays this when the first client disconnects).
> >
> > Unless this is an exercise to learn BSD sockets, consider using
> > IO::Socket::INET to build them rather than the low-level calls.
>
> Many thanks for your reply, Rocco. I only wish I could use IO::Socket.
> But the snag is the server will be receiving a constant stream of
> event messages from various clients and has to store these in a
> different MySQL database for each. So if everything had to run
> explicitly in one process, my server code would be constantly
> disconnecting from one database and connecting to another.
Err, why? You can have more than one database connection open in a perl
process.
> (Of course, if there is a nifty way of calling DBI::connect on more
> than one database, and switching quickly between them, then this
> would avoid the problem.
Yes, you make one database handle for each database, and switch between
handles as needed.
> Perhaps one can call DBI::connect on some database, and then just
> execute 'use <database>'; statements to switch databases thereafter.
No, you call DBI->connect for *each* database, and store the handle
somewhere.
> Anyway, I won't speculate further here, as SQL is off-topic for Perl.)
It's not a matter of SQL, but a matter of using the DBI. Which makes it
on-topic for Perl.
> > What status messages does the server print when the second client
> > connects? Tracing through them might help determine the problem.
>
> I did manage to eliminate the output buffering problem on Windows
> by replacing every read() and write() socket call by sysread() and
> syswrite() resp.
>
> Works fine with one client, then two, then more. _But_ as soon as
> a client disconnects (even with the $SIG{CHLD} assignment commented
> out in the server code), the server bombs out with a message window
> comprising:
>
> perl.exe has generated errors and will be closed by Windows.
>
> An error log is being created
>
> which is a fat lot of use, as it doesn't give any the name or
> location of the error log (and I couldn't find any file called
> *.log or *.err anywhere in the Perl directory tree). Does anyone
> know where this error log goes?
Well, if you were using unix, the file would be called "core".
But even so, this would be a binary file, and not useful unless you have
a C debugger, such as gdb.
> Anyway, I then upgraded from ActiveState perl v5.6.1 to v5.8.0
> (beta), hoping that all these problems would go away. But now
> things are much _worse_, as the server bombs out with the above
> message as soon as the first client tries to connect!
>
> Looks like the signal handling, newly introduced in 5.8.0 as the
> readme file says, has gone pear-shaped!
Signal handling has been around for much longer than that... but it was
altered in 5.8.0 so that fewer segmentation faults, etc, could occur.
> > If fork() is misbehaving under MSWin32-- and it may be, because
> > fork() is implemented with threads on that platform-- consider
> > using IO::Select to multiplex the connections in a single process.
>
> I really wish the judge in the recent Microsoft anti-trust case
> had included in the settlement conditions a caveat that all Windows
> versions must incorporate a kosher, copy-on-write fork() call, to be
> made publicly available on free upgrade packs within, say, six months.
Windows doesn't include *any* kind of fork. Perl uses threads to fake
it.
> If not then he/she missed a major trick, as the absence of a fork()
> causes huge problems for all kinds of Unix-to-Windows ports, not just
> Perl, and its continuing absence seems to me like a clear-cut example
> of Microsoft's obstructive tactics that the court case was all about.
On unix, fork is generally used for two things -- starting new,
seperate, process (usually done as fork then exec), and for having one
program do two things at once (fork, and use pipes for the child and
parent to communicate).
On windows, you can use OpenProcess for the first, and threads and
windows messages for the second, and it works mostly ok -- it's just a
different way of doing things.
You don't *need* fork semantics to do the things that one uses fork for
on unix. It's when you're trying to design something which works on
both systems that you end up whining about fork being missing on
windows.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: 15 Nov 2002 19:49:07 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Sort multidimensional hash?
Message-Id: <u9smy2zk98.fsf@wcl-l.bham.ac.uk>
"Jürgen Exner" <jurgenex@hotmail.com> writes:
> When the abstract data structure is a list (i.e. it has an order), then
> arrays are the right choice.
> If the abstract data structure is a mapping and the domain are numbers and
> are more or less continuous, then arrays are the right thing.
>
> If the abstract data structure is a set (i.e. it has no order and elements
> cannot appear twice) then the keys of a hash are the right choice (you can
> ignore the values).
> If the abstract data structure is a mapping and the domain are arbitrary
> scalars (opposite to continious numbers) then a hash is the right choise.
>
> So first of all think about what features you need for your data structure
> and then choose the proper data type. Features to consider are
> - is the order of the elements significant?
> - can values appear more than once?
> - what is the domain of my mapping, numbers or arbitrary scalars?
> Based on the answers pick your choice.
You forgot to mention that if the abstract data structure is a bag
(i.e. it has no order and elements can appear any number of times)
then a hash is the right choice with the values being the number of
times an element occurs.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 15 Nov 2002 21:03:30 GMT
From: ctcgag@hotmail.com
Subject: Re: Sort multidimensional hash?
Message-Id: <20021115160329.977$rI@newsreader.com>
"Jürgen Exner" <jurgenex@hotmail.com> wrote:
> T Stephens wrote:
> > Is there an online resource that explains the concepts of when it's
> > best to use hashes and when it's best to use arrays?
>
> Actually, it's quite simple:
> When the abstract data structure is a list (i.e. it has an order), then
> arrays are the right choice.
> If the abstract data structure is a mapping and the domain are numbers
> and are more or less continuous, then arrays are the right thing.
I'd say if the domain is non-negative integers and is mostly dense.
To me, continuous numbers imply high precision floating points, for which
hashes are better than arrays, but you're are mostly screwed either way.
> If the abstract data structure is a set (i.e. it has no order and
> elements cannot appear twice) then the keys of a hash are the right
> choice (you can ignore the values).
> If the abstract data structure is a mapping and the domain are arbitrary
> scalars (opposite to continious numbers) then a hash is the right choise.
>
> So first of all think about what features you need for your data
> structure and then choose the proper data type. Features to consider are
> - is the order of the elements significant?
I would clarify this (because I've seen people make this error) to ask,
is the order of the elements within the data structure significant
throughout the life of the data structure, i.e. do you regular access
elements by their positions, rather than their values?
If the order is only significant at one or a few instances, such as
printing the contents near the end of the life-time, and this ordering is
by something external to the data strucutre (e.g. lexigraphical order) it's
usually better to use a hash and then sort the keys, than to use an array
throughout to keep it sorted.
> - can values appear more than once?
I don't think this question is ever relevant to array vs. hash, at least
not as such. If order is not important, but counting redundancy is, then
just keep a count in the hash's value slots.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service
------------------------------
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 4126
***************************************