[13450] in Perl-Users-Digest
Perl-Users Digest, Issue: 860 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 20 21:07:23 1999
Date: Mon, 20 Sep 1999 18:05:10 -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: <937875910-v9-i860@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 20 Sep 1999 Volume: 9 Number: 860
Today's topics:
Re: An Array of Collumns <meridamx@enol.com>
answers <casino@start.com.au>
Re: answers (Kragen Sitaker)
Re: answers <sjs@yorku.ca>
Re: CONTEST: Range Searching <ltl@rgsun40.viasystems.com>
Re: deja.com alters posts <mike@crusaders.no>
Re: File Upload (Kragen Sitaker)
Re: File Upload <bwilcox@eudoramail.com>
Re: File Upload <ff@arraycomm.com>
Re: Perl Challenge (elephant)
Re: Perl Challenge <cassell@mail.cor.epa.gov>
Perl FAQ problems (Kragen Sitaker)
Re: perl related question now! <mike@crusaders.no>
Re: perl related question now! (Kragen Sitaker)
Re: perl related question now! (Martien Verbruggen)
Re: Programmer's Editor (elephant)
Re: Query date for tommorow (elephant)
Re: range of array indexes (Martien Verbruggen)
Re: reading registry in Perl on WinNT <cassell@mail.cor.epa.gov>
Re: reading registry in Perl on WinNT (elephant)
Re: Some e-mails get sent, some don't <rootbeer@redcat.com>
Re: Some e-mails get sent, some don't <rootbeer@redcat.com>
Re: Some e-mails get sent, some don't <rootbeer@redcat.com>
Re: Some e-mails get sent, some don't (Martien Verbruggen)
Re: Sorting on a string, by value. <uri@sysarch.com>
Re: Statistics for comp.lang.perl.misc (Matthew Bafford)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 20 Sep 1999 18:52:42 -0600
From: "Chuck Burgess" <meridamx@enol.com>
Subject: Re: An Array of Collumns
Message-Id: <7s6l90$8sb$1@news.inquo.net>
[snip]
Friggin' genius. That one worked like a charm. Thanks for your help. I would
have been up for nights. Thanks to all who posted and to you Michael for the
final solution.
------------------------------
Date: Tue, 21 Sep 1999 10:45:27 +1000
From: "Andrew" <casino@start.com.au>
Subject: answers
Message-Id: <37e6d543@derwent.nt.tas.gov.au>
love the way people say...
'not a perl question'
or
'read some doco'
is this because you are so arrogant or just don't know?
------------------------------
Date: Tue, 21 Sep 1999 00:54:56 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: answers
Message-Id: <AHAF3.23310$N77.1849179@typ11.nn.bcandid.com>
In article <37e6d543@derwent.nt.tas.gov.au>,
Andrew <casino@start.com.au> wrote:
>love the way people say...
>'not a perl question'
>or
>'read some doco'
>
>is this because you are so arrogant or just don't know?
I usually say "not a perl question" because I'm arrogant *and* just
don't know. I usually say "read some doco" because I think reading
some doco will be far more helpful than even a hundred helpful
newsgroup answers -- although some things are hard to find before
reading *all* the docs, so I try to provide helpful newsgroup answers.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Mon Sep 20 1999
49 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 20 Sep 1999 20:52:09 -0500
From: Steven Smolinski <sjs@yorku.ca>
Subject: Re: answers
Message-Id: <m3wvtluj3q.fsf@hank.yorku.ca>
"Andrew" <casino@start.com.au> writes:
> love the way people say...
> 'not a perl question'
> or
> 'read some doco'
>
> is this because you are so arrogant or just don't know?
If you've read the group for a few days (see news.announce.newusers
for that great advice, btw) you'd have been able to answer your own
question: the people who generally admonish rude posters with the
above phrases also write some of the best code around and give
generously of their valuable time.
*plonk*
Steve
------------------------------
Date: 21 Sep 1999 00:29:19 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: CONTEST: Range Searching
Message-Id: <7s6jgv$8ba$1@rguxd.viasystems.com>
Perl regular expressions (and extensions) share some traits with
certain classes of mind altering substances. As you increase the
doseage, you get some conciousness expanding affects. rexen can be
lovely. As you dig deeper, it seems like you can do almost
anything. But then the dark side starts to show. You spend more and
more time exploring the possibilities. You try to do even more with
them. The cycle builds. And soon you are lost. You alternate
between furiously banging away at the keyboard to set up a new trial
of your latest vision, then staring vacantly at the screen as you try
to tweak the model in your head to dance to the rexen rules.
Beware the rexen. Just say no.
This (hopefully last, but I'm not promising) version will match
across lines. It will place markup text (currently just a '*')
before and after the matched text. It can do this even if the
beginning of the next match occurs on the same line as the end
of the previous match.
Invoke as follows to see some advantages:
perl -w patba.pl -DC2 MATCH
perl -w patba.pl -DC2 'MATCH and'
perl -w patba.pl -DC2 'MATCH.*?9'
#!/usr/lib/lprgs/perl -w
use strict;
# Author: Lee.Lindley@bigfoot.com
#use re 'debug';
# 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. Mark the matched text in the output.
my (%opts, $USAGE);
# Strings used to prettify the output
my $pre_pattern_markup = '*'; # Could be <b> ... </b>
my $post_pattern_markup = '*';
my $after_matched_lines = "--\n";
my $pattern = parse_args(); # drudgery hidden for now
# Build a pattern that will find a match and capture it along
# with the desired lines that proceed the match
my $full_pattern = qr{
( # Capture "pre" lines in $1
(?:^ # Bind to beginning of line
# cuts down on backtracking? seems to help
# The captured line cannot contain $pattern
# or actually, the start of $pattern since
(?!.*(?s:$pattern)) # the ?s: lets $pattern cross line boundary
.*\n # Actual stuff captured in $1
){0,$opts{B}} # But only up to -B lines
) # End of "pre" lines captured in $1
# A ? minimal modifier seemed more natural like {0,$opts{B}}?,
# but negative lookahead assertion turned out to be more efficient.
# That might not be the case for really long lines, but it was
# in my testing.
( # Capture part of line before $pattern in $2
^.*? # Either the min set of chars prior to a
| # matching string beginning at start of line
\G.*? # Or same thing starting where matching left off
# I couldn't see why the former was required
) # and tried various methods of priming \G.
# None worked.
# Now capture the actual matching string in $3
# Allow . and \s to match newline and make
# spaces count within $pattern. But beware
# that there is a bug with -x in 5.005_03,
# so no space or '#' can follow it for now
((?s-x)$pattern)}xmo;
# Build a pattern that MAY grab the end of the line containing the
# last match along with the desired lines that follow it, but without
# stepping on the potential next match. This one will be chained off of the
# prior $full_pattern.
my $after_pattern = qr{
\G # Bind to position last match left off
( # Capture it in $1 so can print it
(?: # Group so I can count them
(?!.*(?s-x:$pattern)) # I don't want to see $pattern in these
.*\n # What we actually capture
){0,$opts{A}} # Well, up to -A lines anyway
)
}xo;
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 in the file. Hope we have enough
# memory and swap space.
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;
# We have now printed the first part of a line that
# contains the pattern. There is always at a minimum
# a newline left over at this point. But there could
# also be the start of another pattern. If the start
# of another pattern occurs on this line, we let the next
# loop iteration print it instead
print $1 if $string =~ /$after_pattern/gco;
# The above may have printed the end of the line containing
# the pattern and up to -A lines after the pattern.
#
# If the next line (or the rest of this line) contains
# start of the next pattern, then don't print the string
# showing end of a match set of lines
print $after_matched_lines
if $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$USAGE";
find_pattern_in_file(\*FH, $file_name);
}
}
exit 0;
sub parse_args {
$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}; # Num lines before pat to print
$opts{A} = 0 unless exists $opts{A}; # Num lines after pat to print
# Overrides both A and B
$opts{B} = $opts{A} = $opts{C} if (exists $opts{C});
# There must be at leat one pattern arg and at least A or B must be set
# If they want to give me something other than positive integer,
# then let them twist 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};
$opts{A}++; # $after_pattern must match the end of the line that
# contains the pattern at a minimum. This is an
# awkward place to put this, but I don't see any better.
return $pattern;
}
__END__
This is line 1
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 and MATCH
and 8 was the last.
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: Tue, 21 Sep 1999 01:39:06 +0200
From: "Trond Michelsen" <mike@crusaders.no>
Subject: Re: deja.com alters posts
Message-Id: <oxzF3.1194$1s6.10044@news1.online.no>
mike cardeiro <mikecard@my-deja.com> wrote in message
news:7s5dai$ev5$1@nnrp1.deja.com...
> I use deja.com for my newgroups and was just reading a message and i saw
> a link in the message. the link appeared as:
> merlyn@stonehenge.com
> When i clicked on the link i got a deja.com internal server error so i
> looked at the actual url within the link and saw this:
> http://www.deja.com/[ST_rn=md]/[ST_artlink=www.stonehenge.com]/jump/http
> ://www.stonehen ge.com/merlyn/
> I am sure this is not how the original poster coded the anchor adress.
> It is not ethical to alter data in a usenet post (and if you're going to
> do it the least you could do is make it work). this is alot different
> from putting a tag at the end of somebody's message that was posted
> through their system, that is fine, changing data in the actual message
> is not.
I don't agree. Usenet is for text/plain, while webpages are for text/html.
If you want to display a plaintext-message in a html-document, you have to
do /some/ conversion to get the look&feel from a regular newsreader. This
could be as simple as slapping <pre></pre> around the message and converting
< to < , but you probably want to take it further and add links to
email-addresses and URIs and maybe you want to put a <BR> at the end of each
line. Maybe you even want to replace "\n\n-- \n" with "\n\n<HR>\n" or print
quoted lines in a different colour.
However, the r/really/ important part is that the message when viewed
normally in the browser is identical to the message when viewed in a
newsreader.
--
Trond Michelsen
------------------------------
Date: Mon, 20 Sep 1999 23:17:44 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: File Upload
Message-Id: <sgzF3.23185$N77.1832452@typ11.nn.bcandid.com>
In article <37E6B9BA.AF5ABAA0@prodigy.net>,
Burt Hwang <bhwang@prodigy.net> wrote:
>. . . I can't figure out how to
>actually store the uploaded file on the server.
open or die, print, close. perldoc -f open, perldoc -f die, perldoc -f
print, perldoc -f close.
You might prefer CGI.pm, btw.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Mon Sep 20 1999
49 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Mon, 20 Sep 1999 19:21:40 -0400
From: "Bob Wilcox" <bwilcox@eudoramail.com>
Subject: Re: File Upload
Message-Id: <937869758.672994@news.tir.com>
Take a look at http://www.terminalp.com/scripts/
Burt Hwang wrote in message <37E6B9BA.AF5ABAA0@prodigy.net>...
>Objective: I need to pass a file from a webpage along with some other
>data (i.e, email address, name, etc.) and store the uploaded file on the
>web server.
>
>Problem: I've checked out cgi-lib.pl and used a sample code to display
>(on the user's browser) the uploaded file but I can't figure out how to
>actually store the uploaded file on the server.
>
>Can anyone help? Am I providing enough info? Here's the PERL code
>which I use to handle the user's data:
>
>
>-------------------------------------------------------------------------
>require "../cgi-lib.pl";
>
># When writing files, several options can be set... here we just set one
># Limit upload size to avoid using too much memory
>$cgi_lib'maxdata = 524288;
>
>
># Start off by reading and parsing the data. Save the return value.
># We could also save the file's name and content type, but we don't
># do that in this example.
>$ret = &ReadParse;
>
>
># A bit of error checking never hurt anyone
>
>&CgiDie("Error in reading and parsing of CGI input") if !defined $ret;
>
>&CgiDie("No data uploaded",
>
> "Please enter it in <a href='fup.html'>fup.html</a>.") if !$ret;
>
>
>
>
>
># Munge the uploaded text so that it doesn't contain HTML elements
>
># This munging isn't complete -- lots of illegal characters are left
>as-is.
>
># However, it takes care of the most common culprits.
>
>$in{'upfile'} =~ s/</</g;
>
>$in{'upfile'} =~ s/>/>/g;
>
>
>
>
>
># Now produce the result: an HTML page...
>
>print &PrintHeader;
>
>print &HtmlTop("File Upload Results");
>
>print <<EOT;
>
>
>
><p>You've uploaded a file. Your notes on the file were:<br>
>
><blockquote>$in{'note'}</blockquote><br>
>
><p>The file's contents are:
>
>$in{'upfile'}
>
>EOT
>
>
>
>print &HtmlBot;
>---------------------------------------------------------------------------
--
>
>Here's my HTML:
>---------------------------------------------------------------------------
--
><FORM ENCTYPE="multipart/form-data" NAME=upload METHOD=POST
>ACTION="cgi-bin/processOrder">
><INPUT TYPE=hidden NAME=hiddenVar VALUE=nothing>
>File Name:<INPUT NAME=upfile TYPE=file><P>
><INPUT TYPE=submit>
></FORM>
>---------------------------------------------------------------------------
--
>
>TIA.
------------------------------
Date: Mon, 20 Sep 1999 23:50:37 GMT
From: Farhad Farzaneh <ff@arraycomm.com>
Subject: Re: File Upload
Message-Id: <37E6C84D.C054A5DB@arraycomm.com>
Burt Hwang wrote:
>
> Objective: I need to pass a file from a webpage along with some other
> data (i.e, email address, name, etc.) and store the uploaded file on the
> web server.
>
> Problem: I've checked out cgi-lib.pl and used a sample code to display
> (on the user's browser) the uploaded file but I can't figure out how to
> actually store the uploaded file on the server.
You have the uploaded file's contents in $in{'upfile'}. You probably
also have the source filename in $incfn{'upfile'} if you want to keep
it. Now just write the file out like you normally.
open F,">$filename" or die("error opening file: $!\n");
binmode(F);
print F,$in{'upload'};
close F;
I haven't test it but you get the idea.
--
Farhad
------------------------------
Date: Tue, 21 Sep 1999 10:57:16 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: Perl Challenge
Message-Id: <MPG.125166dae4c8c9dd989ce6@news-server>
makau@multimania.com writes ..
>
>> >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
>
>Yeah, but I am pretty sure that in a very near future, you will need my
>help. As we say, newbies become knowbies...
well .. now I'll never see it
*plonk*
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Mon, 20 Sep 1999 17:32:04 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Perl Challenge
Message-Id: <37E6D204.5BF03054@mail.cor.epa.gov>
makau@multimania.com wrote:
>
> > >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
>
> Yeah, but I am pretty sure that in a very near future, you will need my
> help. As we say, newbies become knowbies...
Well, good luck. Just remember that it takes a lot of effort
to become a knowbie. But it's worth the work. You won't be
a true knowbie until you've read all the FAQ and all the docs
that come up when you type 'perldoc perl'.. and understand them.
Until then, do as many other new posters do. Carefully test
your answer before pressing 'send' [actually, *all* of us
have to do that]. Make sure the answer isn't already in the FAQ
before you make something up. Be sure there isn't a module
which does the task before you write a chunk of code.
Practice perlstyle and Netiquette. And make yourself look
good by posting what you do know and skipping over the parts
you don't.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 21 Sep 1999 01:02:04 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Perl FAQ problems
Message-Id: <gOAF3.23323$N77.1850534@typ11.nn.bcandid.com>
I found a bug in perlfaq9, so I went to the URL mentioned in the FAQ to
see if the bug had been fixed.
That URL is http://www.perl.com/pub/language/faq/. This page has links
to a couple of other places, like
http://www.perl.com/newdocs/pod/perlfaq9.html and
http://www.perl.com/newdocs/perlfaq9.pod, that are 404.
Is it possible Digex's Singapore-like mandatory transparent web proxy
has an out-of-date page? Or is the web site just wrong?
As it turns out, the FAQ I have is the latest version.
The bug is:
use Sys::Hostname;
$address = sprintf('%s@%s', getpwuid($<), hostname);
Since getpwuid has a list context, it's going to return all the
fields. As a result, it will use my encrypted password (or whatever
sits in that field) as a domain. So I get email addresses like
'kragen@x' and 'kragen@##kragen'.
I'm reading the FAQ because I recently posted some answer that, while
correct, was far inferior to the FAQ answer.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Mon Sep 20 1999
49 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Tue, 21 Sep 1999 01:19:12 +0200
From: "Trond Michelsen" <mike@crusaders.no>
Subject: Re: perl related question now!
Message-Id: <HezF3.1185$1s6.10282@news1.online.no>
Young-Soo Roh <ysroh@chat.carleton.ca> wrote in message
news:37E69E20.E7BA6455@chat.carleton.ca...
> This is newsgroup for perl.
Yes.
> I posted this message because I was wondering something can be done by
perl
> cgi script.
Well, it can't - or at least it would be pretty silly to do it with cgi.
This is best done by webserver-configuration, and although it is possible to
configure a webserver with Perl, it's not a Perl-issue at all.
If you can't setup password-protection on your webserver you could put your
files in a password-protected zip-file, but this is not Perl-related either.
--
Trond Michelsen
------------------------------
Date: Mon, 20 Sep 1999 23:19:11 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: perl related question now!
Message-Id: <PhzF3.23189$N77.1832547@typ11.nn.bcandid.com>
In article <HezF3.1185$1s6.10282@news1.online.no>,
Trond Michelsen <mike@crusaders.no> wrote:
>If you can't setup password-protection on your webserver you could put your
>files in a password-protected zip-file, but this is not Perl-related either.
Or you could use some method of encryption that doesn't have trivial
known-plaintext attacks published, or at least doesn't have them
available off the Net in ready-to-run form. e.g. GNU Privacy Guard.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Mon Sep 20 1999
49 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Tue, 21 Sep 1999 00:00:25 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: perl related question now!
Message-Id: <tUzF3.88$p63.3865@nsw.nnrp.telstra.net>
In article <37E6B9AD.1489A780@mail.cor.epa.gov>,
David Cassell <cassell@mail.cor.epa.gov> writes:
> I hope you don't talk to people like that even if you don't
> see them. And I hope you learn what is appropriate to ask
> in newsgroups and what is not. Note that I am not going
> to continue by calling you a 'loser' also, as _ad_hominem_
> arguments and name-calling are not appropriate here.
Nice LART :)
Martien
--
Martien Verbruggen |
Interactive Media Division | Little girls, like butterflies, need no
Commercial Dynamics Pty. Ltd. | excuse - Lazarus Long
NSW, Australia |
------------------------------
Date: Tue, 21 Sep 1999 10:56:29 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: Programmer's Editor
Message-Id: <MPG.125166a52d5f12e3989ce5@news-server>
scottlong@my-deja.com writes ..
>Try the CRiSP text editor. You can donload a free evaluation at
>http://vital.com/download.htm.
*plonk*
quoted shite removed
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Tue, 21 Sep 1999 10:58:28 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: Query date for tommorow
Message-Id: <MPG.12516722da939da1989ce7@news-server>
Dietmar Bestenlehner writes ..
>begin:vcard
*plonk*
(yes .. I *am* having fun this morning *8^)
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Tue, 21 Sep 1999 00:12:40 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: range of array indexes
Message-Id: <Y3AF3.92$p63.3865@nsw.nnrp.telstra.net>
In article <7s5srv$eij$1@nntp2.atl.mindspring.net>,
"Allan M. Due" <Allan@due.net> writes:
> Why not just :
>
> $str = join('',@array);
Because that will use the whole array, and the poster only wanted part
of it.
For the original poster: You need an array slice.
# perldoc perldata
my $str = join '', @array[$x..$#array];
Martien
--
Martien Verbruggen |
Interactive Media Division | Never hire a poor lawyer. Never buy
Commercial Dynamics Pty. Ltd. | from a rich salesperson.
NSW, Australia |
------------------------------
Date: Mon, 20 Sep 1999 17:09:28 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: reading registry in Perl on WinNT
Message-Id: <37E6CCB8.7781D332@mail.cor.epa.gov>
Tony Rice wrote:
>
> Is it just an environment variable or do I need separate module to get
> access to the registry by key?
No, it is not an environment variable. Yes, you do need a
separate module.
The registry in win32 is a collection of tree structures. And
blithely tinkering with it can wreak havoc upon one's system,
so be careful. But the Win32::TieRegistry module will help
you fiddle with your registry.. or someone else's. There are
extensive docs on this module in the HTML documentation which
ActiveState's install stuck in your Start Menu. Read the
examples, and back up before experimenting too much.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 21 Sep 1999 11:50:01 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: reading registry in Perl on WinNT
Message-Id: <MPG.125173321e2dc972989ce8@news-server>
Tony Rice writes ..
>Is it just an environment variable or do I need separate module to get
>access to the registry by key?
perldoc Win32::TieRegistry
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Mon, 20 Sep 1999 17:21:17 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Some e-mails get sent, some don't
Message-Id: <Pine.GSO.4.10.9909201718080.25903-100000@user2.teleport.com>
On Sun, 19 Sep 1999, Kragen Sitaker wrote:
> And it probably doesn't have to work for "fred and barney"@redcat.com;
> if someone has chosen such an obnoxious email address, they deserve to
> have things break.
An address may be obnoxious, but still valid. To refuse to serve a valid
address on such arbitrary and subjective grounds, though, is even more
obnoxious.
When deciding whether an address's format is valid, I prefer to use the
RFCs than to rely upon your subjective judgment.
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 20 Sep 1999 17:27:14 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Some e-mails get sent, some don't
Message-Id: <Pine.GSO.4.10.9909201725150.25903-100000@user2.teleport.com>
On Sun, 19 Sep 1999, Kragen Sitaker wrote:
> Nevertheless, I think something like this is the right way to go if
> you *must* pass user data to shells.
Perhaps that "if" should be re-examined. An e-mail address should simply
never get passed through a shell. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 20 Sep 1999 17:39:44 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Some e-mails get sent, some don't
Message-Id: <Pine.GSO.4.10.9909201729100.25903-100000@user2.teleport.com>
On Mon, 20 Sep 1999, Bill Moseley wrote:
> Ok. What about the previous question:
> >> $addr =~ s/'/\\'/g;
> >> if(!open(M,"|mail '$addr'"){
>
> Can anyone think of holes in that simple approach?
Is this what you want? Cheers!
$addr = q(billg@microsoft.com\';echo gotcha);
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 21 Sep 1999 00:52:33 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Some e-mails get sent, some don't
Message-Id: <lFAF3.103$p63.3865@nsw.nnrp.telstra.net>
In article <MPG.124ffd9d8f11fe9598975b@nntp1.ba.best.com>,
moseley@best.com (Bill Moseley) writes:
> Ok. What about the previous question:
>>> $addr =~ s/'/\\'/g;
>>> if(!open(M,"|mail '$addr'"){
>
> Can anyone think of holes in that simple approach?
$addr = 'bad@danger.com\' ; rm -rf /';
$addr = q(bad@danger.com' ; rm -rf /);
The email address will be broken, but the rm will be executed.
Martien
--
Martien Verbruggen |
Interactive Media Division | I took an IQ test and the results were
Commercial Dynamics Pty. Ltd. | negative.
NSW, Australia |
------------------------------
Date: 20 Sep 1999 19:19:13 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Sorting on a string, by value.
Message-Id: <x7zoyh6uj2.fsf@home.sysarch.com>
>>>>> "JM" == Jim Matzdorff <syran@best.com> writes:
JM> but I do try to
JM> a) proofread for errors
JM> b) attempt to do what I am trying to do, even if it's not the best way
JM> to do it to show that I am not just looking for a "quick" answer -- that
JM> I have actually attempted to solve for my own
JM> c) thank those that have helped me
d) try to learn from us.
we rip code here not for its own sake but to show better ways and
idioms. the ST (schwartzian transform) and larry's and my improvement
(no good name yet) are idiomatic ways to improve sorting. they also
isolate sort key extraction from the actual sort itself. too many people
don't know how and why they should be separated. seriously, you should
read our paper to learn more about this.
JM> however when you folks constantly criticize and berate me (or anyone,
JM> for that matter) when they do it the correct way, the best way, or even
JM> the obvious way (to you), well, it's gets a bit demeaning.
well, it wasn't just your code, but your description of your data space
that was buggy IMO. larry and i were (friendly) flaming each other about
that.
JM> is this comp.lang.perl.misc or comp.lang.perl.expert.only.misc?
the latter group will attract the most newbies. :-)
JM> Opps, i didn't even realize I didn't include the string comparison.
JM> The order should have been (1).(2)(3) or (numeric).(string)(numeric).
see, that is what i meant. the problem wasn't stated accurately.
JM> So, from your latest example I can figure out
JM> my ( $num1, $str, $num2 ) = /([\d_]+)\.([a-z]+)(\d*)/i ;
$num1 will have underscores which have to be removed, but otherwise that
looks good. i would declare the variables beforehand so you could test
the result of this regex for success.
JM> divide and conquer
JM> pack 'C5 A* x A*' =>
JM> split(/_/ => $num1), $num2 || 0, $str, $_
JM> ok, first i've never seen the "splat /_/ => $num1" syntax. am I to assume
JM> this will split a string and put the results into that string (and/or
JM> array?).
JM> pack 'C5 A* x A*' packs a unsigned char of len 5 (from num1), but I am
JM> unsure of what the A* x A* relates to? pack num2 (or 0) as an ASCII
JM> string then str as the same? what's the $_ needed for then?
you are crossing my key extraction regex with larry's packed sort. they
don't work together. his is expecting a list of 5 short (< 256) integers
which get packed into a single byte apiece. so you can't pass it $num1
which is a single larger integer.
either use my ST or larry's packed sort code but not both. but his had
the bug of assuming 5 seperate small integers in the prefix while mine
assumed a single large integer.
JM> @out = map substr($_, 1 + rindex $_, "\0"),
read the paper and all will be clear. what larry did was append the
original string to the generated key with a \0 separator. this map will
find the last \0 using rindex, and get the string after that char with
substr. the idea (did i tell you to read the paper?) is to have the sort
operator not do a perl callback which saves mucho cpu over other perl
sorts. so you have to have a way to associate the extracted key with the
original record and appending it is one way. another is appending the
record index number and using that to index back into the original list
of records.
JM> one then sorts all this to get a sorted list that then is mapped to
JM> @out by way of substr??? i am now officially lost as to how this
JM> translates. perhaps I don't understand the pack/substr functions well
JM> enough yet, but i am reading the camel book and did a perldoc on pack
JM> (which yields essentially the same text) put still am a bit lost.
read the paper and more will be clear. pack and unpack can be tricky to
grasp but they make sense after a while. think of them as binary
versions of printf/scanf (scanf is only in c, not perl) with different
way to designate how you print/store each value.
JM> Gads,
JM> --jim
zooks!
JM> In article <x7btazaiqc.fsf@home.sysarch.com>,
JM> Uri Guttman <uri@sysarch.com> wrote:
>> my ($parta1, $parta2) = split /\./, $a;
>>
>> $parta1 =~ s/_//g;
>>
>> that makes it a single numeric string
>>
>> return ( ( $parta1 == $partb1) ? (( $parta2 > $partb2 ) ? 1 : -1) :
>> ^^
>> (($parta1 > $partb1) ? 1 : -1 ));
and my comments above were not directed at you but at larry.
finally, you jeopardy quoted my entire post which is not cool. please
follow netiquette and place your comments after the edited partions of
the quoted post.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: Mon, 20 Sep 1999 23:41:00 GMT
From: *@dragons.duesouth.net (Matthew Bafford)
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <slrn7udgfe.6sn.*@dragons.duesouth.net>
On Mon, 20 Sep 1999 22:37:24 GMT, kragen@dnaco.net (Kragen Sitaker)
spewed forth:
: I'll try to keep it down below 30 posts a day.
Why?
As long as you continue to post accurate responses, continue follow
usenet convention, and continue your friendly attitude, I doubt many of
us would have any problem with you posting 50 a day.
Keep 'em coming!
--Matthew
------------------------------
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 860
*************************************