[13442] in Perl-Users-Digest
Perl-Users Digest, Issue: 852 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 20 03:07:23 1999
Date: Mon, 20 Sep 1999 00:05:12 -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: <937811111-v9-i852@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 20 Sep 1999 Volume: 9 Number: 852
Today's topics:
Re: #exec cgi <The__Patrician@hotmail.com>
Re: Be careful about using constants <johnlin@chttl.com.tw>
Re: builtin.pm (John G Dobnick)
Re: builtin.pm <elaine@chaos.wustl.edu>
Re: CONTEST: Range Searching (Joe Smith)
Re: CONTEST: Range Searching <ltl@rgsun40.viasystems.com>
Re: CONTEST: Range Searching (Don Blaheta)
Re: correct references to module functions when using s (elephant)
Re: CRAP Software (David H. Adler)
empty log file in NT without unloacking the file (Manny)
Re: empty log file in NT without unloacking the file <ehpoole@ingress.com>
Re: Help! (writing cgi/pearl/sendmail program) <meridamx@enol.com>
Re: How to create files from CGI script? <dwoods@ucalgary.ca>
Newbie questions on list assignment <lishans@evitech.fi>
Re: Passing variables around in multi-screen cgi script <dove@synopsys.com>
Re: Perl Challenge (elephant)
Re: PL extension (Alan Curry)
Re: Reading required files on a different server. (Abigail)
Regulat Expressions and Tabulator Problems <m.scheferhoff@gmx.de>
Re: Trouble with perl5.004_04 on RH Linux (David H. Adler)
Re: Using a period as a delimiter in the split() functi <johnlin@chttl.com.tw>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 20 Sep 1999 07:42:32 +0200
From: "Lord Havelock Vetinari, the patrician" <The__Patrician@hotmail.com>
Subject: Re: #exec cgi
Message-Id: <37E5C948.41416445@hotmail.com>
In addition you could also use the SSI <--#include
virtual="/script.cgi?query"-->
However, you should then write the path of the CGI from the server root, as
seen from the web browser, into the SSI, instead of just the script name...
An example:
<!--#include virtual="/errors/logerrors.cgi?Error=403"-->
CCC_Ltd wrote:
> > I'm trying to include a cgi program from an shtml page. My problem is, I
> > need to send a query string too. But
> > <!--#exec cgi="script.cgi?query"-->
> > isn't working, I get an "[an error occured while processing this
> directive]"
> > error.
> > If I try
> > <!--#exec cmd="script.cgi?query"-->
> > The directive is replaced with nothing at all.
> >
> > Are there any way I can achieve what I'm trying to?
> >
> > Thanks,
> > Magnus Hult
> > hult.holmstrom@swipnet.se
> >
> >
>
> To use a query string on the ssi you have to include the
> query string in the URL when you call the .shtml file.
>
> example: http://mydomain/myshtml.shtml?querystring
>
> Also... get rid of the ?query in the ssi statement.
>
> one other note... it should be <!--#exec cgi="script.cgi"-->
> not <!--#exec cmd....
------------------------------
Date: Mon, 20 Sep 1999 11:01:21 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: Be careful about using constants
Message-Id: <7s4itc$fpj@netnews.hinet.net>
Larry Rosler wrote
> John Lin says...
>
>> use strict;
>> use Fcntl ':flock';
>>
>> print LOCK_EX,"\n"; # 2
>> print LOCK_NB,"\n"; # 4
>> print LOCK_EX+LOCK_NB,"\n"; # 2, and missing "\n"
>> print (LOCK_EX+LOCK_NB),"\n"; # 2, and missing "\n"
>> print LOCK_EX|LOCK_NB,"\n"; # 6
>> print (LOCK_EX)+(LOCK_NB),"\n"; # 6
>>
>> If you are not careful enough you can easily make an invisible bug
>> because -w won't warn you.
>
>print (...) interpreted as function at e:/test/try.txt line 8.
>print (...) interpreted as function at e:/test/try.txt line 10.
>Useless use of a constant in void context at e:/test/try.txt line 8.
>Useless use of addition in void context at e:/test/try.txt line 10.
>Useless use of a constant in void context at e:/test/try.txt line 10.
>2
>4
>226
>2
Sorry, the no-warning version was
use strict;
use Fcntl ':flock';
print 'LOCK_EX=',LOCK_EX,"\n";
print 'LOCK_NB=',LOCK_NB,"\n";
print 'LOCK_EX+LOCK_NB=',LOCK_EX+LOCK_NB,"\n";
print '(LOCK_EX+LOCK_NB)=',(LOCK_EX+LOCK_NB),"\n";
print 'LOCK_EX|LOCK_NB=',LOCK_EX|LOCK_NB,"\n";
print '(LOCK_EX)+(LOCK_NB)=',(LOCK_EX)+(LOCK_NB),"\n";
Just before I posted it, I eliminated something I think 'not so important'
without re-testing it. The -w DOES NOT warn about the above version.
Anyway, my points are: (1) how come? (2) suggestion
(1) How come? It's hard for me to understand why
print LOCK_EX+LOCK_NB,"\n";
No warning.
print (LOCK_EX+LOCK_NB),"\n";
Warning: print (...) interpreted as function
Warning: Useless use of a constant in void context
and the result is wrong (2 and no "\n")
print (LOCK_EX)+(LOCK_NB),"\n";
Warning: print (...) interpreted as function
Warning: Useless use of addition in void context
Warning: Useless use of a constant in void context
but the result is correct
(2) Suggestion: please compare version I and version II below
Version I (documented in `perldoc constant`)
use constant PI => 4 * atan2 1, 1;
print "The value of PI is @{[ PI ]}.\n";
use constant USERINFO => getpwuid($<);
$homedir = USERINFO[7]; # WRONG
$homedir = (USERINFO)[7]; # Right
Version II (my suggestion)
use constant '$PI' => 4 * atan2 1, 1;
print "The value of PI is $PI.\n";
use constant '@USERINFO' => getpwuid($<);
$homedir = $USERINFO[7];
Constants with prefixes seem more natural than bareword
and produce less trouble for both compiler and programmers.
What do you think about it?
Thank you for your advises.
John Lin
------------------------------
Date: 20 Sep 1999 03:24:48 GMT
From: jgd@alpha3.csd.uwm.edu (John G Dobnick)
Subject: Re: builtin.pm
Message-Id: <7s49e0$5u8$1@uwm.edu>
From article <37E55E64.E227D2EA@chaos.wustl.edu>, by Elaine -HFB- Ashton <elaine@chaos.wustl.edu>:
> John G Dobnick wrote:
>> Perhaps CPAN needs some sort of "link" facility, so that an old
>> obsoleted entry can contain a "pointer" to it's replacement"?
>> Perhaps something like
>>
>> This has been replaced.
>> Please see List::Util and Scalar::Util.
>
> I mailed the author and requested he do something such as this. I may
> forward this idea on as well as it's something that I've thought about
> for a while. Perhaps even a list of modules and what they have been
> obsoleted by and when.
A cross reference list would be _nice_ but not absolutely _required_
to my way of thinking. (That strikes me as a _lot_ of bookkeeping.)
Given that the whole CPAN setup is done with voluntary labor, I'm
*not* about to ask others to work harder for something that is free.
(Something about examining gift horses comes to mind. That, and the
very act of "demanding" such work of others is rude and
inconsiderate.)
As a minimal _suggestion_ (and it's only a suggestion) I think that a
"one liner" in an obsoleted module escription, pointing to it's
replacement, would be helpful. Maybe somthing like "REPLACE_BY <new
module name>".
I'll admit that this is a "top of the head" suggestion, and that
someone who is more familiar with the internals of CPAN may well have
a much better way to handle the matter of "replaced" or "renamed"
modules.
My $0.025 worth.
--
John G Dobnick "Knowing how things work is the basis
Information & Media Technologies for appreciation, and is thus a
University of Wisconsin - Milwaukee source of civilized delight."
jgd@uwm.edu ATTnet: (414) 229-5727 -- William Safire
------------------------------
Date: Mon, 20 Sep 1999 00:42:32 -0400
From: Elaine -HFB- Ashton <elaine@chaos.wustl.edu>
Subject: Re: builtin.pm
Message-Id: <37E5BAB4.1CF2C068@chaos.wustl.edu>
John G Dobnick wrote:
> Given that the whole CPAN setup is done with voluntary labor, I'm
> *not* about to ask others to work harder for something that is free.
> (Something about examining gift horses comes to mind. That, and the
> very act of "demanding" such work of others is rude and
> inconsiderate.)
One doesn't demand and generally expect compliance. No, this fits
perfectly into something I'm working on already and _I_ would like to do
it since I can't keep track of all the bloody things myself. I do,
however, like to pass ideas by others to see if it would be a welcome
addition. :)
> I'll admit that this is a "top of the head" suggestion, and that
> someone who is more familiar with the internals of CPAN may well have
> a much better way to handle the matter of "replaced" or "renamed"
> modules.
I don't really like renamed unless that is, in fact, what has
transpired. Replaced is good, but doesn't carry the authority of
obsolete which conveys the message of 'do not use this module' a bit better.
> My $0.025 worth.
I still need another dollah for a cuppa kawfee. :)
e.
------------------------------
Date: 20 Sep 1999 01:11:24 GMT
From: inwap@best.com (Joe Smith)
Subject: Re: CONTEST: Range Searching
Message-Id: <37e589bc$0$221@nntp1.ba.best.com>
In article <ant190846b49Rr9i@waveney.demon.co.uk>,
Richard Proctor <Richard@waveney.demon.co.uk> wrote:
>getopts('mNB:A:C:') and $pat = shift and @ARGV or usage;
> $_ = "$.\t$_" if $opt_N;
Your solution fails on this test:
zcat http_access_log.gz | ./perlpat -N -C 2 404
1) Since no file names are specified on the command line, it is supposed
to read STDIN and not print a usage message.
2) I'm looking for lines with "404 not found", not line 404 of the input.
-Joe
--
INWAP.COM is Joe Smith, Sally Smith and our cat Murdock.
(The O'Hallorans and their cats moved to http://www.tyedye.org/ Nov-98.)
See http://www.inwap.com/ for PDP-10, "ReBoot", "Shadow Raiders"/"War Planets"
------------------------------
Date: 20 Sep 1999 03:20:31 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: CONTEST: Range Searching
Message-Id: <7s495v$j7m$1@rguxd.viasystems.com>
Hmm. This is the 3rd time I've played with myself in the same
thread. Maybe I need to work on socialization. ;->
I've pushed the all-regexp solution as far as I care to take it.
There is a flaw when a line containing the end of one matching string
also contains the beginning of another matching string.
I might be able to use additional negative lookahead assertions to
prevent chewing up the end of a line that is needed to match the next
pattern, or maybe even chaining multiple m//g, but I think the
effort has crossed the threshold where what I learn from it can
exceed the cost. Ouch. I wish I hadn't had that last thought
about chaining multiple m//g; I'm starting to get another idea..
I learned quite a bit from the attempt so far though.
Invoke as follows to see advantages and flaws:
perl -w patba.pl -DC2 MATCH
perl -w patba.pl -DC2 'MATCH and'
#!/usr/lib/lprgs/perl -w
use strict;
# Author: Lee Lindley
# Print a pattern and up to N lines of text before the pattern, and
# up to N lines after the pattern. pattern can match across a line
# boundary at the cost of missing matching strings that begin on the
# same line as the end of a previous match.
my (%opts, $USAGE);
my $pre_pattern_markup = '*'; # Could be <b> ... </b>
my $post_pattern_markup = '*';
my $after_matched_lines = "--\n";
my $pattern = parse_args();
#my $full_pattern = qr{
# ((?:.*\n){0,$opts{B}}?) # Match up to -B arbitrary lines ($1)
# (?m: # ^ and $ match on newline for this part
# (^.*?) # 0 or more chars begining of this line($2)
# ((?s-x)$pattern)# Whatever they want to match ($3)
# # where . and \s match newline too
# # but space has meaning within $pattern
# (.*$) # Match to end of line containing $pattern($4)
# ) # which is where I could miss beginning of
# # another match. Oh well.
# \n # Throw in final newline of line containing
# # pattern -- m modifier dropped it.
# # Give trailing lines that don't contain pattern
# ((?m:
# (?!^.*(?s-x:$pattern).*$)
# .*\n
# ){0,$opts{A}}) # up to -A lines anyway ($5)
#}xo;
# Well, there seems to be a bug with (?-x:), so I must get rid
# of all the readability drek. Good luck reading it. Or
# just take my word that is the same as above except for the "-x" stuff.
my $full_pattern = qr{((?:.*\n){0,$opts{B}}?)(?m:(^.*?)((?s)$pattern)(.*$))\n((?m:(?!^.*(?s:$pattern).*$).*\n){0,$opts{A}})}o;
sub find_pattern_in_file {
my ($fh, $file_name) = @_;
print "\n\n$file_name\n", $after_matched_lines
if (defined $file_name);
local $/;
my $string = <$fh>; # suck it all in
while ($string =~ /$full_pattern/go) {
print $1 if defined $1; # lines before pat
print $2 if defined $2; # part of line before pat
print $pre_pattern_markup, $3, $post_pattern_markup;
print $4 if defined $4; # part of line after pat
print "\n";
print $5 if defined $5; # lines after pat
# If the next line contains the pattern, then
# don't print the string showing end of a match set
print $after_matched_lines
unless $string =~ /\G(?=.*(?s:$pattern).*$)/mgco;
}
}
# The rest of this just handles the argument processing and
# file manipulation.
if (@ARGV == 0) {
if (exists $opts{D}) {
# Special test case
find_pattern_in_file(\*DATA, "__DATA__");
} else {
# No file name provided as an argument
find_pattern_in_file(\*STDIN);
}
} else {
foreach my $file_name (@ARGV) {
# Rather than simply using magic <ARGV> processing,
# I want to print the file name.
local *FH;
open(FH, $file_name)
or die "Failed to open $file_name: $!\n\t$USAGE";
find_pattern_in_file(\*FH, $file_name);
}
}
exit 0;
sub parse_args {
# I write strings this way because I used to write them this
# way in C (well with \n\ at the ends of the lines)
# and I just can't seem to kick the habit. :-)
$USAGE = "patfore [-B T] [-A X] [-C N] [-S] [-D] pattern [files ...]
\twhere T is number of lines before pattern to display and
\twhere X is number of lines after pattern to display and
\twhere N is number of lines both before and after pattern to display
\t-S indicates a strict pattern that should not be white space pampered
\tand -D says use the testing data at the bottom of the source";
use Getopt::Std;
die $USAGE unless getopts('DSA:B:C:', \%opts);
$opts{B} = 0 unless exists $opts{B}; # Number of lines before pat to print
$opts{A} = 0 unless exists $opts{A}; # Number of lines after pat to print
$opts{B} = $opts{A} = $opts{C} if (exists $opts{C}); # Overrides both A and B
# There must be at leat one pattern arg and at least A or B must be set
# If they want to give me a negative number or a float or
# something else that isn't a number, then let them burn for now.
die $USAGE unless (@ARGV >= 1 && ($opts{A} > 0 || $opts{B} > 0));
my $pattern = shift @ARGV;
# Should I assume that when the user gives a space char that they
# really mean \s and that it includes newline? Assume so unless
# they are sophisticated enough to tell me to leave their sacred pattern
# alone. Otherwise, I'm going to expect unsophisticated users who
# provide the string "black ice" and expect it to match when one line
# ends with "black" and the next line starts with "ice". Therefore,
# I mangle the user supplied pattern by default.
$pattern =~ s/ +/\\s+/g unless exists $opts{S};
return $pattern;
}
__END__
This is line 1 MATCH
and line 2
and line 3
and yet a line 4
and a line 5
and 6 don't you know MATCH
and a line 7 MATCH MATCH
and 8 was the last. MATCH
but now there are 9
and yet still more is 10
insert some more here
because I needed more room
to match before and after
and too see if it really works. MATCH
--
// Lee.Lindley /// Programmer shortage? What programmer shortage?
// @bigfoot.com /// Only *cheap* programmers are in short supply.
//////////////////// 50 cent beers are in short supply too.
------------------------------
Date: 20 Sep 1999 02:23:56 GMT
From: dpb@cs.brown.edu (Don Blaheta)
Subject: Re: CONTEST: Range Searching
Message-Id: <7s45rs$hku@cocoa.brown.edu>
Quoth Uri Guttman:
> >>>>> "DB" == Don Blaheta <dpb@cs.brown.edu> writes:
> DB> } continue {
> DB> @forelines = (), $aftleft = 0 if eof;
> DB> }
>
> what is the purpose of the continue block? you never do anything to
> execute it like using next. you could just put that code in the loop
> body.
*smacks forehead* That's what I get from cribbing too directly from the
examples in the docs. ;)
--
-=-Don Blaheta-=-=-dpb@cs.brown.edu-=-=-<http://www.cs.brown.edu/~dpb/>-=-
I haven't lost my mind -- it's backed up on tape somewhere.
------------------------------
Date: Mon, 20 Sep 1999 15:36:01 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: correct references to module functions when using strict?
Message-Id: <MPG.125056ab91643529989ce0@news-server>
cLive hoLLoway writes ..
>I'm madly trying to grow up as a programmer, and am a little lost on
>'use strict' and wondered if some kind soul could point me in the right
>direction...
hard to resist such a worthwhile pursuit
>when I added 'use strict' to the script, I got the following message
>(after debugging everything else ;-):
>
>Bare word "param" not allowed while "strict subs" in use.
>
>I have changed the listing of 'param' to 'CGI::param' in the script, but
>can't test it yet coz I've got a couple of other dependent scripts to
>change first.
>
>All I really want to know is:
>
>Is this all I have to do? ie, Find out the package name of anything
>required prepend it with :: to the affected function?
most modules will allow you to specify which functions you'd like
exported into your namespace (exported from the module's perspective -
imported from the perspective of your code)
so .. for CGI for example you can either do
use strict;
use CGI; # just using CGI
my $x = CGI::param( 'x' );
or you can do this
use strict;
use CGI qw( param ); # tell CGI: export param() into my namespace
my $x = param( 'x' ); # use param() as if it were mine
these different types of usage are covered in the documentation that
comes with the CGI module .. you can see it with the following command
perldoc CGI
>One script contains common sub-routines (package common) used by a group
>of scripts. Is it better programming to declare variables created in
>this common script within the common namespace (ie name them
>$common::etc), or to declare them in the calling program and then to
>create them in the common sub (ie name the $::etc)?
matter of opinion and situation .. the first approach would be my choice
- I can't be bothered explaining why .. and it certain situations I
might choose to do it the other way
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: 20 Sep 1999 05:16:54 GMT
From: dha@panix7.panix.com (David H. Adler)
Subject: Re: CRAP Software
Message-Id: <slrn7ubgq6.cuk.dha@panix7.panix.com>
In article <EagKUAAoSS53EwMh@elmbronze.demon.co.uk>, Dave Eastabrook wrote:
>on Sun, 19 Sep 1999 Neil <neil@pacifier.com> wrote
>>
>>> JS> 'A young woman walks into a bar and asks the barman for a double
>>> JS> entendre so he gave her one'
>>
>>> one what?
>>
>>I think the idea is that she asked for a *double* but only got *one*.
>
>Man walks into a bar. "Ouch". It was an iron bar.
Two guys walk into a bar. You'd think the second one would have seen
it.
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Okay, that's it. 30 days no computer use penalty for being stupid
- Greg at http://www.userfriendly.org
------------------------------
Date: 20 Sep 1999 03:15:42 GMT
From: mpatel@news.fhlb.com (Manny)
Subject: empty log file in NT without unloacking the file
Message-Id: <7s48su$b55$1@tilde.csc.ti.com>
I am writing a perlscript to clear locked files without unlocking it.
What is trick to empty (/dev/null) a log file while the file is locked? Assuming the file is bing appended every second.
Thanks!
Manny
------------------------------
Date: Sun, 19 Sep 1999 23:58:43 -0400
From: "Ethan H. Poole" <ehpoole@ingress.com>
Subject: Re: empty log file in NT without unloacking the file
Message-Id: <37E5B0F3.6A1A8A66@ingress.com>
Manny wrote:
>
> I am writing a perlscript to clear locked files without unlocking it.
>
> What is trick to empty (/dev/null) a log file while the file is locked? Assuming the file is bing appended every second.
In short (and if you think about it) you cannot clear a file that is
currently locked by another process until the lock is released. So the
short answer is you cannot do what you want while it is locked.
However, you *may* (emphasis on 'may') be able to rename the file so that
subsequent locks and appends create then write/lock a new file. However,
if you are referring to a continually running application (e.g. a server
daemon/app) that maintains a lock for as long as it is active you may be
able to rename the file, but it will likely not release the lock until you
restart the daemon/app and it will likely continue to write to the renamed
file instead of the new file (if the filehandle is open when you move the
file, it remains connected to that file). If that is your situation, then
the answer is that you stop the daemon/app or look for an API function
that allows you clear the log (assuming there is one).
This really is not a Perl question though, it is an OS-specific issue.
--
Ethan H. Poole **** BUSINESS ****
ehpoole@ingress.com ==Interact2Day, Inc.==
(personal) http://www.interact2day.com/
------------------------------
Date: Sun, 19 Sep 1999 20:36:41 -0600
From: "Chuck Burgess" <meridamx@enol.com>
Subject: Re: Help! (writing cgi/pearl/sendmail program)
Message-Id: <7s4705$jnn$1@news.inquo.net>
>I just want to send email with my domain name for return address.
>I have found this problem with most of the low cost domain hosts.
>Any OTHER suggestions?
Yeah. Get a more expensive ISP. Mine costs 16.95 a month, they do not check
domain names in addresses, and they will even load Perl Modules as needed.
http://www.enol.com
raynew@my-deja.com wrote in message <7s22ju$8q9$1@nnrp1.deja.com>...
>No spam.
>I have three domains that are not hosted locally.
>Cheap, but do not support smtp.
>They advise me to use my local dialup isp.
>My local dialup isp will not accept any email
>(even via dialup modem) that does not have THEIR
>domain name in return address.
>
>I just want to send email with my domain name for return address.
>I have found this problem with most of the low cost domain hosts.
>
>I would guess this is a common problem.
>Currently I keep looking for any isp in the world
>that does not check return address.
>They are drying up bit by bit because of spam.
>
>Any OTHER suggestions?
>Ray
>
>
>
>In article <37E3C254.7B872310@prodigy.net>,
> Ken Robbins <puyrebelNOSPAMTHANKS@prodigy.net> wrote:
>> raynew@my-deja.com wrote:
>> > [...]
>> > BUT
>> >
>> > Reply-To:
>> >
>> > and
>> >
>> > From:
>> >
>> > change to myname@mydomain.com
>> > [...]
>>
>> I don't know about anyone else, but doesn't that sound like he is
>going
>> to send spam?
>>
>> --
>> Ken Robbins
>> Remove NOSPAMTHANKS to reply by e-mail.
>>
>
>
>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.
------------------------------
Date: Sun, 19 Sep 1999 23:24:54 -0700
From: Dan Woods <dwoods@ucalgary.ca>
To: "David P. Schwartz" <davids@desertigloo.com>
Subject: Re: How to create files from CGI script?
Message-Id: <7s4gpv$7n8@ds2.acs.ucalgary.ca>
David,
> umask 022
> /cgi-bin 711
> /cgi-bin/code_dir1 711
> /cgi-bin/code_dir1/mydatadir 666
Since your cgi-bin is 711, I think web user 'nobody' still can't
write to a sub-directory. Why not change your structure to...
/cgi-bin 711
/cgi-bin/code_dir1 711
/mydatadir 666
and your perl can write to "../../mydatadir" or "~/mydatadir".
If you're on AIX, set ACL permissions to allow access to 'nobody'.
If not, you're on a system for which you are opening up mydatadir/
access to anyone else on your system who can 'cd' into there
and possibly overwrite the data.
Thanks...Dan.
http://www.4loops.com
------------------------------
Date: Mon, 20 Sep 1999 09:31:50 +0200
From: Lishan Song <lishans@evitech.fi>
Subject: Newbie questions on list assignment
Message-Id: <Pine.HPX.4.10.9909200926030.4391-100000@tamagoch.evitech.fi>
@mylist = qw(item1, item2, item3);
@tmplist = @mylist; #???
I have following questions on list assignment:
- Is the assignment legal?
- If it is legal, are the values copied from @mylist or
@tmplist is a reference to @mylist?
Thanks.
------------------------------
Date: Sun, 19 Sep 1999 22:35:28 -0700
From: David Amann <dove@synopsys.com>
Subject: Re: Passing variables around in multi-screen cgi script
Message-Id: <37E5C7A0.F05FF43B@synopsys.com>
Hi Jed,
Jed Parsons wrote:
> I'm trying to write a multi-screen cgi script, and am having trouble
> figuring out how to pass arrays and hashes around. How can I make them
> accessible to other
> parts?
>
The short answer is that you're going to have to export your array or hash
table out to some sort of string, store that either in a hidden variable in
the HTML, in a cookie, or in a custom URL (client side persistence) or write
it to a file or backend database (server side persistence), and then read it
back into the array.
Since HTTP is a stateless protocol, you cannot store variables in memory
between two pages. Here's a step-by-step way on how it works.
1. Browser accesses first part of cgi-script.
2. CGI determines to run the first part.
3. CGI sends back output HTML to browser (including some token to get
to the the second part of the CGI).
4. CGI quits running. All memory is cleaned up.
5. Browser accesses second part of cgi.
6. A new instance of the CGI starts up from scratch.
You can store hash tables to disk using the CPAN module Storable's store and
retrieve function, or you can try using the MLDBM module. (Check out
Recipes 11.14 and 11.15 in the Perl Cookbook for these two methods.)
Hope this helps,
-=dav
>
> Jed
>
> --
> Jed Parsons mailto:jed@socrates.berkeley.edu
> http://socrates.berkeley.edu/~jed/
>
> "Okay! You know, super ideas do not grow on trees!" --- Supergrover
------------------------------
Date: Mon, 20 Sep 1999 15:21:19 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: Perl Challenge
Message-Id: <MPG.1250533b5dd2cf1e989cdf@news-server>
makau@multimania.com writes ..
>> I doubt that you have any idea about the level of perl knowledge
>> in this newsgroup .. I'm certainly no guru ..
>> but I worked out what it did AND how it did it very easily in
>> - at a guess - 15 seconds .. the knowledgable people of the group
>> would take roughly 10% longer than the time it takes them to read it
>
>Damn, seems I am far newbier than I ever thought :-)
reviewing your short but colourful posting history to c.l.p.misc it
would seem very apparent .. if you thought you were anything but a
newbie then - yes - you are far newbier than you ever thought
| blah blah deleted |
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Mon, 20 Sep 1999 06:38:22 GMT
From: pacman@defiant.cqc.com (Alan Curry)
Subject: Re: PL extension
Message-Id: <yDkF3.21651$N77.1721561@typ11.nn.bcandid.com>
In article <37E563AA.9E6A2B96@vpservices.com>,
Jeff Zucker <jeff@vpservices.com> wrote:
>Michel Jacob wrote:
>>
>> I know almost nothing on CGI and Perl programming. I want to use a
>> little CGI program that is freely distribute on the WEB to put a
>> password access restriction on my WEB site.
>
>Whoa, stop right there. A CGI is not a good way to put a password
>restriction on a site. Use the web server's built in authentication
>methods instead.
Don't be too sure about that. A CGI script owned by you (and therefore
executed with your uid[*]) can provide access to a file that is not globally
readable. A typical httpd acting alone doing authenticated HTTP can't do
that.
So HTTP authentication for access to private files can easily be less secure
than a CGI-based method. If the httpd can read your file, so can the other
$BIGNUM users on the machine.
Since this used to be the perl group, I'll post some perl:
#!/usr/bin/perl -w
use strict;
use CGI ':standard';
my $password='secret!';
my $file='/home/foo/secretfile';
my $type='text/plain';
if(param('password') ne $password) {
print <<EOP;
Content-Type: text/html
<title>Authentication failure</title>
<h1>Incorrect password</h1>
<p>Bzzt!
EOP
exit(0);
}
print "Content-Type: $type\n\n";
exec 'cat', '--', $file;
Other options include:
1. pick an unused port, run your own httpd on it, and let it do authenticated
HTTP. No more world-readable problem.
2. encrypt the file and let it be world-readable, then give the decryption
key out as a "password". This even gives some protection from an unethical
administrator.
[*] If your system doesn't run suexec, show your admin a "kill -9 -1" CGI,
and if he doesn't install suexec pretty quickly, give up now -- security on
that system is beyond hope.
--
Alan Curry |Declaration of | _../\. ./\.._ ____. ____.
pacman@cqc.com|bigotries (should| [ | | ] / _> / _>
--------------+save some time): | \__/ \__/ \___: \___:
Linux,vim,trn,GPL,zsh,qmail,^H | "Screw you guys, I'm going home" -- Cartman
------------------------------
Date: 20 Sep 1999 00:38:49 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Reading required files on a different server.
Message-Id: <slrn7ubi84.ae4.abigail@alexandra.delanet.com>
Glen Saunders (glen1@ibm.net) wrote on MMCCX September MCMXCIII in
<URL:news:37e572c8@news1.prserv.net>:
@@ In all the perl documentation I've read, it is assumed that the perl
@@ program and all it's required files are on the same server. Is it
@@ possible to have a perl program read from a file on a server different
@@ from the one the program itself is on? (This stems from having to use
@@ a secure server for one part of the process). If so, what is the
@@ protocol (UNIX) for pointing perl to the absolute path? Thank you.
Sure.
Just make a dummy module that use LWP and eval in its import() routine.
Of course, I would just copy those files, but that's just me.
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Mon, 20 Sep 1999 08:44:18 +0200
From: Michael Scheferhoff <m.scheferhoff@gmx.de>
Subject: Regulat Expressions and Tabulator Problems
Message-Id: <37E5D7C2.A9CEB606@gmx.de>
Hi,
I write a text from a file line per line in an array. In every line
there are 14 "values" seperated by a tabulator. I need to read these
values and put them into variables. I tried to make a tabualtor machting
with:
if ($tmp[$x]=~ m/\t/)
but no tab was found.
Can someone help me with my problem?
Thanks,
Michael
------------------------------
Date: 20 Sep 1999 06:18:36 GMT
From: dha@panix7.panix.com (David H. Adler)
Subject: Re: Trouble with perl5.004_04 on RH Linux
Message-Id: <slrn7ubkds.cuk.dha@panix7.panix.com>
In article <7rke65$5ek$1@hendrix.postino.com>, Danny Aldham wrote:
>X-Newsreader: TIN [version 1.2 PL2]
>
>I have a site running perl5.004_04 on x86 RedHat Linux. I am seeing
>resource type problems, something that could be a memory leak. I recall
>seeing that Redhat had distributed a poor version of perl at one time,
>and am wondering if this is it.
I don't remember if that's the one, but it is certainly not the
current Perl. If memory serves, the current non-development release
is 5.005_03. You should be able to find the current release (even if
I've got the number wrong :-) at www.perl.com.
HTH
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"Last year in Oregon, Summer fell on a *tuesday*. That was it. One
day. Big shiny thing in the sky. Some people thought it was a UFO."
- Randal Schwartz in comp.lang.perl.misc
------------------------------
Date: Mon, 20 Sep 1999 13:28:10 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: Using a period as a delimiter in the split() function
Message-Id: <7s4itf$fpj@netnews.hinet.net>
I have a question.
Can Perl internally distinguish regex from strings?
split /PATTERN/ => regex semantics
split $string => string semantics
split /$string/ => regex semantics
If the answer is YES, I think split should
split according to the user's need.
If he wants to split on a string then split on that string.
If he wants to split on a regex, he will write a regex here.
This considerate design can prevent users from surprising bugs.
(just like the grep case I previously posted)
Elsif the answer is NO, that is,
Perl doesn't have special type for regex,
even if you write
split /$string/
it just pass the string to split,
then my questions become:
How can it deal with
split /$string/i
and in
$reg=qr/$string/i;
what is added to $reg? Is $reg still a string?
(That's why I guess regex is different from string)
My opinion is: distinguishing regex semantics from
string semantics in split, grep, ... and so on
will create some useful variety of usage and can
hopefully reduce some frequent programmer errors.
What do you think about it?
John Lin
------------------------------
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 852
*************************************