[6405] in Perl-Users-Digest
Perl-Users Digest, Issue: 30 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 28 12:27:12 1997
Date: Fri, 28 Feb 97 09:00:20 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 28 Feb 1997 Volume: 8 Number: 30
Today's topics:
Re: Class library to make C++ more Perlish? (Alan Ezust)
Compiling problems: Perl & Solaris (Bradley Cain)
Re: Generating a randomly sorted list of integers <tchrist@mox.perl.com>
Re: Generating a randomly sorted list of integers <pwalters@portal.vpharm.com>
help on using CGI.pm (fish)
Re: help!: RE parse comma separated list (Tad McClellan)
Re: help!: RE parse comma separated list (Honza Pazdziora)
Help: matching with /RE/ and grep /RE/ are different! <Pierre.Bergdolt@ansf.alcatel.fr>
Re: How to sort blocks in a file? (Tad McClellan)
Re: How to sort blocks in a file? <is@groucho.dev.uga.edu>
Re: How to sort blocks in a file? (Honza Pazdziora)
Re: HTML Frame target (Nathan V. Patwardhan)
Re: Manipulating a file (efficiently) <dehon_olivier@jpmorgan.com>
Matching ! <osheam@logica.com>
Multiple actions after or <rdarnese@nortel.ca>
Output dynamic interactive graphical directory tree fro <real.carbonneau@nortel.ca>
perl 5 bug <peter@easics.be>
Re: Perl for X (Nathan V. Patwardhan)
Re: read/write file contents(new programmer) (Nathan V. Patwardhan)
Reloading/recalling a page basslerp@musu2.slu.edu
Re: Removing Tempfiles - a solution (Ken Williams)
System command <limpj@sterlingdi.com>
using \U and \L with edvEDV <jonas@cultcom.se>
VMS - PERL how do I sendmail in my form cgi? (Sirius )
Re: Which database in Perl? (Brian Jepson)
Re: Win95 can't always do this! ( Was: Re: Perl on Wind (Nathan V. Patwardhan)
Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 28 Feb 1997 09:49:13 -0500
From: ezust@learnix.ca (Alan Ezust)
Subject: Re: Class library to make C++ more Perlish?
Message-Id: <5f6r99$4te@sparky.learnix.ca>
In article <qumwwrttm47.fsf@cyclone.stanford.edu>,
Russ Allbery <rra@cs.stanford.edu> wrote:
>In comp.lang.perl.misc, Matt Austern <austern@isolde.mti.sgi.com> writes:
>
>> I'd be interested in measurements showing that operator overloading
>> causes performance problems, by the way, especially if you've made those
>> measurements using recent SGI compilers. There's no good reason why
>> compilers shouldn't handle a function called operator*() just as well as
>> they handle a function called multiply(). My experience is that most
>> compilers do deal with overloaded operators fairly well, but I'm
>> entirely willing to believe that there are still some compilers out
>> there that have problems.
>
>I don't have hard numbers to throw at it off-hand; I had them at one
>point, but I don't have the necessary knowledge to defend them without a
>great deal of research to get caught up again, and you're correct that I
>haven't tried the new compilers. However, on the other hand, I feel like
>I should point out that you're almost stuck programming for g++ as the
>lowest common denominator these days if you want portability, since the
>language still hasn't stabilized very well.
>
There is no runtime penalty for using operator overloading. An operator is
just a function. If the function is inefficient, there will be runtime
penalties for calling the function.
The reason people often (mistakenly) say that operator overloading causes
performance hits is because a lot of commonly overloaded
non-side-effecting operators are inefficent.
I.e. When you do something like this
a = b + c
this kind of function would be less efficient than
a.add(b,c)
The first method requires you to return a temporary object (copy ctor),
and assign the result to "a" (assignment operator) in addition to doing the
actual addition.
The second method allows you to manipulate the destination object "a"
directly from inside the add function.
But if the function you write is efficient, it makes NO difference whether
it is an operator function or a regular function.
--
Alan Ezust, Senior Instructor ezust@learnix.ca Toronto, Canada
(416) 486-0596 x 225 (voice) http://www.learnix.ca (416) 486-1754 (fax)
-------------------------------------------------------------------------
"In cyberspace, no-one can hear you scream" -Zippy
------------------------------
Date: 28 Feb 1997 14:39:30 GMT
From: cain@stimpy.eecis.udel.edu (Bradley Cain)
Subject: Compiling problems: Perl & Solaris
Message-Id: <5f6qn2$h2@dewey.udel.edu>
I'm trying to compile Perl 5.003 under Solaris 2.5.1 with gcc 2.7.2.2. I've
read through the hints section, etc. (and yes, I have /usr/ccs/bin as the
first dir in my path)
I get these errors when running make tests:
BEGIN failed--compilation aborted at ./lib/posix.t line 13.
FAILED on test 0
lib/safe.......Can't load '../lib/auto/Safe/Safe.so' for module Safe: ld.so.1: ./perl: fatal: relocation error: symbol not found: main: referenced in ../lib/auto/Safe/Safe.so at ../lib/DynaLoader.pm line 140.
at ../lib/Safe.pm line 390
BEGIN failed--compilation aborted at ./lib/safe.t line 13.
FAILED on test 0
lib/sdbm.......Can't load '../lib/auto/Fcntl/Fcntl.so' for module Fcntl: ld.so.1: ./perl: fatal: relocation error: symbol not found: main: referenced in ../lib/auto/Fcntl/Fcntl.so at ../lib/DynaLoader.pm line 140.
lib/socket.....Can't load '../lib/auto/Socket/Socket.so' for module Socket: ld.so.1: ./perl: fatal: relocation error: symbol not found: main: referenced in ../lib/auto/Socket/Socket.so at ../lib/DynaLoader.pm line 140.
I also get some other errors, but they all concern dbm routines, so I'm not
worried. Is there anything to be done about the errors above? Is this
normal?
thanks,
brad
--
*******************************************************************************
brad@udel.edu * Brad Cain / N3NAF / Master's Program
cain@ee.udel.edu * University of Delaware Electrical Engineering
PGP key via finger * --Comp. Eng. / Communications / Networking---
------------------------------
Date: 28 Feb 1997 15:39:00 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Generating a randomly sorted list of integers
Message-Id: <5f6u6k$s4a$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
jan.b.schipmolder@lmco.com writes:
:- this line is a full line from the file; it's also "random"
:- since /usr/dict/words has one word per line, you now have a random word
That's hardly random: you are prejudiced towards longer lines.
Consider: you have a file with ten words of length 3 and ten words of
length 15. Your file contains 5/6th of its bytes as long lines, and
only 1/6 of its bytes as short lines, even though half the lines are
long and half are short.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
It's all magic. :-) --Larry Wall in <7282@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: Fri, 28 Feb 1997 08:14:10 -0800
From: Pat Walters <pwalters@portal.vpharm.com>
Subject: Re: Generating a randomly sorted list of integers
Message-Id: <33170452.167E@portal.vpharm.com>
Stephen Frost wrote:
> I needed to write some code to produce a randomly sorted list of
> integers (between "1" and "n"). This I have done, but I am not
> at all happy with the amount of code that was required, nor with
> the performance implications of the way I've gone about it. It
> works just dandy (and fast enough) with 1->99 or thereabouts, but
> if I were to use it with 1->999 or 1->9999 it would probably die
> a horrible death.
Here's what I do. Seems to work find with very large lists.
#!/wherever/perl
$max = $ARGV[0] || 10;
srand(time() ^ ($$ << 15));
for ($i = 0; $i < $max; $i++)
{
push(@list,$i);
}
dump_list(@list);
shuffle(@list);
dump_list(@list);
sub shuffle
{
my ($i,$ran,$tmp);
for ($i = $#_; $i > 0; $i--)
{
$ran = int rand $i;
$tmp = $_[$i];
$_[$i] = $_[$ran];
$_[$ran] = $tmp;
}
}
sub dump_list
{
print join(" ",@_),"\n";
}
--
W. Patrick Walters, Ph.D.
Staff Scientist, Computational Chemistry and Molecular Modeling
Vertex Pharmaceuticals, Inc., 130 Waverley St., Cambridge, MA 02139
Voice: (617)577-6000 FAX: (617)577-6400
------------------------------
Date: 28 Feb 1997 15:30:58 GMT
From: gis84514@cis.nctu.edu.tw (fish)
Subject: help on using CGI.pm
Message-Id: <5f6tni$13i@news.cis.nctu.edu.tw>
Hello..
After examining the example files distributed with the CGI.pm,
I found that all the examples check the param and shows the results..
My questions is that I want to generate "a series of forms"..that is.
CGI CGI CGI
A_form ---> B_from ---> C_from --->D_from ---...
Can it be down using CGI.pm library????
Thanks a lot for your help....
------------------------------
Date: Fri, 28 Feb 1997 06:36:06 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: help!: RE parse comma separated list
Message-Id: <mfj6f5.ip.ln@localhost>
[ emailed, posted]
John Stumbles (suqstmbl@reading.ac.uk) wrote:
: I'm trying to extract data from a comma separated variable format file.
: Obviously dealing with foo,bar,wizz,bang is easy enough with split(/,/),
: but when there are commas within fields the field is quoted, like:
: foo,"barr,roseanne",wizz,bang
I guess you missed this in the Perl FAQ:
4.28) How can I split a [character] delimited string except when inside
[character]?
That's probably OK, 'cause the FAQ is really old, and Jeffrey
Friedl now recommends:
---------------------
@fields = ();
push(@fields, $+) while $text =~ m{
"([^\"\\]*(?:\\.[^\"\\]*)*)",? ## standard string, w/ possible comma
| ([^,]+),? ## anything else, w/ possible comma
| , ## lone comma
}gx;
## final empty field for trailing comma
push(@fields, undef) if substr($text, -1, 1) eq ',';
---------------------
Let's try it out on your sample data:
---------------------
#!/usr/bin/perl -w
foreach $text ( 'foo,"barr,roseanne",wizz,bang',
'foo,"bar,pub,tavern,hostelry",wizz,bang') {
@fields = ();
push(@fields, $+) while $text =~ m{
"([^\"\\]*(?:\\.[^\"\\]*)*)",? ## standard string, w/ possible comma
| ([^,]+),? ## anything else, w/ possible comma
| , ## lone comma
}gx;
## final empty field for trailing comma
push(@fields, undef) if substr($text, -1, 1) eq ',';
# see if it worked...
foreach (@fields) {
print "$_\n";
}
}
---------------------
Works for me.
: So... I converted all commas to tabs with s/,/\t/g and, before
: splitting on the tabs, converted back quoted fields with:
: s/"([^"]*)\t([^"]*)"/\1,\2/g;
: But this doesn't work for fields with multiple commas like:
: foo,"bar,pub,tavern,hostelry",wizz,bang
: This seems to call for some sort of recursive RE, which is beyond the
: level of wizardry I can safely practice. Can someone help?
^^^^^^^^^^^^^^^^
Jeffrey can! ;-)
: [Email copies of replies to newsgroup would be greatly appreciated as our
: news server sometimes finds itself at a null point in the usenet news
: space wave-function.]
OK.
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Fri, 28 Feb 1997 14:29:39 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: help!: RE parse comma separated list
Message-Id: <adelton.857140179@aisa.fi.muni.cz>
John Stumbles <suqstmbl@reading.ac.uk> writes:
> I'm trying to extract data from a comma separated variable format file.
> Obviously dealing with foo,bar,wizz,bang is easy enough with split(/,/),
> but when there are commas within fields the field is quoted, like:
>
> foo,"barr,roseanne",wizz,bang
>
> So... I converted all commas to tabs with s/,/\t/g and, before
> splitting on the tabs, converted back quoted fields with:
>
> s/"([^"]*)\t([^"]*)"/\1,\2/g;
>
> But this doesn't work for fields with multiple commas like:
> foo,"bar,pub,tavern,hostelry",wizz,bang
>
> This seems to call for some sort of recursive RE, which is beyond the
> level of wizardry I can safely practice. Can someone help?
This is an idea how you could do it, if the examples you gave are the
most difficult.
$" = ":";
while (<>)
{
@fields = m!("[^"]+"|[^,"]+)!g;
print "@s";
}
The regexp has two options: either the field starts with " and then it
can contain comma, or it starts with something different and then it
cannot.
Hope this helps.
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: Fri, 28 Feb 1997 16:07:32 +0100
From: Pierre BERGDOLT <Pierre.Bergdolt@ansf.alcatel.fr>
Subject: Help: matching with /RE/ and grep /RE/ are different!
Message-Id: <3316F4B4.41C6@ansf.alcatel.fr>
Hi there,
I have got a problem with a perl script that deal with rcs log file.
Consider the following example:
@reslog=`rlog $rcsfile`;
@lstrelfic=();
foreach $_ (@reslog) {
if (/^\s*revision\s+(\d+\.\d+)\s+.*$/) { push(@lstrelfic, $1); }
}
this give me a empty list for @lstrelfic (I expect a one element list
with "2.1" as value). A grep command with the same matching expression
give different result:
@matchingline=grep(/^\s*revision\s+(\d+\.\d+)\s+.*$/, @reslog);
give me the following result for @matchingline:
revision 2.1 locked by: adm_conf;
the @reslog in both case have the following value:
RCS file: /net/yoda/dsk3/gdc/arch/SNV2/se_outils/src/diff_liv,v
Working file: diff_liv
head: 2.1
branch:
locks: strict
adm_conf: 2.1
access list:
symbolic names:
P03L01D97022610: 2.1
P02L07D96101109: 2.1
comment leader: "# "
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
creation P02L07D96100910
----------------------------
revision 2.1 locked by: adm_conf;
date: 1996/10/09 09:00:46; author: adm_conf; state: Exp;
P02L07D96100910 2 96100910
=============================================================================
The line I try to match in first example is:
"revision 2.1 locked by: adm_conf;" in order to get "2.1" in my list.
Can anyone tell my why my first example doesn't work.
Thanks to answer me be e-mail.
--
-----------------------------------------------------------
Pierre Bergdolt Pierre.Bergdolt@ansf.alcatel.fr
Alcatel TELECOM
1 a 7, rue Ampere tel: 33 + 01.69.81.12.79
91300 Massy - FRANCE fax: 33 + 01.69.81.17.23
-----------------------------------------------------------
------------------------------
Date: Fri, 28 Feb 1997 07:21:11 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: How to sort blocks in a file?
Message-Id: <74m6f5.9v.ln@localhost>
tei hou (sp3102th@ex.ecip.osaka-u.ac.jp) wrote:
: I have a file which is divided into blocks by "##*##" line.
: Now i want to sort the blocks by its label, how can i do it
: with [g]awk or perl[45]?
You don't have a "sorting" problem.
You have a "reading in multi-line records" problem.
Once you get each record into an array, regular, vanilla sort
will do the trick.
: The format would be as below:
:
: #########################
: ## LABEL: Cfoo
: strings_1
: strings_2
: #########################
: ## LABEL: Afoo
: strings_3
: strings_4
: #########################
: ## LABEL: Bfoo
: strings_5
: strings_6
: I want the result:
: #########################
: ## LABEL: Afoo
: strings_3
: strings_4
: #########################
: ## LABEL: Bfoo
: strings_5
: strings_6
: #########################
: ## LABEL: Cfoo
: strings_1
: strings_2
If your record separators are always constant (as your sample data
shows), then you might want to look into the $/ 'input record
separator' special variable.
The solution below assumes only that the record separator is
three # chars at the beginning of a line:
-------------------
#!/usr/bin/perl -w
while (<DATA>) {
if ( /^###/ ) { # start a new record
push(@orig, $rec) if $rec;
$rec = $_;
}
else
{ $rec .= $_ }
}
push(@orig, $rec); # get the last record too
@sorted = sort @orig;
foreach (@sorted)
{print}
__DATA__
#########################
## LABEL: Cfoo
strings_1
strings_2
#########################
## LABEL: Afoo
strings_3
strings_4
#########################
## LABEL: Bfoo
strings_5
strings_6
-------------------
: Thanks for any help.
You're welcome.
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Fri, 28 Feb 1997 09:11:50 -0500
From: Bob Stearns <is@groucho.dev.uga.edu>
Subject: Re: How to sort blocks in a file?
Message-Id: <3316E7A5.167E@groucho.dev.uga.edu>
tei hou wrote:
>
> Hello,
>
> I have a file which is divided into blocks by "##*##" line.
> Now i want to sort the blocks by its label, how can i do it
> with [g]awk or perl[45]?
>
> The format would be as below:
>
> #########################
> ## LABEL: Cfoo
> strings_1
> strings_2
> #########################
> ## LABEL: Afoo
> strings_3
> strings_4
> #########################
> ## LABEL: Bfoo
> strings_5
> strings_6
>
> I want the result:
>
> #########################
> ## LABEL: Afoo
> strings_3
> strings_4
> #########################
> ## LABEL: Bfoo
> strings_5
> strings_6
> #########################
> ## LABEL: Cfoo
> strings_1
> strings_2
>
> Thanks for any help.
>
> tei hou
> sp3102th@ex.ecip.osaka-u.ac.jp
This is a three step process: separate the data and generate sort
keys/records; sort the data; put the data back the way it was. Thus we
have the shell script:
awk -f step1.awk datafile | sort | awk -f step3.awk > resultfile
where step1.awk is:
BEGIN { RS = "^#####*$" }
{ i = index($0,":")
key = substr($0,i+2)
gsub("\n","`",$0) # if "`" occurs in the data, choose any
# character which does not occur in it
print key " " $0
}
and step2.awk is:
{ i = index($0," ")
print "#########################"
gsub("`","\n",$0) # this must match the line in step1.awk
print substr($0,i+1)
}
There are several assumptions in the above code; the foremost is that
the key is a single "word"; ie string delimited by blanks. I have not
run this code and I know it will take at least nawk to run so if all you
have is awk, you will need to go get gawk or mawk.
--
Bob Stearns
University of Georgia
is@groucho.dev.uga.edu
(706)542-5110
------------------------------
Date: Fri, 28 Feb 1997 14:20:47 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: How to sort blocks in a file?
Message-Id: <adelton.857139647@aisa.fi.muni.cz>
sp3102th@ex.ecip.osaka-u.ac.jp (tei hou) writes:
> Hello,
>
> I have a file which is divided into blocks by "##*##" line.
> Now i want to sort the blocks by its label, how can i do it
> with [g]awk or perl[45]?
>
> The format would be as below:
>
> #########################
> ## LABEL: Cfoo
> strings_1
> strings_2
> #########################
> ## LABEL: Afoo
> strings_3
> strings_4
> #########################
> ## LABEL: Bfoo
> strings_5
> strings_6
>
> I want the result:
>
> #########################
> ## LABEL: Afoo
> strings_3
> strings_4
> #########################
> ## LABEL: Bfoo
> strings_5
> strings_6
> #########################
> ## LABEL: Cfoo
> strings_1
> strings_2
>
I have this solution, not claiming this is the most efficient but
should give some idea how to do it in perl:
#!/usr/bin/perl -w
use strict;
my $num = -1;
my @records = ();
while (<>)
{
if (/^#{6,}/)
{
$num++;
$records[$num] = '';
}
$records[$num] .= $_;
}
print sort { ( $a =~ /^## LABEL: (\w+)/m )[0] cmp
( $b =~ /^## LABEL: (\w+)/m )[0]; } @records;
__END__
Hope this helps.
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: 28 Feb 1997 14:52:08 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: HTML Frame target
Message-Id: <5f6reo$34h@fridge-nf0.shore.net>
Lon Hosford (lon@hosfordusa.com) wrote:
: How do you have Perl5 generate an HTML page on client in an HTML frame
: target window?
I'm not trying to burst your bubble or ruin your enthusiasm, but I
must be frank with you: Perl has nothing to do with HTML or CGI
for that matter.
Luckily, there are three fine resources for you to peruse:
(1) comp.infosystems.www.authoring.cgi
(2) http://www.dejanews.com -> search the archives for the NG mentioned in #1
(3) http://www.perl.com/FAQ -> follow the links to the CGI assistance.
HTH!
--
Nathan V. Patwardhan
nvp@shore.net
"A stitch in time saves nine."
------------------------------
Date: 28 Feb 1997 17:07:23 +0100
From: Olivier Dehon <dehon_olivier@jpmorgan.com>
Subject: Re: Manipulating a file (efficiently)
Message-Id: <njz3eugnccj.fsf@jpmorgan.com>
lpa@sysdeco.no writes:
> I have to parse a file (and extract subparts of it). The file has the
> nice property of containing a table in the beginning, which can guide me
> directly to the exact position of relevant subparts into the same file.
> I.e. the beginning of the file looks like:
>
> file struct:
> PART1 5468,280;
> PART2 11826,630;
> PART3 24993,1350;
> PART4 38818,2095;
> end struct;
>
> the first number is the position of the first character of the relevant
> part. The following number is the line number (this number would actually
> be enough for me.
I would consider using the seek() function, which acts more or less like
the C fseek() function.
Look at the perlfunc manpage for a detailed explanation of this function.
Hope this helps.
Regards,
Olivier.
------------------------------
Date: 28 Feb 1997 15:05:20 GMT
From: "Matthew O'shea" <osheam@logica.com>
Subject: Matching !
Message-Id: <01bc2588$91f58d20$e022ea9e@P01223.logica.co.uk>
I am writting a simple search engine locate appropriate files given a user
entered Key word.
Its all going fine except when I enter "c++" the code falls over - as it
appears to try and Increment the search criteria.
My code stands as follows:
-----------------------------------------
while(<CONTENTS>)
{
local($AbsentFlag) = 0 ;
$LineCount++ ;
($filename, $keywords, $description) = split(/:/,$_) ;
if ($logic eq "or")
{
foreach $QueryWords (@QueryWords)
{
if (/\b$QueryWords\b/i)
{
$HitCount++ ;
$found=1 ;
$BidDetails{$filename} = $description ;
}
}
}
# And Logic - make sure all words exist in Bid keywords
else
{
foreach $QueryWords (@QueryWords)
{
if ((/\b$QueryWords\b/i))
{
# Do Nothing - We're only interested in missing data
}
else
{
$AbsentFlag = 1 ;
}
}
if ($AbsentFlag == 0)
{
$HitCount++ ;
$found=1 ;
$BidDetails{$filename} = $description ;
}
}
}close CONTENTS ;
Can Anyone help ?
--
Kindest Regards
Matthew O'shea
------------------------------
Date: 28 Feb 1997 15:49:42 GMT
From: Richard Arnesen <rdarnese@nortel.ca>
Subject: Multiple actions after or
Message-Id: <5f6uqm$93v@nrtphc11.bnr.ca>
Lets say I have a statement where after the first part of it I have an or.
Within the or I want to print something to STDERR and then set a variable.
Unfourtanetly I have for some reason been unable to get this to work
because of syntax.
Any help would be appreciated.
--
Richard D. Arnesen Jr. - Unix DCA Support, Nortel, RTP
----------------------------------------------------------------
"..but I now know who he is, and what he is. There is nothing he
won't do, he is immune from shame...you find absolutely nothing,
nothing but an appetite" - Jesse Jackson speaking of Bill Clinton
----------------------------------------------------------------
The opinions stated above are mine and not that of Nortel
------------------------------
Date: 28 Feb 1997 15:52:19 GMT
From: "Real Carbonneau" <real.carbonneau@nortel.ca>
Subject: Output dynamic interactive graphical directory tree from perl to html
Message-Id: <01bbf4d6$7bb8ade0$0702402f@bmtli7>
For the purpose of easy navigation of documents, and simple maintainability
of an information repository, a dynamically outputed interactive graphic
directory tree would be very practical. The idea would be to have an
interactive (you could click on the directory you want to explore and the
directory tree would be expanded) directory tree, but that would only
diplay the file from a specified directory and on. Maybe even have an
index.html in each directory that would be the description which would get
outputed for the current directory. Maybe even get fancy and have the tree
to the right and the description and the files to the left, also have it
detect the file type, if it's an image and put an image reference
tag...etc..
Maybe I'm just dreaming?
If anyone has any ideas please post of maito:real.carbonneau@nortel.ca
Thank you in advance for any help.
Real Carbonneau
------------------------------
Date: Fri, 28 Feb 1997 15:20:57 +0100
From: Peter Sels <peter@easics.be>
Subject: perl 5 bug
Message-Id: <3316E9C9.62319AC4@easics.be>
Hello,
With Perl5 I get uninitialised variable errors that give wrong line
numbers back when I use (els)if constructs.
When the uninitialised error is in the (els)if body the line number in
the error message is the line number of the line the (els)if condition
is on.
can be annoying...
Example:
my $Yohoo;
if (someCond)
{
}
elsif (otherCond) # line 10
{
print $Yohoo; # line 12
}
When no assignment is made to $Yohoo, we get an error:
Use of Uninitialized value at Prog line 10
So it gives the incorrect line number. :(
If we change the above to:
my $Yohoo;
if (someCond)
{
}
elsif (otherCond) # line 10
{
print $Yohoo; # line 12
print $Yohoo; # line 13
}
We get back:
Use of Uninitialized value at Prog line 12
Use of Uninitialized value at Prog line 13
which are the correct line numbers indeed. :)
Could you correct this, Larry?
cheerio!
Peter
--
===================================================================
Peter Sels === Easics ===
ASIC Designer === VHDL-based ASIC design services ===
mailto:peter@easics.be ===================================
Tel: +32-16-298 405 Kapeldreef 60, B-3001 Leuven, BELGIUM
Fax: +32-16-298 319 http://www.easics.com
personal homepage: http://users.ox.ac.uk/~kebl0341/
------------------------------
Date: 28 Feb 1997 14:29:11 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Perl for X
Message-Id: <5f6q3n$34h@fridge-nf0.shore.net>
Ken Schrock (kens@cannet.com) wrote:
: I have heard references to Perl\Tk...
: Does such a thing exist?
Yes, it's alive and kicking, and covered in the newsgroup
comp.lang.perl.tk!
You can find pointers to the FAQ on http://www.perl.com/perl
HTH!
--
Nathan V. Patwardhan
nvp@shore.net
"A stitch in time saves nine."
------------------------------
Date: 28 Feb 1997 14:47:41 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: read/write file contents(new programmer)
Message-Id: <5f6r6d$34h@fridge-nf0.shore.net>
Zahid R. Naqvi (zrnaqvi@mailbox.syr.edu) wrote:
: I am a new PERL programmer and perhaps this is a very basic question.
: Anyway how can I look for a specific string in a file, and then add some
: text immediately after I find the text. I have been using "tell" and
: "seek" but I just can't get it right.
Ahh, you need the Perl FAQ. :-)
http://www.perl.com/FAQ -or- check this group's archives at
http://www.dejanews.com
There are various ways to do this:
(1) Open your file in read/write mode +< - caveats - (1)if the file does
not exist, the open will fail, (2) by reading the writing the same file,
you can easily bite yourself in the behind. ;-)
(2) Open your file in read mode, and output new data to a temp file.
Rename the tempfile to the newfile (once you're convinced that
your program is working correctly).
Here's a rough (an ahhh do mean rough) example using read/write:
Textfile contains:
moo cow
rabid dogs
ozzy osbourne is a fat satanist
insert after me
last line in file
The script:
#!/usr/local/bin/perl5
$file = 'line.txt';
open(INFILE, "+<$file") || die("No: $!");
@lines = <INFILE>; ### slurp into array
seek(INFILE,0,0); ### start a zero'th position of file
foreach $line (@lines) {
print INFILE $line; ### put lines back into the file
if ($line =~ /insert/) { ### we've found our tag to insert
print INFILE "new text here\n"; ### insert the new stuff after it
}
}
close(INFILE);
--
Nathan V. Patwardhan
nvp@shore.net
"A stitch in time saves nine."
------------------------------
Date: Fri, 28 Feb 1997 10:01:22 -0600
From: basslerp@musu2.slu.edu
Subject: Reloading/recalling a page
Message-Id: <857145365.9404@dejanews.com>
First and foremost, my apologies if I should have posted this to
one of the cgi newsgroups. While I know people around here can get
awfully edgy about this (understandably so), my best guess was that it fit
here as well as it would anyplace else.
My question/problem is this. A PERL script I am developing spits up a web
page that has a number of radio button-based selections for a particular
user (whose information had been read from a number of databases). At
this point, the user can check off the items that he no longer wants and
hits submit, at which time the database(s) is/are updated, and the page is
reloaded with the updated selections (the script calls another subroutine
within itself each time a user submits). Anyway, every time you submit
the page and it is reloaded, the browser sees this is a completely new
page, and not as simply as a "reloaded" page. So, if you would happen to
go through this process 20 times of resubmitting info, you'd have a
history on your "go listing" on Netscape (for example) of 20 visits to
this page, and only the last page hit being the correct, updated page.
At this point, you can probably guess what my question will be, which is:
is there any way for this page to be loaded as what the browser would
consider the "same page"? Is this even possible?
Thanks in advance, and I'll try to post more info if needed.
Ryan Bassler -> basslerp@musu2.slu.edu
LMP web page -> http://www.prairienet.org/~bassler
Become an LMP Pod - get your CD copy of "Aunt Canada" now!
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Fri, 28 Feb 1997 09:59:28 -0500
From: ken@forum.swarthmore.edu (Ken Williams)
Subject: Re: Removing Tempfiles - a solution
Message-Id: <ken-2802970959280001@news.swarthmore.edu>
In article <331663AC.FF6D5DF@india.ti.com>, Ajitesh Das
<baku@india.ti.com> wrote:
> Ken,
> I have comment regarding this. Do we really need temp files
> at all. In most of the cases I have found, we can avoid using
> fork() and/or pipes.
> What do you say ?
Well, in my case I don't know a good way around it. The reason I'm using
a temporary file is that I've got a database that lots of people may try
to read from and write to simultaneously. Opening a file for write access
blocks anyone else from opening the file for read or write access, but
arbitrarily many people should be able to read from the file at once.
The solution I came up with was to use a combination of file locking and
tempfiles. When somebody opens the file for read/write access, they
simply open it and place an exclusive lock on it (using flock). When
somebody opens the file for read-only access, they check to see whether
the file has an exclusive lock on it, and if not they copy the file to a
temporary file and start reading from that.
The obvious solution to this problem would have been to simply use a
shared lock for the read-only cases. The problem is that my read-only
users typically keep the file open for a really long time, and they block
all write access during that period. Read/write users keep the files open
for a comparatively short time. I thought that copying these files to a
tempfile would be prohibitively slow, but that has turned out not to be
the case.
Another solution (which I tried) would be to use the tempfiles for the
read/write folks. The reason this wasn't so great was that after the user
is done writing to their tempfile, they must then replace the original
database with the tempfile. When they do this, they obliterate the
ownership of the database. This wasn't acceptable, and I didn't want to
run a setuid script.
Anyway, this is where I am. I'm fairly happy with the current status of
my program, but of course I welcome ideas and suggestions too.
-Ken Williams
The Math Forum
ken@forum.swarthmore.edu
------------------------------
Date: Fri, 28 Feb 1997 11:16:42 -0500
From: Patrick Lim <limpj@sterlingdi.com>
Subject: System command
Message-Id: <331704EA.1073@sterlingdi.com>
We are having a problem with a perl script using
the system command/function, in conjunction with
a CGI. We are doing a system command of a shell,
passing it some arguments to process.
If we test the script from the UNIX command line,
the exit status is 0, as we want. If we run it
as a CGI, we get an exit status of 1.
Example:
$rc = system(test.sh '"Test guy"' '"phone number"');
>From the command line, rc is 0. From a CGI,
rc is 0x100 (which is exit status 1).
Why are we getting this?
Thanks in advance,
Patrick Lim
limpj@sterlingdi.com
Cathy Colavito
colavich@sterlingdi.com
------------------------------
Date: Fri, 28 Feb 1997 13:26:32 -0800
From: Jonas Liljegren <jonas@cultcom.se>
Subject: using \U and \L with edvEDV
Message-Id: <33174D88.31DF@cultcom.se>
In the Camel book (2:nd ed) page 76 I read:
"if you want to change your text to uppercase or lowercase, it's better
to use the \U or \L sequences in a double-quoted string, since they will
pay attention to locale information, but tr/a-z/A-Z/ won't."
How do I set this locale information? I wold like "\ueke" translate to
"Eke".
--
/ Jonas Liljegren
http://w3.adb.gu.se/~a95jonas/welcome.html
Geek Code 3.1 GIT/P/Od-s+:-a24C++US++P++LEW++N++
o?K?w!oM!VPSPE-Y--PGP-t+5X++R@tv+b+!DID++Geh!!r!y+
------------------------------
Date: Fri, 28 Feb 1997 16:19:34 GMT
From: sirius@getsirius.com (Sirius )
Subject: VMS - PERL how do I sendmail in my form cgi?
Message-Id: <5f70ht$9cj@unix.midplains.net>
I am trying to modify a perl form handling script. The server is on a
VMS machine. I can not get the part of the form that does the
"sendmail" function. Can anybody tell me how to go about this? The
form method is "post" if that makes a difference.
This is what I have and I think it opens up the mail file but can not
close it. I think that if I knew how to output a <CTRL-Z> in my print
statements I could close the file and do what I need. Or maybe you
know just how to do this with perl on vms? Help!
} else { # production mode. Send mail to mail.
if ( !open(MAIL, "|$mail_program") ) {
print &error_page ($message);
exit;
}
print MAIL <<"EOM";
To: $email_address
Subject: $subject
\n\n$message
\n.\n
EOM
close (MAIL);
}
}
Hey...don't laugh. I am a total beginner at this.
Thanks, Chuck
------------------------------
Date: 28 Feb 1997 15:44:56 GMT
From: bjepson@crd03.ny.jpmorgan.com (Brian Jepson)
Subject: Re: Which database in Perl?
Message-Id: <slrn5hdv8v.mts.bjepson@crd03.ny.jpmorgan.com>
In article <33158420.54521@news.demon.co.uk>, Guy Saner wrote:
>I am programming an online database system in Perl. I have found several
>modules for accessing databases, but I am unsure about which
>is best. My requirements are:
>
>Between 2000 - 6000 records
>Fully searchable under any field.
>Ability to write and read records.
>
>If anyone has suggestions about which modules I should use or what
>database structure is best, I would be very grateful for any response.
>
>Thanks in advance
>
>Guy Saner
This sounds like a perfect job for mini-SQL. Check it out at:
http://hughes.com.au
mini-SQL is a lightweight database engine which runs on Unix, OS/2,
and Win32. mSQL is shareware for commercial purposes, and free for
certain noncommercial purposes. The MsqlPerl module, available at:
http://www.perl.com/CPAN/modules/by-module/Msql
Should build fine on Unix and provides a nice way to get at miniSQL
data from Perl.
I've got a live example of my Msql::RDBMS package (available from
CPAN in the same directory as MsqlPerl) at:
http://www.ids.net/~bjepson
There's also a work-in-progress of an online tour engine which is backed
by mini-SQL and MsqlPerl at:
http://users.ids.net/~bjepson/wander/room.cgi?mp_id=1
There's a whole front-end for the data entry that I'm considering
making available for demo purposes. I'm just worried that Randal will
indulge in his habit of installing pictures of the Purple One :-), since
it allows an administrator to upload images for each room. If anyone is
interested in looking at this portion of the system, send me an email at
bjepson@conan.ids.net, and I'll give you the URL and password.
P.S. your Followup-To: was set to *. I'm not sure what this would have
done under my newsreader, but I don't want to find out, so I set it
to comp.lang.perl.misc.
Cheers,
--
Brian Jepson * (bjepson@ids.net) * http://www.ids.net/~bjepson
Int(ra|er)net Database Developer, Author, Crypto-Fluxologist
Non-Prophet Arts Technology Flux: http://www.ids.net/~as220
WWW/Database/NT,Java/Database: http://www.ids.net/~bjepson/books
------------------------------
Date: 28 Feb 1997 14:27:24 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Win95 can't always do this! ( Was: Re: Perl on Windows 95)
Message-Id: <5f6q0c$34h@fridge-nf0.shore.net>
Glenn Stanton (gms@lucent.com) wrote:
: >Exactly. It was broken in NTPerl PL 110, but fixed in 5.003_07.
: the problem isn't 5.001m, it's Window 95. because Win95 can't spawn
: the second connection/socket, your CGI will fail even though the command
Interesting. I've been using OmniHTTPd and NT Perl 5.003_07 and basic
socket stuff seems okay. I'm yet to know if this works with more complex
programs.
--
Nathan V. Patwardhan
nvp@shore.net
"A stitch in time saves nine."
------------------------------
Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Jan 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.
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 30
************************************