[22407] in Perl-Users-Digest
Perl-Users Digest, Issue: 4628 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 26 14:10:38 2003
Date: Wed, 26 Feb 2003 11:10:09 -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 Wed, 26 Feb 2003 Volume: 10 Number: 4628
Today's topics:
Re: perl download script - how to minimize server memor nobull@mail.com
Re: perl download script - how to minimize server memor nobull@mail.com
Question (Emil)
Re: Question (Malcolm Dew-Jones)
Reading Multiple Input Files with <> (Jodyman)
Re: Reading Multiple Input Files with <> <ubl@schaffhausen.de>
Re: Reading Multiple Input Files with <> <REMOVEsdnCAPS@comcast.net>
regex spanning multiple lines (Rich Riopel)
Re: regex spanning multiple lines (Tad McClellan)
regexp - Alternative to $& <asu1@c-o-r-n-e-l-l.edu>
regexp producing uninitialized var errors. <morgan_don't_spam_me_you_bastards@classroominc.org>
Re: regexp producing uninitialized var errors. (Tad McClellan)
Re: setting smalldatetime column to NULL (MIchael Peppler)
Simple question about Perl Regular Expressions <hermeto@hotmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 26 Feb 2003 09:58:08 -0800
From: nobull@mail.com
Subject: Re: perl download script - how to minimize server memory usage?
Message-Id: <4dafc536.0302260958.1a4cd854@posting.google.com>
lobbister.2.wuni@spamgourmet.com (Adrian Grigore) wrote in message news:<b4ed8910.0302260203.7ae2b34d@posting.google.com>...
> Malte Ubl <ubl@schaffhausen.de> wrote in message news:<b35a15$gam$1@news.dtag.de>...
> > I guess, you could write to a temp file and then redirect the user to
> > that one.
>
> I also considered this, but it is not an option since the same script
> will also be used for delivering full versions of my games, meaning
> that I do not want to disclose the location
_Internal_ web server redirects do not usually disclose the location
of the temporary file. Just make sure your web server doesn't generate
Content-location for internal redirects. Most don't.
Anyhow even if you did accidently disclose the temporary location of a
registered copy of the game you'd only be disclosing that information
to the registrant. If the registrant wanted to give away illicit
copies of his registered copy he could more simply just do so directly
rather than publishing a URL that would only remain valid for a few
hours.
None of this, of course, has anyhing to do with Perl. There is a
current thread about this in CIWAC where it is more on-topic. In fact
there's probably always a thread about this in CIWAC.
Please see that thread for my comment about restartable downloads.
------------------------------
Date: 26 Feb 2003 10:03:39 -0800
From: nobull@mail.com
Subject: Re: perl download script - how to minimize server memory usage?
Message-Id: <4dafc536.0302261003.2f8e5538@posting.google.com>
lobbister.2.wuni@spamgourmet.com (Adrian Grigore) wrote in message news:<b4ed8910.0302260207.27b6533d@posting.google.com>...
> Brian McCauley <nobull@mail.com> wrote in message news:<u9heaxerlb.fsf@wcl-l.bham.ac.uk>...
> > lobbister.2.wuni@spamgourmet.com (Adrian Grigore) writes:> This is a question about your web server software, it has nothing to
> > so with Perl.
>
> It has, because I was thinking maybe mod_perl could help solve this
> problem.
I think you have misunderstood the problem.
> > > Is there some way to solve this problem without reducing the maximum
> > > download speed for those downloaders who have the bandwidth?
> >
> > The normal approach to CGIs that generate huge output is to create a
> > temporary file and generate an internal redirect.
> >
> > Furthermore, if you arrange that the temporary file is reused rather
> > than regenerated in the event of an identical request this will allow
> > the download to be restartable.
>
> Not possible in this for security reasons, please see my reply to the
> previous posting above. What I absolutely want to *evit* is exactly
> this approach, as I will be using the same script for delvering full
> versions of my games...
What security reasons?
What breach of your security is it you imagine is possible if you
follow my advice and suppose is not possible with your existing
approach?
------------------------------
Date: 26 Feb 2003 08:15:09 -0800
From: ejanev@yahoo.com (Emil)
Subject: Question
Message-Id: <b368b696.0302260815.5568e848@posting.google.com>
I am relatively new to perl.
Two questions:
I am trying to automatize some file management on Win98 ( copies,
moves .. ) by a perl program (and by the way to do some exercise with
Perl). Perl would be easier to me if I need to do the same on the UNIX
machine, but on Win98 some problems appeared:
Is there similar command ( option ) under Win98 ( dos ) like "grep -l"
uder UNIX. I tried with "find" but didn't find similar option.
Depending of the existence of some string in a Word file ( ".doc" ) it
has to be copied or moved to a specific directory.
Second problem is with executing "copy" and "move" command with "
`copy ... ...`
from the program. The paths that are requested are shortenned ones,
like they appear in the command window ( not like in Explorer ). I can
keep two lines in some configuration file, one with the Full Name Path
and other with Shortened Path like in Command Window, and use first
one for Perl file manipulation ( opens ), and the other for ` ` (
command evaluation ).
Any help or direction is welcome. Thanks.
------------------------------
Date: 26 Feb 2003 09:45:10 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Question
Message-Id: <3e5cfd26@news.victoria.tc.ca>
Emil (ejanev@yahoo.com) wrote:
: I am relatively new to perl.
: Two questions:
: I am trying to automatize some file management on Win98 ( copies,
: moves .. ) by a perl program (and by the way to do some exercise with
: Perl). Perl would be easier to me if I need to do the same on the UNIX
: machine, but on Win98 some problems appeared:
: Is there similar command ( option ) under Win98 ( dos ) like "grep -l"
: uder UNIX. I tried with "find" but didn't find similar option.
: Depending of the existence of some string in a Word file ( ".doc" ) it
: has to be copied or moved to a specific directory.
: Second problem is with executing "copy" and "move" command with "
: `copy ... ...`
: from the program. The paths that are requested are shortenned ones,
: like they appear in the command window ( not like in Explorer ). I can
: keep two lines in some configuration file, one with the Full Name Path
: and other with Shortened Path like in Command Window, and use first
: one for Perl file manipulation ( opens ), and the other for ` ` (
: command evaluation ).
: Any help or direction is welcome. Thanks.
You could make a perl script that emulates grep pretty easily, but the
usual technique is probably to get a unix compatible grep.exe command, and
the most common way to do that is to google for `cygwin'.
Once you have the cygwin files, then the easiest install onto other
computers for single utilities is to copy just the utility you need
(grep.exe) and the cygwin.dll file into the path (that might not be the
.dll's name).
Other unix compatible greps are also available.
------------------------------
Date: 26 Feb 2003 07:02:36 -0800
From: jodyman@hotmail.com (Jodyman)
Subject: Reading Multiple Input Files with <>
Message-Id: <5b5a9657.0302260702.23c73826@posting.google.com>
How can I go through 2 files simultaneously using while?
Is there a trick to doing this?
For example:
while ($in1=<IN1>) {
while (<IN2>) {
do something with $_
do something with $in1
}
}
With the above the whole <IN2> is read and acted upon
before the next <IN1> is accessed.
Any help would be appreciated. I have a mental block here.
Jody
------------------------------
Date: Wed, 26 Feb 2003 16:07:57 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: Reading Multiple Input Files with <>
Message-Id: <b3iofa$3bq$1@news.dtag.de>
Jodyman wrote:
> How can I go through 2 files simultaneously using while?
> Is there a trick to doing this?
>
> For example:
>
> while ($in1=<IN1>) {
> while (<IN2>) {
my $line_from_second_file = <IN2>;
->malte
------------------------------
Date: Wed, 26 Feb 2003 11:24:30 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Reading Multiple Input Files with <>
Message-Id: <Xns932E7E28C9FA5sdn.comcast@216.166.71.239>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
jodyman@hotmail.com (Jodyman) wrote in news:5b5a9657.0302260702.23c73826
@posting.google.com:
> How can I go through 2 files simultaneously using while?
> Is there a trick to doing this?
>
> For example:
>
> while ($in1=<IN1>) {
> while (<IN2>) {
> do something with $_
> do something with $in1
> }
> }
>
> With the above the whole <IN2> is read and acted upon
> before the next <IN1> is accessed.
while ($in1 = <IN1>) {
$in2 = <IN2>;
last if !defined $in2;
... do stuff with $in1, $in2;
}
- --
Eric
print scalar reverse sort qw p ekca lre reh
ts uJ p, $/.r, map $_.$", qw e p h tona e;
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPlz4NWPeouIeTNHoEQJFDACeLfSA69FEfint8yFH+oircPvjamsAnjnl
HrpTkTIXM6a4jRvSeD3gvwiF
=08vf
-----END PGP SIGNATURE-----
------------------------------
Date: 26 Feb 2003 08:24:46 -0800
From: rich@richanddonna.com (Rich Riopel)
Subject: regex spanning multiple lines
Message-Id: <7ac2bf92.0302260824.5fd90521@posting.google.com>
Hi,
I need to write a regex to search the following text for all lines
with roleuid=HMR-1,ou=roles,o=bcbsnj.com. The regex should get all
from dn: to the blank line.
dn: dnqualifier=flast,ou=people,o=bcbsnj.com
roledn: roleuid=her-1, ou=roles, o=bcbsnj.com
roledn: roleuid=HMR-1,ou=roles,o=bcbsnj.com
dn: dnqualifier=flast1,ou=people,o=bcbsnj.com
roledn: roleuid=her-1, ou=roles, o=bcbsnj.com
roledn: roleuid=abc-1, ou=roles, o=bcbsnj.com
roledn: roleuid=HMR-1,ou=roles,o=bcbsnj.com
dn: dnqualifier=flast2,ou=people,o=bcbsnj.com
roledn: roleuid=her-1, ou=roles, o=bcbsnj.com
roledn: roleuid=abc-1, ou=roles, o=bcbsnj.com
roledn: roleuid=HMR-1, ou=roles, o=bcbsnj.com
This is what I have so far... I may be way off
# search on a (beginning of line, dn: and any number of chars till the
end of the line) at least 1 time follwed by the
# (beginning of a line followed by roledn: and any number of chars
till the end of the line) zero or more times followed by a
# (beginning of a line followed by roledn:
roleuid=HMR-1,ou=roles,o=bcbsnj.com and the end of the line) at least
1 time
#
# replace $3 with $relaced
$_=~ s/(^dn: .*$){1}(^roledn: .*$)*(^roledn:
roleuid=HMR-1,ou=roles,o=bcbsnj.com$){1}+/$1$2$replaced/g;
TIA
Rich
------------------------------
Date: Wed, 26 Feb 2003 11:27:56 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: regex spanning multiple lines
Message-Id: <slrnb5pu8s.5lf.tadmc@magna.augustmail.com>
Rich Riopel <rich@richanddonna.com> wrote:
> I need to write a regex to search the following text for all lines
> with roleuid=HMR-1,ou=roles,o=bcbsnj.com.
So it should replace the first two, but leave the last one alone?
> The regex should get all
> from dn: to the blank line.
Use "para mode" for that part, assuming this data is in a file.
----------------------------------
#!/usr/bin/perl
use strict;
use warnings;
my $search = quotemeta 'roleuid=HMR-1,ou=roles,o=bcbsnj.com';
my $replace = 'SOMETHING';
$/ = ''; # enable "para mode", see perlvar.pod
while ( <DATA> ) {
s/$search/$replace/;
print;
}
__DATA__
dn: dnqualifier=flast,ou=people,o=bcbsnj.com
roledn: roleuid=her-1, ou=roles, o=bcbsnj.com
roledn: roleuid=HMR-1,ou=roles,o=bcbsnj.com
dn: dnqualifier=flast1,ou=people,o=bcbsnj.com
roledn: roleuid=her-1, ou=roles, o=bcbsnj.com
roledn: roleuid=abc-1, ou=roles, o=bcbsnj.com
roledn: roleuid=HMR-1,ou=roles,o=bcbsnj.com
dn: dnqualifier=flast2,ou=people,o=bcbsnj.com
roledn: roleuid=her-1, ou=roles, o=bcbsnj.com
roledn: roleuid=abc-1, ou=roles, o=bcbsnj.com
roledn: roleuid=HMR-1, ou=roles, o=bcbsnj.com
----------------------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 26 Feb 2003 18:25:28 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: regexp - Alternative to $&
Message-Id: <Xns932E888F812DCasu1cornelledu@132.236.56.8>
Hello:
I am running my CGI script with the -T option. To untaint a parameter, I
match to a regexp, and if it matches, set the variable corresponding to the
parameter to the matched string as below:
my $location = $query->param("location") || '';
if($location =~ /^\w+(\/\w+)*/) {
$location = $&;
} else {
bail_out('Invalid location specified in request', $location)
}
Now, I have seen the performance warning in perlre regarding $&. I am
wondering if there is an alternative to using $& in this context.
Sinan.
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: Wed, 26 Feb 2003 11:54:41 -0500
From: "Morgan LaVigne" <morgan_don't_spam_me_you_bastards@classroominc.org>
Subject: regexp producing uninitialized var errors.
Message-Id: <1dydnURjYcnPbMGjXTWc3g@giganews.com>
This is probably a dumbass question but....
I have an array, it's populated, and if I do this:
$ref=0;
foreach(@lines)
{
if(m/Comment/)
{
delete $lines[$ref];
}
$ref++;
}
I get :
Use of uninitialized value in pattern match (m//) at (eval 1) line 842,
<TXT> line 851.
For every single line. (TXT is the input filehandle I used to populate the
array.)
Any thoughts?
------------------------------
Date: Wed, 26 Feb 2003 11:35:26 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: regexp producing uninitialized var errors.
Message-Id: <slrnb5pumu.5lf.tadmc@magna.augustmail.com>
Morgan LaVigne <morgan_don't_spam_me_you_bastards@classroominc.org> wrote:
> I have an array, it's populated, and if I do this:
> $ref=0;
> foreach(@lines)
> {
> if(m/Comment/)
> {
> delete $lines[$ref];
> }
> $ref++;
> }
> I get :
> Use of uninitialized value in pattern match (m//) at (eval 1) line 842,
^^^^^^^^^^^
><TXT> line 851.
There is no eval() in the code you've shown us.
Something ain't right with what you're saying.
So I dunno what the heck is going on, since the message does
not relate to the code...
> Any thoughts?
Read the "Foreach Loops" section in perlsyn.pod, and don't do things
that is says to not do. :-)
You appear to be using the wrong tool for the job anyway,
doesn't this do it with much less fuss?
@lines = grep $_ !~ m/Comment/, @lines;
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 26 Feb 2003 08:09:43 -0800
From: mpeppler@peppler.org (MIchael Peppler)
Subject: Re: setting smalldatetime column to NULL
Message-Id: <234a9cb1.0302260809.6e5b1228@posting.google.com>
JavaProgrammer@nowhere.com wrote in message news:<b3gc6p$d0f$1@news.netmar.com>...
> A co-worker is trying to get her PERL script to UPDATE a record so a (Sybase
> System 11) smalldatetime column is set to NULL, but not having any luck.
> Apparently a statement like
>
> UPDATE table
> SET smalldatetimeColumn = NULL
> WHERE ...
>
> doesn't work though it works fine in SQL Advantage. Is there any way to get
> the above statement to work in PERL?
That statement should definitely work (assuming that the WHERE clause is correct).
Things that could be wrong:
Forgetting to call $dbh->commit if AutoCommit is Off
Not calling $sth->execute properly, or not checking for errors.
Michael
------------------------------
Date: Wed, 26 Feb 2003 17:28:27 GMT
From: Hermeto Mendes <hermeto@hotmail.com>
Subject: Simple question about Perl Regular Expressions
Message-Id: <Xns932EBC3CEA247ilovespamdarpagovmil@195.34.132.22>
I do not know how to get one simple Perl Regular Expression to work:
How would one write:
firstname lastname
lastname, firstname
so both variants are recognised, but I have to write the name only once?
I tried:
'firstname lastname|lastname\, firstname'
but possibly this can be achieved in shorter writing?
Thanks for any help!
[BTW: I would need this for the score.ini-file of the Xnews-reader-
application]
------------------------------
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 4628
***************************************