[6694] in Perl-Users-Digest
Perl-Users Digest, Issue: 319 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 16 21:07:13 1997
Date: Wed, 16 Apr 97 18:00:24 -0700
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, 16 Apr 1997 Volume: 8 Number: 319
Today's topics:
Re: "my" variable affects namespace "outside" block? (Kevin Buhr)
Re: "rename" PLEASE HELP!!! (I R A Aggie)
Re: -e command-line option <rra@stanford.edu>
Re: [Q] How to capitilize beginning of words (Tad McClellan)
Re: Array Elements <tchrist@mox.perl.com>
Re: auto refreshing form (Ivar Lade)
Beginners :: debugger (Was: "Dummies" book any good?) <thomson@zinger.adp.wisc.edu>
Bug in Regexp? <hcurrie@ice-t.com.au>
Re: C++Builder means Future. (Frank C. Earl)
Re: Camel Book example Question (Jeff Stampes)
Re: Good editor for W95? <mkruse@shamu.netexpress.net>
Re: how to use a system-installed Perl w/locally downlo (Thomas Andrews)
Inseting into a specific part of text.. <mianzo+@cs.cmu.edu>
Looking for simple module example (Perl for Win32) (Paul T. Burke)
Re: More on perl5.003 install (Matthew Cravit)
Re: PERL 4.036 for Solaris 2.5 (feedme.org/anti-spam.html)
Re: perl and multithreading (Richard S. Smith)
Re: PERL BUG: ([]) x 3 does not work correctly (Brian Dellert)
Re: Perl regular expressions - HTML <sastcm@unx.sas.com>
quotewords function - "0" problem bsautter@get-it.net
Re: reading in password file (Bill)
Snag with setting gid and uid (Zyana)
Re: Source code security for Perl 5 on NT (Activeware) (I R A Aggie)
Re: Strings as a uniform representation & tcl (Henry Baker)
Re: uninitialized value warning? <rootbeer@teleport.com>
Re: Unix and ease of use (WAS: Who makes more ...) <tim@a-sis.com>
Re: WANTED: perl guru ;-) (Jeff Stampes)
Wanted: UNIX email parser mirtos@panix.com
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 16 Apr 1997 17:55:50 -0500
From: buhr@stat.wisc.edu (Kevin Buhr)
Subject: Re: "my" variable affects namespace "outside" block?
Message-Id: <vbaenca4lx1.fsf@mozart.stat.wisc.edu>
jfw@wral-tv.wral-tv.com (John F. Whitehead) writes:
>
> Could someone please explain the following to me? (nicely?)
> Why does the following program, which uses a "my" variable in a loop,
> not get confined to the block it's in, and instead affect the variable the
> next time it's used? Example:
You've been bitten by a never-before-seen (?) perl bug, which I just
reported to "perlbug@perl.com". It seems that, in a multiple-BLOCK
construct, like an "if/elsif/else" or "while/continue" statement, the
*first* simple statement of the second and later BLOCKs may be
interpreted, lexically speaking, as if it belonged to the previous
block.
> My questions are:
>
> 1) why does the variable $file get undefined
In:
> if ($ends_in_slash == 1) {
> print "2 file is `$file'\n";
> my $file = "new value"; # line 3
> } else { # line 4
> print "3 file is `$file'\n"; # line 5
> }
the "my" variable *should* be limited to the end of the block in which
it appears (i.e., it should "cease to exist" after the "}" in line 4),
so the "$file" in line 5 should refer to "foreach"'s "$file" and not
the "my"-variable "$file" from the previous block.
However, because of this perl bug, it doesn't work right. Somehow,
perl thinks that the "$file" in line 5 is the same variable as the
"$file" in line 3. Since that variable is never initialized (it's
only set to "new value" if that first block is actually *executed*),
you get weird undefined values everywhere.
You can work around the problem, for now, by writing:
> if ($ends_in_slash == 1) {
> print "2 file is `$file'\n";
> my $file = "new value"; # line 3
> } else {
> 0; # useless non-empty statement to work around bug!
> print "3 file is `$file'\n"; # line 6
> }
Now, the "$file" in line 6 is "foreach"'s "$file" and not the "my"
variable from line 3, as it should be.
Kevin <buhr@stat.wisc.edu>
------------------------------
Date: Wed, 16 Apr 1997 18:52:06 -0500
From: fl_aggie@hotmail.com (I R A Aggie)
Subject: Re: "rename" PLEASE HELP!!!
Message-Id: <fl_aggie-ya02408000R1604971852060001@news.fsu.edu>
In article <8c208ad3b9.fsf@gadget.cscaper.com>, Randal Schwartz
<merlyn@stonehenge.com> wrote:
+ Nor are the parens. :-)
+ rename $var1, $var2;
Oh, I dunno:
When in doubt, parenthesize. At the very least it will let some
poor schmuck bounce on the % key in vi.
-- Larry Wall in the perl man page
James - I'm all for torturing poor schmucks who use vi... ;)
--
Consulting Minster for Consultants, DNRC
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: 16 Apr 1997 16:01:43 -0700
From: Russ Allbery <rra@stanford.edu>
To: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: -e command-line option
Message-Id: <qumu3l6fu7c.fsf@cyclone.stanford.edu>
[ Posted and mailed. ]
Ronald Fischer <rfi@uebemc.siemens.de> writes:
> perl -e 'while(<>){ print "$. $_"; }' -e 'print "DONE\n"' < ~/.login
I offered in return:
> perl -pe 'END { print "DONE\n" } print "$. "' < ~/.login
Randal Schwartz <merlyn@stonehenge.com> writes:
> perl -pe 's/^/$. /; $_ .= "DONE\n" if eof' ~/.login
Yeah, yeah, no redirect needed. Well, two can play at that game.
perl -pe 's/^/$. /; eof && s/$/\nDONE/' ~/.login
Hah! Take that!
--
Russ Allbery (rra@stanford.edu) <URL:http://www.eyrie.org/~eagle/>
------------------------------
Date: Wed, 16 Apr 1997 15:56:39 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: [Q] How to capitilize beginning of words
Message-Id: <7ee3j5.7th.ln@localhost>
Mike Stok (mike@stok.co.uk) wrote:
: In article <5hp0j5.5ou.ln@localhost>, Tad McClellan <tadmc@flash.net> wrote:
: >Of course, for this method to work, you need to be able to
: >spell capitalize ;-)
: You mean "capitalise" I suspect ;-)
I find 'capitalize' three times in the PODs at once in the new FAQ...
I find 'capitalise' zero times ;-(
So, I guess I should restate it as:
Of course, for this method to work, you need to be able to
spell capitalize whatever way the perl.gods spell it ;-)
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 16 Apr 1997 23:10:41 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Array Elements
Message-Id: <5j3m9h$8nu$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
"Corporate Microcomputing Department" <sastcm@unx.sas.com> writes:
: @array_name=(1,2,3,4,5);
: print "The number of elements is $#array_name\n";
:
: this will print the number 4.
Most people consider there to be 5 element in that array.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
Besides, REAL computers have a rename() system call. :-)
--Larry Wall in <7937@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: 16 Apr 1997 23:56:54 GMT
From: il@litago.hials.no (Ivar Lade)
Subject: Re: auto refreshing form
Message-Id: <slrn5lapr6.kml.il@litago.hials.no>
Wed, 16 Apr 1997 13:24:11 -0600, Ed Young <eyoung@ncsa.uiuc.edu>:
>I have an html form for a semi chat/guestbook. After you submit to the
>form, the information is placed on the same page. Problem is in order to
>see the updated form the end user has to reload/refresh their browser. How
>can I code the page so that when they hit the submit button...it adds to
>the page and then automaticly reloads the page. Thanks!
My homepage has a guestbook on the bottom, when you push submit the message
is posted to the same page. This causes the page to reload and add you're
message.
The whole page is written in perl (perverse?), some of the stuff is being
read from files. The page also includes counter, sizeing of images and
reads my .plan file. Whole source is readable, url is five lines down ...
PS: feel free to mail better soulutions to me, I know it's lousy code :-)
--
Ivar Lade (il@3data.hials.no)
http://3data.hials.no/~il/
------------------------------
Date: 16 Apr 1997 19:12:53 -0500
From: Don Thomson <thomson@zinger.adp.wisc.edu>
Subject: Beginners :: debugger (Was: "Dummies" book any good?)
Message-Id: <tzn2qybj7e.fsf_-_@zinger.adp.wisc.edu>
>>>>> "Terry" == Terry Michaels <74331.3261@CompuServe.COM> writes:
Terry> [...] I think a beginner
Terry> should begin using the debugger as soon as possible.
>>>>> "Randal" == Randal Schwartz <merlyn@stonehenge.com> writes:
Randal> I think a beginner should be taught to write correct programs,
Randal> thus avoiding the use of the debugger, as soon as possible.
Randal: I teach a fifteen hour Perl course through the computing center
at the university and show folks simple debugger commands the very first
day, not for debugging, but as a tool for watching the execution of a
program so they can see what's happening flow-of-control-wise and why.
It's a great learning tool for them, and also a great way to demonstrate
Perl logic by stepping through code a line at a time in class while
explaining concepts.
By the way, we buy each of them a copy of your book and use that as the
basis for the course, with a few Perl5 addendums thrown in. The only
course prerequisite is prior experience watching the Flinstones.... ;-)
--
----- Don Thomson ----- DoIT (Division of Information Technology) -------
thomson@doit.wisc.edu (608) 262-0007 1210 W. Dayton, Madison, WI 53706
------------------------------
Date: Thu, 17 Apr 1997 10:15:37 +1000
From: Hamish Currie <hcurrie@ice-t.com.au>
Subject: Bug in Regexp?
Message-Id: <33556BA9.FEB@ice-t.com.au>
Hi there,
I have a scalar that has about 34k of text (html) in it. I run the
Regexp
$s =~ /<[ \t\n]*body([ \t\n][^>]*)?>((\n|.)*)<[ \t\n]*\/body[ \t\n]*>/i;
over it, and $2 which I expect to have the body of my html document in
it,
retrns '2' if I cut out some of the source file, everything works well.
(30k seems fine.) Is this a bug? Does Perl have a limit on the size of
data
it can process with Regex? Can anyone suggest a workaround?
I have tested this on freebsd:
$ perl -v
This is perl, version 5.003 with EMBED
built under freebsd at Feb 25 1997 10:25:25
+ suidperl security patch
and on win32:
C:\xxx>perl -v
This is perl, version 5.001
Unofficial patchlevel 1m.
Copyright 1987-1994, Larry Wall
Win32 port Copyright (c) 1995 Microsoft Corporation. All rights
reserved.
Developed by hip communications inc., http://info.hip.com/info/
Perl for Win32 Build 110
Built Aug 13 1996@08:18:50
on Win32 perl, 10k of text seems to break this example, and it crashes
with
a Runtime Exception.
I have included the test program I used.
#
# Test
#
my $s = includeFile("in.html");
$s =~ /<[ \t\n]*title[ \t\n]*>((\n|.)*)<[ \t\n]*\/title[ \t\n]*>/i;
my $Title = $1;
$s =~ /<[ \t\n]*body([ \t\n][^>]*)?>((\n|.)*)<[ \t\n]*\/body[ \t\n]*>/i;
my $Body = $2;
my $Template = includeFile("template.html");
$Template = VarReplace($Template, "Replace", "Title", $Title);
$Template = VarReplace($Template, "Replace", "Body", $Body);
SaveFile("out.html", $Template);
sub includeFile {
my $FileSpec = $_[0];
my $S = '';
if (open(FIN, '<' . $FileSpec)) {
while (<FIN>) {
$S .= $_;
}
close FIN;
}
return $S;
}
sub SaveFile {
my ($FileSpec, $FileContent) = @_;
my $S = '';
if (open(FOUT, '>' . $FileSpec)) {
print FOUT $FileContent;
close FOUT;
} else {
print "Fatal Error Saving File: $FileSpec\n";
}
}
sub VarReplace {
my ($doc, $Key1, $Key2, $Value) = @_;
while ($doc =~ m/\[$Key1\[$Key2\]\]/){
$doc =~ s/\[$Key1\[$Key2\]\]/$Value/g;
}
return $doc;
}
------------------------------
Date: Wed, 16 Apr 1997 23:51:19 GMT
From: fearl-no-spam-@-no-spam-airmail.net-no-spam- (Frank C. Earl)
Subject: Re: C++Builder means Future.
Message-Id: <335565af.5056617@news.airmail.net>
On Wed, 16 Apr 1997 16:46:45 -0700, 34110s96@student.csi.cuny.edu
wrote:
>I just got C++Builder and I have never seen a powerful RAD tool like
>this one. Forget about the Visual Crap. C++Builder is the King of the
>Hill and not Marketing hype of Microsoft.
And if only it was on Linux, we'd be in hog-heaven. Thing is, it's on
MS-Windows.
--
Frank C. Earl
Earl Consulting Services
---------------------------------------------------------------------------
Pursuant to USC 47, there is a $500 per incident charge for each and
every piece of Unsolicited Commercial Email (UCE) sent to this or any
of my other addresses. Sending UCE's to any of my addresses implys
general acceptance of these terms. (My Return addresses are _deliberately_
broken to interfere with mailing list generators- remove "-no-spam-" every
place in the address to reply.)
------------------------------
Date: 16 Apr 1997 23:31:11 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: Camel Book example Question
Message-Id: <5j3nfv$1dt$2@neocad.com>
P. Pitton (ppitton.quada@t-online.de) wrote:
: I have a question concerning an example in the Camel-Book, page 226
: perl -ne 4print if (/REGEX/ ? ($c=LINES) : (--$c > 0))4 FILES
: I don4t understand the inside of the parentheses, the ? and : look so
Page 91 in the camel will help you understand the trinary ?: operator
better. Basically it's a simple if/else.
TEST_EXPR ? IF_TRUE_EXP : IF_FALSE_EXP
--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com
------------------------------
Date: 16 Apr 1997 23:21:02 GMT
From: Matt Kruse <mkruse@shamu.netexpress.net>
Subject: Re: Good editor for W95?
Message-Id: <5j3msu$ong@news1-alterdial.uu.net>
Benjamin Burack <rascal@inlink.com> wrote:
: I'm writing CGI scripts in perl on my W95 machine, and then uploading
: them to the Unix server. I'm looking for recommendations on good
: editors that can easily save in a Unix format.
www.textpad.com
The best 32-bit windows text editor available, IMO.
--
Matt Kruse
mkruse@netexpress.net
http://mkruse.netexpress.net/ http://www.mkstats.com/
---------------------------------------------------------------------------
------------------------------
Date: 16 Apr 1997 17:09:14 -0700
From: thomaso@shell3.ba.best.com (Thomas Andrews)
Subject: Re: how to use a system-installed Perl w/locally downloaded modules
Message-Id: <5j3pna$odv@shell3.ba.best.com>
In article <5j18pp$i04@fridge-nf0.shore.net>,
Nathan V. Patwardhan <nvp@shore.net> wrote:
>Terrence M. Brannon (brannon@bufo.usc.edu) wrote:
>
>: I am not superuser, yet I wish to use the system-installed Perl with
>: modules I get from CPAN and store in my lcal directory? Is there some
>: way to set this up?
>
>Read the INSTALL/README files that came with your distribution... you
>might see a reference to prefix, or exec-prefix, or even "install the
>modules in another place". OR, run perl Makefile.PL and add the PREFIX
>(the base location where you want the modules installed) by hand.
I've been writing my own packages, for a perl application I want to
release to users, and I've been doing this (setting PREFIX), but for
some reason, I keep getting the error message:
Writing /path/to/app/lib/perl5/site_perl/i386-freebsd/auto/StringBox/.packlist
cannot create /path/to/app/lib/perl5/i386-freebsd/5.003/perllocal.pod: directory nonexistent
When I create the directories:
/path/to/app/lib/perl5/i386-freebsd
/path/to/app/lib/perl5/i386-freebsd/5.003
"make install" works, but I'm trying to create a fault-tolerant install,
and the path I need to create is different depending on the machine.
For example, on a Solaris machine, I need to create the directory:
/path/to/app/lib/sun4-solaris
/path/to/app/lib/sun4-solaris/5.003
Obviously, I'd really rather the FreeBSD machine didn't try to put
stuff in a /perl5 subdirectory - then I could safely create the
directory:
/path/to/app/lib/<arch>/<version>
but as it stands, it's not clear to me how to override the part
that keeps adding perl5 on the FreeBSD machine, short of overriding
all of the following (created by Makefile.PL):
INSTALLPRIVLIB = $(PREFIX)/lib/perl5
INSTALLARCHLIB = $(PREFIX)/lib/perl5/i386-freebsd/5.003
INSTALLSITELIB = $(PREFIX)/lib/perl5/site_perl
INSTALLSITEARCH = $(PREFIX)/lib/perl5/site_perl/i386-freebsd
--
==
Thomas Andrews thomaso@best.com http://www.best.com/~thomaso/
"Harry Truman's a goddamn liar. No
pidgeon ever lit on my head." - Senator Sam Rayburn
------------------------------
Date: Wed, 16 Apr 1997 20:34:39 -0400
From: Mark C Seigle <mianzo+@cs.cmu.edu>
Subject: Inseting into a specific part of text..
Message-Id: <3355701E.41C67EA6@cs.cmu.edu>
Hello, I am kind of new to some Perl functions. I was wondering if
someone could point me to a way of...
grepping for a line of text in an ascii file...
inserting at that line number....
I am firmilliar with standard file operations, however I cannot figure
out how to throw something into the middle of the text.
All help is greatly appreciated!
--
Mark C. Seigle
School of Computer Science Operations
Carnegie Mellon University
------------------------------
Date: Wed, 16 Apr 1997 22:49:45 GMT
From: paul_burke@onesource.com (Paul T. Burke)
Subject: Looking for simple module example (Perl for Win32)
Message-Id: <335555ef.92435024@snoop>
I am in search of a simple module example that I can see from both the
.pm and .pl file perspective. I have am new to creating my own perl
modules and have not found any simple examples that work as
documented.
Any help would be greatly appreciated.
Thank You,
Paul T. Burke
paul_burke@onesource.com
------------------------------
Date: 16 Apr 1997 13:24:23 -0700
From: mcravit@shell3.ba.best.com (Matthew Cravit)
Subject: Re: More on perl5.003 install
Message-Id: <5j3chn$ch8@shell3.ba.best.com>
In article <Pine.SOL.3.93.970416113858.27251A-100000@bmec.hscbklyn.edu>,
Sankar Mukhopadhyay <sankar@hscbklyn.edu> wrote:
>
> rm -f configure.sh
> sh Configure -Dcc=gcc
>make: Warning: Both `makefile' and `Makefile' exist
>`sh cflags libperl.a miniperlmain.o` miniperlmain.c
> CCCMD = gcc -c -O
>sh: gcc: not found
Try either adding /usr/local/bin (or whichever directory you have gcc
installed in) to your path, or doing "sh Configure -Dcc=/usr/local/bin/gcc".
If gcc is not found, it's either because it's not installed, or it's not
installed in a directory that is in your path.
/MC
--
--
Matthew Cravit, N9VWG | Experience is what allows you to
E-mail: mcravit@best.com (home) | recognize a mistake the second
mcravit@taos.com (work) | time you make it.
------------------------------
Date: 16 Apr 97 22:09:34 GMT
From: "nozaki@feedME" (feedme.org/anti-spam.html)
Subject: Re: PERL 4.036 for Solaris 2.5
Message-Id: <33554e1e.0@lightning.ica.net>
Hi! Where can I find a binary version of PERL 4 .036 for SUN Solaris 2 .5?
Thanks!
---------------------------------------------
Free ACCCESS to 30,000 Newsgroups
Read and Post through a web-site...
http://www.feedME.org
---------------------------------------------
------------------------------
Date: Wed, 16 Apr 1997 23:55:21 GMT
From: rsmith@netcom.com (Richard S. Smith)
Subject: Re: perl and multithreading
Message-Id: <rsmithE8r949.Cnz@netcom.com>
Malcolm Beattie (mbeattie@sable.ox.ac.uk) wrote:
: Multithreading is being merged in to perl after 5.004 is out (the
: original work was done against 5.001m but more important things
: took precendence for the perl core). It uses a fairly small number
: of threading primitive macros which currently have definitions for
: the POSIX threads API (and for old-draft/DCE threads). Adding a
: "fake" scheduler for platforms without O/S thread support is on the
: ToDo list (and, in fact, a proof of concept version "Plthread"
: showed it could be done a couple of years ago).
Forgive me but I'm going to use this thread to ask a question that's been
on my mind for a while.
What's the difference between "multithreading" Perl and a Perl script that
uses fork() to do things in the background? For example, in chapter 6 of
the new Camel book (page 350) there's code for a "multi-threaded" socket
server script that I've been using as a basis for some stuff web-related
stuff I've been doing.
What's the difference between that and "true multithreading"?
Thanks for any enlightenment on this issue.
--
+--------------------------------------------------------------------+
| Richard S. Smith / rsmith@netcom.com / http://www.captech.com/~rss |
| Progress(tm) 4gl v[678] Developer/DBA / Los Gatos, California, USA |
| The PROGRESS FAQ --> http://www.captech.com/~rss/progress-faq.html |
+--------------------------------------------------------------------+
------------------------------
Date: Wed, 16 Apr 1997 22:42:23 GMT
From: xpress@pobox.com (Brian Dellert)
Subject: Re: PERL BUG: ([]) x 3 does not work correctly
Message-Id: <33555521.23275092@news.real-time.com>
On 14 Apr 1997 13:47:41 -0700, Russ Allbery <rra@stanford.edu> wrote:
>Umm...this is exactly what I would expect to happen. With the x operator,
>you're asking Perl to make three exact copies of ([]). An exact copy of
>an array reference isn't a new array reference; it's a reference to the
>same array.
Thanks for the info. Any idea how I can get my array to contain an
arbitrary number of *different* array references. This is the code
I'm using now:
my($i, @chain);
for($i=0; $i<@$pieces; $i++) {
push @chain, [];
}
Is there any more elegant/faster solution? My gut feeling is that
there must be, but maybe this is my only bet.
thanks again,
brian
>
>--
>Russ Allbery (rra@stanford.edu) <URL:http://www.eyrie.org/~eagle/>
------------------------------
Date: Wed, 16 Apr 1997 23:40:38 GMT
From: "Corporate Microcomputing Department" <sastcm@unx.sas.com>
Subject: Re: Perl regular expressions - HTML
Message-Id: <01bc4abf$073c90f0$5901170a@spearmint>
I hope this helps I'm sure there are more ways to do this.
# Case #1 is OK.
# <dt><A HREF="/forum/index.html"><img src="/products/gif/greenb.gif"
# alt="*" border=0>The FORUM</A>
#----------------------------------------------------------------
# Case #2 needs a "index.html" appended onto "/forum"
# Case #3 needs a "/" and a "index.html"
#---------------------------------------------------------------
# made Case #2 and Case #3 problems into an array
# you can read your file into an array
# by using:
#
# open(FILE,$path_to_file) || die "can't open $path_to_file\n";
# @oldfile=<FILE>;
# close(<FILE>);
#-------------------------------------------------------------------
@oldfile=('<dt><A HREF="/forum/"><img src="/products/gif/greenb.gif"
alt="*"',
'<dt><A HREF="/forum">');
#make a copy, grep will modify the original
@file=@oldfile;
# this looks wierd, most of the symbols needed to be escaped
grep {s/(.*)HREF\=\"\/forum\/\"(.*)/$1HREF\=\"\/forum\/index\.html\"$2/}
@file;
grep {s/(.*)HREF\=\"\/forum\"(.*)/$1HREF\=\"\/forum\/index\.html\"$2/}
@file;
#show output, you would probably print the array back to the original file
foreach $line (@file){print "new line is:$line\n";}
----Tamara
sastcm@wnt.sas.com
----------------------------------------------------------------------------
-------------------
TempStephenByrne@extonpo.bentley.com wrote in article
<861140815.15319@dejanews.com>...
> I am fairly new to Perl so forgive the simplicity of my question/example.
>
> I am trying to format some HTML documents that we have so that they will
> be consistent. Within the documents I am trying to fix the following.
>
> We have 3 cases:
>
> <dt><A HREF="/forum/index.html"><img src="/products/gif/greenb.gif"
> alt="*" border=0>The FORUM</A>
>
> <dt><A HREF="/forum/"><img src="/products/gif/greenb.gif" alt="*"
> border=0>The FORUM</A>
>
> <dt><A HREF="/forum">
>
> Case #1 is OK.
> Case #2 needs a "index.html" appended onto "/forum"
> Case #3 needs a "/" and a "index.html"
>
> Here's the Perl that I have currently: (this is about my 45th attempt
..
> I have tried everything)
>
>
> ## This one is supposed to append the "/"
> ## It assumes that all hrefs have been capitalized
>
> ##### problem is it puts "/" on the end of each href
>
> if (($_ =~ "HREF=\"") &&
> ($_ !~ "HREF=\"\/.+\/\">") &&
> ($_ !~ "http:") &&
> ($_ !~ "HREF=\"\/[\w\.\/]+\.\w{3,4}\">"))
> {
> s/HREF=\"\/(.+)\">/HREF=\"\/\1\/\">/;
> }
>
> ## Then, I run this part which should append index.html where needed
>
> if (($_ =~ "HREF=\"") &&
> ($_ !~ "HREF=.*\#.*\">") &&
> ($_ !~ "HREF=\"\/.+\.\w{3,4}\">"))
> {
> s/(HREF=\".+\/*.*)\"\>/\1index.html\"\>/;
> }
>
>
> I have also tried several mutations of this code, all of which come close
> but no cigar.
>
> Has anybody done this successfully? Or could somebody please provide
> some assistance for what I have provided above?
>
> Thanks in advance!!!
>
> -Steve
>
> -------------------==== Posted via Deja News ====-----------------------
> http://www.dejanews.com/ Search, Read, Post to Usenet
>
>
------------------------------
Date: Wed, 16 Apr 1997 17:41:32 -0600
From: bsautter@get-it.net
Subject: quotewords function - "0" problem
Message-Id: <861229148.8435@dejanews.com>
I am using the "quotewords" function along with
some other code to split a CSV file.
Just today I found my script was working. I narrowed
it down to the quotewords function. Here is a
snippet of code that shows this problem:
----------------------------------------
#!/usr/local/bin/perl
use Text::ParseWords;
$test="Test,string0,with,stuff,in,it,b0";
@values = quotewords(",", 0==0, $test);
foreach (@values)
{
print "VALUE: $_\n";
}
----------------------------------------
The output of this is:
VALUE: Test
VALUE: string0
VALUE: with
VALUE: stuff
VALUE: in
VALUE: it
VALUE: b
It eliminates any zero found at the end of a line!
Zeros in the middle are not affected as in "string0".
Only by putting quotes around the last value will it
keep the zero:
$test="Test,string0,with,stuff,in,it,\"b0\"";
Has anyone noticed this problem before or have a solution?
Benjamin Sautter
bsautter@get-it.net
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 16 Apr 1997 22:22:24 GMT
From: bill@sover.net.no.junkmail (Bill)
Subject: Re: reading in password file
Message-Id: <slrn5lak90.9ss.bill@granite.sover.net>
In article <5iu3r4$7jg@news.fsu.edu>, Justin C Lloyd wrote:
>I am writing a program that needs to read the password file once for each
>student on a roster, and possibly many rosters. Therefore I am reading the
>password file into an array to speed things up (A LOT!!) I had a small
>problem in my code since I was creating an array of references to arrays (I
>kept reusing the same array so it was always the same reference).
>
>Anyway, to make a long story short, here is the function I came up with:
>
>sub read_password_file {
> my @entry = ();
> my @pwfile = ();
> while (@entry = getpwent) {
> my @pwent = @entry;
> push @pwfile, \@pwent;
> }
> return @pwfile;
>}
>
>Is there a way to make it more efficient? Also, would it be better to return
>the array or a reference to the array?
>
>JcL
You want to use the anonymous array constructor []:
sub read_password_file {
my @pwfile;
my @entry;
while (@entry = getpwent) {
push(@pwfile, [ @entry ] );
}
return @pwfile;
}
The [ ] take whatever list is inside them, allocates space for the
array, and return a reference to the new array when evaluated. This is
important when you are doing things just like the above: iterating over
something whose reference potentially always points to the same spot. The
arrays created by [ ] are called anonymous arrays because there is no
entry in the symbol table for them, and yet they are still perfectly
valid arrays. Hope this helps...
Bill
--
Sending me unsolicited email through mass emailing about a product or
service your company sells ensures that I will never buy or recommend your
product or service.
------------------------------
Date: 17 Apr 1997 00:11:55 GMT
From: zyanya@ix.netcom.com(Zyana)
Subject: Snag with setting gid and uid
Message-Id: <5j3psb$kki@sjx-ixn3.ix.netcom.com>
Hi folks,
Sorry to bug you again, but Ive got a question about chown($uid,
$gid, $filename), and I absolutely cannot seem to be able to post to
comp.infosystems.www.authoring.cgi, try as I might (and I have tried.)
If any of you can post to that group, passing this message along would
sure be appreciated, because Im having real trouble with getting any
feed to that group. I can read it (sometimes.) I just cant seem to
get anything to post to it.
The scenario is this:
Ive written a script to upload files from a persons home
computer to their directory at my domain. Nicely gets rid of the need
for an FTP account.
However, although I know my uid and gid, and try to chown($uid,
$gid, $filename), for the file they are uploading, it always changes it
to nobody user. I see this when I use my Telnet account and check
on the status. It should be reading:
(dir info) (mydomain) (mydomain) (other stuff) filename.ext
As it stands, its reading:
(dir info) nobody user (other stuff) filename.ext
At least the files get uploaded! This wouldnt be a problem if I
werent planning on installing CGI bins for people too. (Yes, Ive got
software files that do the password checking, so they cant get in to
upload or open and create a file without those.) Any file that is not
a script gets called just fine when a person goes to that web site and
subdirectory. Images get called up just fine. HTML files, text
files...
But its just those darn uid and gid assignments that Im having
trouble with... And those will be critical to letting people run their
own scripts.
Ive tried putting the chown at the end, after the files
uploaded. No go. Ive tried putting it just before the file gets
uploaded. No go. Ive tried different styles of quotes, wondering (on
a slim chance) if that might be the problem. No go. The test cgi bins
work fine. The test perl scripts Ive been uploading to test this
already are fully debugged and run. I made sure of that. But they
only run if I load them from my real FTP account.
Ive heard that this chown has to be changed from the root
domain. Does anyone know how to get around this problem and change it
from a Perl script called from a web page? Is there something extra
that I need to add in there? Id really like to know how to do it with
a script, automatically, when people upload things, use one of my
on-line editors to open a file and write to it.... Its just not
going to be feasible for me to be constantly uploading scripts for
people, seeing if they run, letting them know what the bug output
was... This needs to be automated.
Also, just because Im starting up a web page hosting service,
please dont think Im made of money and can shell out $$$$ (scalars?
<g>) Some people have suggested I just save myself the hassle and buy
several software packages to the tune of $400-$600 or more, but I just
dont have the funds! I need to do this myself!
Anyone have any answers? Anyone have any snippets of code they
can send me? Id sure appreciate that rather than being referred to
sites with huge bulks of information and I essentially have to wade
through the equival
ent of 8 books on Perl to see if I can figure out an answer. (Yes,
people have done that.) Time is a precious commodity too, and this is
_one_ _specific_ _problem_, not a lot of problems, that requires I wade
through tons of web pages and try to weed out whats relevant and
whats not - and theres a lot out there.
Thanks for listening. Hope you can help. My appologies is this
sounds a little curt, but Ive been up almost 24 hours and thats
taking its toll.
Thanks!
Zyana
------------------------------
Date: Wed, 16 Apr 1997 18:56:01 -0500
From: fl_aggie@hotmail.com (I R A Aggie)
Subject: Re: Source code security for Perl 5 on NT (Activeware)
Message-Id: <fl_aggie-ya02408000R1604971856010001@news.fsu.edu>
In article <33553C14.8A7@krypton.mankato.msus.edu>, "John A. Kaliski"
<johnk@krypton.mankato.msus.edu> wrote:
+ Does anyone have any other ideas?
Talk to a lawyer and get an iron-clad license written?
James
--
Consulting Minster for Consultants, DNRC
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: Thu, 17 Apr 1997 00:15:56 GMT
From: hbaker@netcom.com (Henry Baker)
Subject: Re: Strings as a uniform representation & tcl
Message-Id: <hbaker-1604971615560001@10.0.2.1>
In article <qijbu7e95da.fsf_-_@lambda.ai.mit.edu>, Olin Shivers
<shivers@lambda.ai.mit.edu> wrote:
> > If one had to choose a single type for everything, a string is a
> > pretty good choice. Why not a number? How would you represent a
> > string with a number?
>
> Perlis, as usual, summed it up well in one of his aphorisms:
>
> The string is a stark data structure, and everywhere it
> occurs there is much hiding of information.
I'm afraid you may be 'casting Perlis before swine'.... ;-) ;-) ;-)
------------------------------
Date: Wed, 16 Apr 1997 16:21:38 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Justin C Lloyd <lloyd@cs.fsu.edu>
Subject: Re: uninitialized value warning?
Message-Id: <Pine.GSO.3.96.970416161231.28428B-100000@kelly.teleport.com>
On 14 Apr 1997, Justin C Lloyd wrote:
> I am receiving the following warning 1648 times (when using the
> -w option):
>
> Use of uninitialized value at ROSTERS.pm line 122, <FP> chunk 7.
1648 times? Sounds as if Perl is trying to tell you something. :-)
> Here is the function with the offending line:
>
> sub guess_email {
> my ($name, $first, $mi, $last);
> my ($name, $pwref) = @_;
Did you mean to have a second $name variable?
> my @matches = ();
Nothing wrong-wrong with that, but maybe you didn't realize that 'my
@matches' would have done the same here.
> ($last, $first, $mi) = split /\s+/, $name, 3;
Since we're looking for an uninitialized variable problem, it wouldn't
hurt to doublecheck that (for example) $mi is defined here.
> ### line 122 ###
> @matches = grep { $_->[5] =~ /$first\s+($mi\s+)?$last/i } @$pwref;
> $pwref is a reference to an array containing 849 (1/2 of 1648) password
> file entries.
So, are both $_ and $_->[5] always defined inside that grep? (That is, is
the sixth element of each of those password file entries always a defined
value?)
Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 16 Apr 1997 23:58:43 GMT
From: "Tim Behrendsen" <tim@a-sis.com>
Subject: Re: Unix and ease of use (WAS: Who makes more ...)
Message-Id: <01bc4ac2$006a2b40$87ee6fce@timpent.a-sis.com>
Jettero Heller <heller@nacs.net> wrote in article <5j2m8n$q0f@tracy.nacs.net>...
> Tim Behrendsen (tim@a-sis.com) wrote:
> : Jettero Heller <heller@nacs.net> wrote in article <5j06j7$hoh@tracy.nacs.net>...
> : > Tim Behrendsen (tim@a-sis.com) wrote:
> : > : I don't accept excuses for my employees, I don't accept excuses
> : > : for myself, and I don't accept them for Larry Wall. There is no
> : > : excuse for code without comments. Period.
> : >[snip]
> : > Don't try to push *your* personal coding beliefs on other people.
> : > If you can't accept other peoples coding styles, then don't look at
> : >[snip]
> : If not, whether you answer to me or not is irrelevent. Of course
> : you can do whatever you want with your code. That doesn't change
> : the fact that uncommented code released publically for a significantly
> : complex program is shamefully bad engineering.
>
> This is all nice. . .but irrellavent to the point. The point is:
> Since he is not programming this for *anyone* but himself, he *does
Well, I think at this point Perl has a larger following than
only Larry Wall.
> not* have to abide by anyone elses coding style. You saying "He
> should comment it" *does not* mean that he has to comment it. Just
> cuz you say it is bad engineering does not make it so. The only
> thing that not commenting code makes it is: not commented.
You seem to think that commenting is a question of style, and
it is not. Braces are style, commenting is part of writing
well engineered code.
> Why is it that because *you* insist that he must comment his code,
> and he does not, it is bad engineering? You seem to think that it is
> a "fact" that releasing uncommented code is bad engineering. Sorry
> buddy, that is an opinion. not a fact. Until you accept that, you
> aren't going to get far in talking to other people about coding.
> Releasing code that doesn't work, is bad engineering. . .
> Releasing working code is not. . .
Guess what, if someone released code that was full of gotos, was
packed without any spaces or line breaks into 80 columns and no
indentation, I would call that bad engineering also. But heck,
it's *only* style. Hey, who am I to judge?
If you want to get defensive because you are writing code without
comments, then go ahead. We both know you are writing crap code,
and all the self-righteousness in the world is not going to change
the fact that there are far more software engineers that agree
with me than agree with you.
Of course, you will learn this lesson when you inherit someone's
code that followed your loser philosophy, and have to figure out
what the hell it does. Grow up, and learn to type.
--
==========================================================================
| Tim Behrendsen (tim@a-sis.com) | http://www.cerfnet.com/~timb |
| "Judge all, and be prepared to be judged by all." |
==========================================================================
------------------------------
Date: 16 Apr 1997 22:56:21 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: WANTED: perl guru ;-)
Message-Id: <5j3lel$1dt$1@neocad.com>
[Followups redirected to eliminate the defunct newsgroup c.l.p]
Sascha (ss@ee.ed.ac.uk) wrote:
: This is a multi-part message in MIME format.
Some people use text-based newsreaders...was there something in
your message that couldn't be posted as straight text?
: IyEvdXNyL2xvY2FsL2Jpbi9wZXJsCiRDb250cm9sQWRkcmVzcyA9ICJsaXN0cHJvY1xAbGlz
: dHMuYWN1c2QuZWR1IjsKJFRlc3RpbmcgPSAiT2ZmIjsKJE1heERpc3BsYXkgPSA0OwokU2Vh
: cmNoUGFnZSA9ICRFTlZ7J0hUVFBfUkVGRVJFUid9OwokVGl0bGVBbGlnbiA9ICJjZW50ZXIi
[etc, etc, etc]
Hmmm..I'm not sure this is a supported function in perl4.
--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com
------------------------------
Date: Wed, 16 Apr 1997 19:32:09 -0600
From: mirtos@panix.com
Subject: Wanted: UNIX email parser
Message-Id: <861236600.14253@dejanews.com>
I'm looking for a simple email parser. I'm not looking for something
to connect to accounts, or deal with multiple messages. One message per
file.
I just want to extract from the message (to variables, an array, whatever)
To, From, Subject, Body, and the number of attachments if there were any.
Ive looked into MailTools, but there doesnt seem to be anything that
will do this specifically. Now I can of course simply read thrugh the
file, and go through all the steps myself, but I'm hoping someone has
already written a basic parser. (im not looking to send, just to
extract). I have to be honest, I'm really busy, so I tend to miss lots of
messages in this newsgroup, so if at all possible, an email reply to
mirtos@panix.com would be great. If anyone has any answeres in the next
day or two, that would be great as well.
TIA
Matthew Mac Gibbon
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 319
*************************************