[8795] in Perl-Users-Digest
Perl-Users Digest, Issue: 2412 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 24 14:07:54 1998
Date: Fri, 24 Apr 98 11:00:41 -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 Fri, 24 Apr 1998 Volume: 8 Number: 2412
Today's topics:
Re: Are there things NOT answered yet ? (John Stanley)
Re: Array / List question <jdporter@min.net>
Array of Hashes malhotra@ap.org
Re: Array of Hashes <br@ndon.com>
Auto-generate HTML Tables johnvv@earthling.net
Re: beginnings.... on windows 95 <camerond@mail.uca.edu>
Re: best way to find disk space for a directory (Ken Fox)
Bug in list assign? <jdf@pobox.com>
Re: BUG or FEATURE? -- splice() doesn't extend arrays <mikec@cnet.com>
Re: BUG or FEATURE? -- splice() doesn't extend arrays <mikec@cnet.com>
Re: C from perl <bw@pindar.com>
Re: Can I have a C++ program call a Perl program? (Andrew M. Langmead)
Re: commenting a whole block? (Abigail)
Re: Defending Perl <jdporter@min.net>
Re: dynamically creating a hash of hashes, reading keys <jdf@pobox.com>
foreach question (Gilly (kEQNql))
Re: Free http perl cgi windows95 practice platform <carton.lao@shaw.wave.ca>
Re: help <jrs@hermes.beltc.ctc.edu>
Just a thought... (Ed Jamison)
Re: Just a thought... (Ed Jamison)
Re: Just a thought... <jdporter@min.net>
Re: module usage (Leslie Mikesell)
newbie =~ question (Mr. Wobbet)
Re: newbie =~ question <kompas@galaxy.uci.agh.edu.pl>
Re: newbie =~ question (Andrew M. Langmead)
Perl on AS/400 Performance <lwoolsey@innovative.ca>
Re: Random Number Generation PERL 5.0 <rootbeer@teleport.com>
Re: removing spaces <jrs@hermes.beltc.ctc.edu>
Re: Retreiving the args from a exec cmd call withing pe <zenin@archive.rhps.org>
Re: RMS should be invited to O'Reilly's "Free Software <JYoungman@vggas.com>
Re: RMS should be invited to O'Reilly's "Free Software (Paul D. Smith)
Using module outside @INC without changing @INC (Peter Scott)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 24 Apr 1998 16:39:45 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Are there things NOT answered yet ?
Message-Id: <6hqf8h$539$1@news.NERO.NET>
In article <3540a727.67158101@news.spacestar.net>,
gaj <gjandl@rf.mnschoolbiz.com> wrote:
>On Fri, 24 Apr 1998 14:10:58 GMT, gjandl@rf.mnschoolbiz.com (gaj)
>wrote:
>>Unforch, if I'm not mistaken we've missed the deadline for our second
>>RFD, haven't we? <sigh> I'd surely like to see it come to pass...
I'd like to see it come to pass, too, just not by excluding people the
group is allegedly intended to help, and not by trying to shoehorn the
discussion over the next version of the proposal into 11 days.
As I recall, there was mention of it being ready to be posted three
weeks ago, but Russ, in his role as news.groups person, commented that
it would not be posted on a Friday because of the likelyhood it would
expire before people could read it on Monday. I thought this meant it
would be posted that Monday...
>My total lack of time perception is showing again: there are stil 45
>days left. <whew!> Sometimes I love it when I'm wrong!
Then you must really be loving this. There are just 14 days left until
the current discussion period expires. This is Friday, which means it
will not be posted today. Monday, there will be 11 days left. I am not
counting, but there is a handy automated posting in news.groups that
lists this information. It is posted under the subject "status of RFD"
or something similar.
------------------------------
Date: Fri, 24 Apr 1998 16:11:31 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Array / List question
Message-Id: <3540BB30.74B4@min.net>
A.P. wrote:
>
> Now I have a final?? question. Is there any context/type difference between
> @i and @i[0..$#i]? As a matter of fact I've understood that *in scalar
> context* @i amounts the number of elements of @i ($#i+1) but @i[0..$#i]
> amounts the value of the last element: $i[$#i]?Might someone comment on this?
What's to comment, other than that perl is both documented and
observed to behave that way?
John Porter
------------------------------
Date: Fri, 24 Apr 1998 11:56:55 -0600
From: malhotra@ap.org
Subject: Array of Hashes
Message-Id: <6hqg8n$l3a$1@nnrp1.dejanews.com>
Gurus,
I have an array made up of hashes, and would like to parse this array using
foreach. If I try
foreach %hashelem (@my_array)
I get a syntax error. I tried using
for ($i = 0; $i < $#my_array; $i++)
{
%hashelem = $my_array[$i]
print $hashelem{'some_key'};
}
I do not get the desired output. The only thing that works is
for ($i = 0; $i < $#my_array; $i++)
{
print $my_array[$i]{'some_key'};
}
I would prefer to get case 1 (foreach) working, and if not, atleast case 2
(%hashelem = $my_array[$i])
Any and all help appreciated.
Thanx,
Raj.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Fri, 24 Apr 1998 13:05:22 -0400
From: Brandon Golm <br@ndon.com>
To: malhotra@ap.org
Subject: Re: Array of Hashes
Message-Id: <3540C652.6158E94C@ndon.com>
malhotra@ap.org wrote:
>
> Gurus,
>
> I have an array made up of hashes, and would like to parse this array using
> foreach. If I try
>
> foreach %hashelem (@my_array)
howabout:
@a = ({
one => '1',
two => '2',
},{
bob => 'jones',
sam => 'davis',
}
);
foreach $e (@a) {
foreach $key (keys %$e) {
print "$key $$e{$key}\n";
}
}
>
> I get a syntax error. I tried using
>
> for ($i = 0; $i < $#my_array; $i++)
> {
> %hashelem = $my_array[$i]
> print $hashelem{'some_key'};
> }
>
> I do not get the desired output. The only thing that works is
>
> for ($i = 0; $i < $#my_array; $i++)
> {
> print $my_array[$i]{'some_key'};
> }
>
> I would prefer to get case 1 (foreach) working, and if not, atleast case 2
> (%hashelem = $my_array[$i])
>
> Any and all help appreciated.
>
> Thanx,
>
> Raj.
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Fri, 24 Apr 1998 11:12:06 -0600
From: johnvv@earthling.net
Subject: Auto-generate HTML Tables
Message-Id: <6hqdkm$fce$1@nnrp1.dejanews.com>
Hello all,
I have been making really groovy reports based on the HP glance product while
using MLDBM and Freeze/Thaw ( or REFER, I like trucks and rednecks, more on
that later ) and have been displaying with gnuplot and Gifgraph ( which I
would very much like to see integrated ) garnished with bezier and linear
regression.
The static output (num of disks, cpus, memory ) files look very nice in
tables
within tables for the doubled bevel look and my question is this.
Has anybody created a script which automagically genetrates tables from
complex structures or flatfiles. I would be very nice to HREF the cells in
the process.
Its been two years since I touched cgi, I'll have more later.
Thanx in advance, John van V. aka johnvv@hotmail.com or johnvv@earthling.net
passme
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Fri, 24 Apr 1998 11:07:54 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: beginnings.... on windows 95
Message-Id: <3540B8DA.2A164B19@mail.uca.edu>
OK, Dan, let's fix what you wrote here:
Dan Baker wrote:
>
> Kevan wrote:
> >
> > Where do I begin? I've read the FAQ's etc before posting, but I still
> ...
> > I need to get Perl and install it onto a Windows 95 machine.
> ----------------------
>
> I'm working on a similar thing, so this is kind of the blind leading the
> blind. Here is some info I've rounded up so far:
>
> Q: what version of perl do I need to run on win95
> A: At the time this was written v5.004_04 was the latest version
> available.
5.004_04 is NOT available for a Win32 system (at least already
precompiled and zipped). So, unless you want to compile Perl yourself
(which doesn't seem to be either of your desires), get 5.00402 from
http://www.perl.org/CPAN/authors/Gurusamy_Sarathy/perl5.00402-bindist04-bc.tar.gz
(or the equivalent from www.perl.com).
> Q: Are there any tricks to installing Perl in win32?
> A: well, there are a few things to watch out for:
> - extract the .zip to any temp directory, it will expand everything
> including a bunch of patches and stuff you don't need and can delete
> later.
> - when you install, specifiy the directory as c:\usr so that you can use
> the standard UNIX #! /usr/bin/perl header in your programs to find perl.
The shebang (#!) line is ignored on a Win32 system, except for any flags
which you add to the end (-w, always), so there is no point in setting
c:/usr as the root (BTW, it would have to point to c:\usr\etc, anyway,
if it was active). You have to associate perl with suffixes in the
Registry to use it from another program (such as a server) and to do
this, follow the directions in the Perl for Win32 FAQ (found on your HD
after you install Perl).
> [snip] You can edit your
> autoexec.bat with the sysedit tool, and insert a line giving the path to
> the perl.exe file like:
> path %path%;C:\usr\bin;
or whatever (see above)
> - You have to manually associate *.pl files to execute Perl. Under
> "windows explorer" select VIEW and then OPTIONS and add a file type .pl
> to exec c:\perl\bin\perl.exe when selected.
Follow the directions at http://hjs.geol.uib.no/Perl/index6.html-ssi,
there is a little more to it than the above.
> - don't forget to go back and delete the temporary source installation
> directory.
If you unzip the file with Winzip, it already takes care of that.
> Q: What do I need to get on my windows95 machine to test HTML-cgi-perl
> applications?
> A: You need to have a webserver running locally to handle the
> transactions between the browser, forms, cgi, and perl. there are a few
> sources for free webservers:
> http://www.imatix.com/html/xitami/ - small, free, and runs cgi!
> http://www.microsoft.com/ie/pws/default.htm - HUGE, requires tons of
> space, memory, etc.
> http://www.apache.org - reports that beta runs on win95
Or, simply go to http:www/tucows/com and find one of those or several
other free servers for Win95 (Omnihttpd, Apache, Sambar, Xitami,
Netscape (since the original poster is at an academic institution)
others which I can't remember). Advice I hear over and over again is to
avoid M$ PWS.
>
> Dan,
> remove _ from replyTo for email
Nope, read the newsgroup for the reply and use a spam filter for your
email.
Cameron
camerond@mail.uca.edu
------------------------------
Date: 24 Apr 1998 16:07:29 GMT
From: kfox@pt0204.pto.ford.com (Ken Fox)
Subject: Re: best way to find disk space for a directory
Message-Id: <6hqdc1$72i3@eccws1.dearborn.ford.com>
James Richardson <jamesr@aethos.co.uk.nospam> writes:
> Ronald J Kimball <rjk@coos.dartmouth.edu> wrote:
> > Alex Krohn wrote:
> > > 2. use find to get a list of files and then loop through and stat each
> > > one to get the file size.
> >
> > Painful. Watch out for symbolic links.
>
> Definately dont use du.
Use du if you don't care about being portable. du might be
optimized on your platform -- you might as well use what's
already there.
> Use opendir/readdir/stat/lstat
>
> Something like this may get you started...
>
> [a really long script using opendir/readdir/stat/lstat deleted]
If you really want to "roll your own" implementation of du, at
least start with something that works. Here's how to use the
shipped-with-perl module File::Find.
use File::Find;
my $total = 0;
find(\&wanted, '.');
print "$total\t.\n";
sub wanted {
my @info = lstat;
if (@info) {
$total += $info[12];
}
}
- Ken
--
Ken Fox (kfox@ford.com) | My opinions or statements do
| not represent those of, nor are
Ford Motor Company, Powertrain | endorsed by, Ford Motor Company.
Analytical Powertrain Methods Department |
Software Development Section | "Is this some sort of trick
| question or what?" -- Calvin
------------------------------
Date: 24 Apr 1998 12:38:41 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Bug in list assign?
Message-Id: <1zunt90e.fsf@mailhost.panix.com>
Am I insane, or is this a bug?
$n = (($foo) = qw(a b c)); # $n should get 3, no?
print "$n\n"; # prints "2"
This happened to me using GSAR's Win32 bindist, so I tried it on one
of my Unices running 5.00404, and it happened there too. Am I going
mad? Isn't list assignment in a scalar context supposed to evaluate
to the number of elements in the RHS of the assignment?
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Fri, 24 Apr 1998 08:56:42 -0700
From: Mike Clemens <mikec@cnet.com>
To: Aaron Harsh <ajh@rtk.com>
Subject: Re: BUG or FEATURE? -- splice() doesn't extend arrays
Message-Id: <3540B63A.CB28D0D3@cnet.com>
Aaron Harsh wrote:
>
>
> It would cause some code I wrote last week to break:
>
> @thingies = sort get_thingies();
> @top_ten_thingies = @thingies;
> splice @top_ten_thingies, 10;
>
> If splice was "fixed" I might end up with undefs in my array (if there are
> fewer than 10 thingies).
Actually, no. According to the docs., this would still work with a
corrected splice:
[Quoting from man perfunc]
splice ARRAY,OFFSET,LENGTH,LIST
splice ARRAY,OFFSET,LENGTH
splice ARRAY,OFFSET
Removes the elements designated by OFFSET and LENGTH
from an array, and replaces them with the elements
of LIST, if any. Returns the elements removed from
the array. The array grows or shrinks as necessary.
If LENGTH is omitted, removes everything from OFFSET
onward.
[snip]
The following equivalences hold (assuming $[ == 0):
push(@a,$x,$y) splice(@a,$#a+1,0,$x,$y)
pop(@a) splice(@a,-1)
shift(@a) splice(@a,0,1)
unshift(@a,$x,$y) splice(@a,0,0,$x,$y)
$a[$x] = $y splice(@a,$x,1,$y);
The last equivalence is broken: here's some code...
#!/usr/local/bin/perl
@a1 = qw(A B C);
@a2 = qw(A B C);
$x = 10;
$y = 'Z';
$a1[$x] = $y;
splice(@a2,$x,1,$y);
print "These should be the same-> ";
print join(":",@a1)," and ",join(":",@a2),"\n";
#EOF
Outputs...
These should be the same-> A:B:C::::::::Z and A:B:C:Z
The little camel in my head is whispering "it's a bug." Aaron, I think
you're taking (unfair!) advantage of this bug: if you want the top ten
thingies, you should leave your code as written. If you want the top N
thingies, where N <= 10, then...
#!/usr/local/bin/perl
@thingies = sort qw(Z X W A B C); # Try adding more than 10 elements
here
@top_ten_thingies = @thingies;
$max = 10 unless (($max = $#thingies + 1) < 10); # NEW
splice @top_ten_thingies, $max; # CHANGED
print join(":",@top_ten_thingies),"\n";
# EOF
$max gets assigned to 10 only if there are more than 10 elements in
@thingies.
Off to perlbug for me!
- Mike
--
Michael P. Clemens mailto:mikec@cnet.com Senior Software Engineer
http://www.cnet.com (415) 395-7805 x5137 CNET: The Computer Network
>>> Take a gander at my son: http://www.mindspring.com/~clemota/ian <<<
------------------------------
Date: Fri, 24 Apr 1998 09:12:21 -0700
From: Mike Clemens <mikec@cnet.com>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: BUG or FEATURE? -- splice() doesn't extend arrays
Message-Id: <3540B9E5.C105193F@cnet.com>
Tom Phoenix wrote:
>
> Well, splice has been this way as long as I can remember. :-) But it
> could still be construed as a bug. The docs say,
>
> The array grows or shrinks as necessary.
>
> (...although I'm sure that that wasn't intended to apply here.)
>
> I'd like to see this fixed. The problem I see is that, if we were to fix
> it now, it might cause some older program to break. :-P
This bug also breaks the last "equivalence" listed in the splice()
section of perlfunc. (See my respose to Aaron's post.) I've submitted
a bug report. *fingers crossed*
- Mike, "Damn the older programs, my code's not working NOW!"
--
Michael P. Clemens mailto:mikec@cnet.com Senior Software Engineer
http://www.cnet.com (415) 395-7805 x5137 CNET: The Computer Network
>>> Take a gander at my son: http://www.mindspring.com/~clemota/ian <<<
------------------------------
Date: Fri, 24 Apr 1998 15:04:36 +0100
From: "Bob Wilkinson" <bw@pindar.com>
Subject: Re: C from perl
Message-Id: <35409afd.0@nnrp1.news.uk.psi.net>
Go look at www.swig.org
SWIG enables the wrapping of C/C++ by various scripting languages (Perl
included)
Bob
Kaleem Siddiqi wrote in message <353F91EF.167EB0E7@cs.yale.edu>...
>I'm trying to interface C subroutines with perl using h2xs.
>I've been able to do some simple things such as call
>void functions, as well as functions whose arguments are
>passed by value.
>
>Can anyone point me to more interesting examples such as:
>1) A pointer to an array is passed, such that the array
>can be modified by the C subroutine. Also, is there some
>way of declaring perl arrays such that their types
>correspond with the assumed C types?
>
>2) Structures are passed back (and returned).
>
>Many Thanks!
>-----------------------------------------------------------------------
>Kaleem Siddiqi Dept. of Computer Science
>siddiqi-kaleem@cs.yale.edu Yale University
>Phone: (203) 432-4713 P.O. Box 208285, Yale Station
>FAX: (203) 432-0593 New Haven, CT 06520-8285
>
>http://www.cs.yale.edu/users/siddiqi-kaleem/
>-----------------------------------------------------------------------
------------------------------
Date: Fri, 24 Apr 1998 17:39:21 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Can I have a C++ program call a Perl program?
Message-Id: <ErxIDL.HsG@world.std.com>
Bryan T Hoch <bth@acsu.buffalo.edu> writes:
>Hi, I'm running a C++ program and i want to have it invoke a Perl program
>that i have written. I have the C++ program write to a file, then I want
>to call the Perl program to read from that file.
You have two things that you can do. You can either make the perl
program a separate program, and from your C++ program call the C
library function system() or popen() to run it. Or you can embed a
perl interpreter into your C++ program using the methods shown in the
perlembed and perlguts man pages.
>PS- is there anyway to pass parameters between the two programs?
If you use system(), just concatinate the arguments after the command
name, separated by whitespace. If you use the embedding method, you
can use the perl API to either create variables that perl can access,
or read variables that perl has created.
--
Andrew Langmead
------------------------------
Date: 24 Apr 1998 16:04:48 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: commenting a whole block?
Message-Id: <6hqd70$8oe$1@client2.news.psi.net>
Stuart Cooper (stuartc@ind.tansu.com.au) wrote on MDCXCIV September
MCMXCIII in <URL: news:yeo4szm3fhf.fsf@kudu.ind.tansu.com.au>:
++ abigail@fnx.com (Abigail) writes:
++
++ > Chris Nandor (pudge@pobox.com) wrote on MDCXC September MCMXCIII in
++ > <URL: news:pudge-1704981518550001@ppp-12.ts-1.kin.idt.net>:
++ > ++
++ > ++ Personally, I like:
++ > ++
++ > ++ =pod
++ > ++
++ > ++ comment();
++ > ++ out();
++ > ++ all_this_code();
++ > ++
++ > ++ =cut
++ >
++ >
++ > Yeah, but what if that section has a pod piece in it? ;)
++
++ Good point. Just like C comments, pod sections don't nest.
++
++ > Using an elegant editor:
++ > :x,ys/^/#/
++ >
++ > where x and y are the line numbers of the beginning and end.
++
++ Yeah, but like in many vi region operations, it's a pain having to
++ calculate the beginning and end numbers.
++
++ In Emacs (in the Perl Mode) select the region you wish to comment.
Of course, this works in vi as well. You just have to know vi.
Goto begin of region you want to outcomment, do
ma
Goto end of region you want to out comment and do
:'a,.s/^/#/
Alternatively, you can work with 2 markers.
Abigail
--
perl -pwle '$_ .= reverse'
------------------------------
Date: Fri, 24 Apr 1998 16:08:38 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Defending Perl
Message-Id: <3540BA83.2A4E@min.net>
Ilya Zakharevich wrote:
>
> Perl will run 200 times as slow as C for "most" things. This is
> confirmed by many independent benchmarks of different things.
This from the same man who baldly asserted (in private
correspondence) that <> (Perl) is faster than fgets (C).
It's not, by only by about 10 - 20 times.
John Porter
------------------------------
Date: 24 Apr 1998 12:08:57 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: dynamically creating a hash of hashes, reading keys/values from a file
Message-Id: <3ef3tady.fsf@mailhost.panix.com>
"Ing.Martin HEIN" <martin.hein@maxmobil.at> writes:
> My troubles are coming from dynamically setting up/building a hash of
> hashes, looking like
[snip]
> All things like 'key1', 'key2', 'val1', 'subkey1', ... are read from a
> file.
I couldn't find a specific question in your post, but I think that the
information you seek will be found in the following docs: perlref,
perllol, perldsc. Is there a particular part of your task that's
confusing, or is there perhaps some code you've written that isn't
working the way you expect?
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Fri, 24 Apr 1998 17:24:56 GMT
From: mingtian@hanmail.net (Gilly (kEQNql))
Subject: foreach question
Message-Id: <3540ca90.7777211@usenet.kornet.nm.kr>
foreach (sort (@filelist)) { .. }
Does it sort each time during the loop? or only once?
">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">
!F 1W4k 3*?!0T4B >pA&3* GQ<[@L 2I@L?4@84O 0q8q1f 59>F3*?@4B !F
"> 594c ?6?!<- H/Hw 9L<RA~0m @V4B 5i2I GQ<[@L?M55 00>F ">
!F H%@Z@V>n >5>5GQ 3*@G 0!=??! Hq8A@; @|GXAV4x 2I !F
">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">
------------------------------
Date: Fri, 24 Apr 1998 04:11:41 GMT
From: Carton Lao <carton.lao@shaw.wave.ca>
To: Mark Fynes <Mark.Fynes@cs.tcd.ie>
Subject: Re: Free http perl cgi windows95 practice platform
Message-Id: <35401148.57B6BCE@shaw.wave.ca>
Apache 1.3b3 runs fine on win95, and you don't need mod_perl to use perl
cgi scripts, it would just be slower.
make sure your perl cgi script starts with
#!D:\perl\perl.exe
where there is no spaces between ! and D
and substitute with your perl.exe full path name
Carton
Mark Fynes wrote:
> Hi,
>
> Can anyone recommend a freeware setup for testing / learning perl web
> programming ( through cgi )
> on the windows95 platform?
>
> I've had not success with mod_perl and apache as it requires winNT4
>
> Any suggestions would be most appreciated
> regards
> Mark Fynes
------------------------------
Date: Fri, 24 Apr 1998 10:03:36 -0700
From: "Jonathan R. Seagrave" <jrs@hermes.beltc.ctc.edu>
To: Inge Soetens <soetensi@se.bel.alcatel.be>
Subject: Re: help
Message-Id: <Pine.LNX.3.96.980424095551.2648B-100000@hermes.beltc.ctc.edu>
On Fri, 24 Apr 1998, Inge Soetens wrote:
> From a perl script I need to generate an HTML file
> which contains the following line :
>
> print "<INPUT NAME="GoOn" TYPE="submit" VALUE="Go On"> \n";
>
> This line gives a problem.
> Because there are "quotes" in between "quotes" ...
> Any solutions to this ?
there are several...
print qq|<input name="foo" type="submit" value="bar"> \n|;
the '|' character was chosen arbitratily... choose any character you like.
- or -
print '<input name="foo" type="submit" value="bar"> \n';
this one isn't as good as the last one because you can't say
print '<input name="$bard" type="sonnet" value="Shall I compare thee
to a summer's day?"> \n';
for more that one reason.
- or -
print "<input name=\"foo\" type=\"submit\" value=\"bar\"> \n";
but this, me thinks, is a touch ugly.
--
Get a copy of the camel book or the llama book... they're really good!
cheers
Jonathan
------------------------------
Date: Fri, 24 Apr 1998 16:01:30 GMT
From: edwardj.keepthespamthanks@torvalds.com (Ed Jamison)
Subject: Just a thought...
Message-Id: <MPG.faa72fd6a08fe189896bd@news.ais.net>
I had an interesting idea the other day. It's not really practical, but
I thought it would be interesting to find out what others had to say
about it...
Currently, time (in years) is kept track of in years since the birth of
Christ (somewhat accurately). Hence, we are now in the year 1998 A.D. I
thought it would be interesting to start with a new method of keeping
track, A.C. or A.U. This new method would begin on January 1, 1970 as 0
A.C. (After Computers, or Ante Computers; After UNIX, Ante UNIX). As I
said before, not really practical, but interesting. Computers can be
viewed as one of the most important inventions in the history of time and
they have done more to change the way things work on this planet than
just about anything I can think of. (With a few exceptions, of course;
electricity, engines, etc...)
I'm just curious what comments I could get from this.
Thanks,
Edward Jamison
------------------------------
Date: Fri, 24 Apr 1998 17:02:22 GMT
From: edwardj@torvalds.keepthespamthanks.com (Ed Jamison)
Subject: Re: Just a thought...
Message-Id: <MPG.faa8144dbf4098e9896c4@news.ais.net>
Long ago (Fri, 24 Apr 1998 16:34:51 GMT), in a land far far away,
jdporter@min.net spouted nonsense similar to this...
> Ed Jamison wrote:
> >
> > I had an interesting idea the other day. It's not really practical, but
> > I thought it would be interesting to find out what others had to say
> > about it...
> > Currently, time (in years) is kept track of in years since the birth of
> > Christ (somewhat accurately). Hence, we are now in the year 1998 A.D. I
> > thought it would be interesting to start with a new method of keeping
> > track, A.C. or A.U. This new method would begin on January 1, 1970 as 0
> > A.C. (After Computers, or Ante Computers; After UNIX, Ante UNIX). As I
> > said before, not really practical, but interesting.
>
> 1. If you just want to escape the hegemony of the Christian heritage
> over Western civilization, you would do better to adopt one of the
> dating systems already in use elsewhere in the world.
I don't view the current method of keeping time as religious as much as i
view it as a widely accepted method of keeping time, which was adopted
because of a major event. Why only have one such event? This could be
taken too far, where each major event is evaluated and we have a new 0
A.Something. every 4 years, but in this case I don't think it is such an
example. Since computers keep track of time starting Jan 1, 1970, I
think it would be an interesting idea to adopt a similar way of doing
so...
> 2. The 'A' in 'AD' stands for 'Anno', not 'After';
> 3. 'Ante' means 'before', not 'after'.
Thanks, I'm a little behind on my latin...
> 4. Worried about not enough bytes/nybbles/digits to hold the year
> part of the date? Then under your new system, 44 AD would be
> -1954. How many bytes will that take? Or don't you want to
> represent arbitrary years from the past?
This could be done any number of ways. When AD, BC were first introduced
someone had to make the decision to count backward from whatever to 0 and
then from 0 to 1998 and beyond. We would not discontinue to represent
these past years, we could just refer to them as BC, or something
similar, since that is already taken...
> 5. By "somewhat accurately", I assume you meant "not very accurately",
> right? A discrepancy of 4 to 8 years is not very accurate, imho.
Yes, I am aware that 0 BC, AD is quite inaccurate.
> John Porter
>
Edward Jamison
------------------------------
Date: Fri, 24 Apr 1998 16:34:51 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Just a thought...
Message-Id: <3540C0A7.244F@min.net>
Ed Jamison wrote:
>
> I had an interesting idea the other day. It's not really practical, but
> I thought it would be interesting to find out what others had to say
> about it...
> Currently, time (in years) is kept track of in years since the birth of
> Christ (somewhat accurately). Hence, we are now in the year 1998 A.D. I
> thought it would be interesting to start with a new method of keeping
> track, A.C. or A.U. This new method would begin on January 1, 1970 as 0
> A.C. (After Computers, or Ante Computers; After UNIX, Ante UNIX). As I
> said before, not really practical, but interesting.
1. If you just want to escape the hegemony of the Christian heritage
over Western civilization, you would do better to adopt one of the
dating systems already in use elsewhere in the world.
2. The 'A' in 'AD' stands for 'Anno', not 'After';
3. 'Ante' means 'before', not 'after'.
4. Worried about not enough bytes/nybbles/digits to hold the year
part of the date? Then under your new system, 44 AD would be
-1954. How many bytes will that take? Or don't you want to
represent arbitrary years from the past?
5. By "somewhat accurately", I assume you meant "not very accurately",
right? A discrepancy of 4 to 8 years is not very accurate, imho.
John Porter
------------------------------
Date: 24 Apr 1998 12:38:34 -0500
From: les@MCS.COM (Leslie Mikesell)
Subject: Re: module usage
Message-Id: <6hqimq$dqd$1@Mars.mcs.net>
In article <Pine.GSO.3.96.980424075558.5518V-100000@user2.teleport.com>,
Tom Phoenix <rootbeer@teleport.com> wrote:
>
>Of course, it's (virtually always) better to use a module which implements
>the proper algorithm - which is somewhat different than you describe.
>Other advantages to using a module: a module should be debugged (so you
>don't have to worry about mistakes in that part of the algorithm),
I haven't quite been convinced of the advantages of modules and
making one script depend on lots of other parts to do relatively
simple things. Perhaps I just don't know how to work with modules
correctly so I'm open to advice. The key phrase above is
'should be debugged'... What do you do when you have scripts
using nested modules that don't quite work, and if you need to
change an interface to fix them, how do you track down all of the
scripts on the system that are going to break as a result?
Les Mikesell
les@mcs.com
------------------------------
Date: Fri, 24 Apr 1998 16:00:16 GMT
From: wobbet@lbms.com (Mr. Wobbet)
Subject: newbie =~ question
Message-Id: <MPG.faa73431e8b7a64989688@news.phoenix.net>
i'm reading the camel book, 2nd edition and i get to page 81 where it
talks about binding operators (=~ and !~). one of the examples shown
is
if (($k, $v) = $string =~ m/(\w+)=(\w+)) {
print "key $k value $v";
}
the explanation is that =~ binds $string to the pattern match instead
of binding $_ to the pattern match. good, i like that.
then, it says that since this is evaluated in a list context because
it is on the right hand side of an assignment, if there is a match
then there will be a list assignment to $k and $v. i like that also.
then, the new list is evaluated in a scalar context and it returns the
number of elements in the list. if the assignment is performed the
value will be two and the values will be printed out. if the
assignment is not performed the value will be zero and nothing gets
printed. i also like that.
seeing this example, i decided to try something similar out in my own
code. i started out with:
$string = $hash{"key"} =~ m/myexpr/;
print $string;
i got "1" as the output and that is sort of obvious because it is
evaluating the pattern match in a scalar context and there was one
match and $string got the value of 1. so i changed it to say:
($string) = $hash{"key"} =~ /myexpr/;
print $string;
thinking that the rhs of the = would now be evaluated in list context.
but i still get "1" as the result. so my question, is the rhs of the =
_not_ being evaluated in a list context? if not, why not? have i
completely missed the boat here?
what i do have that works but i think is kind of ugly and probably not
the best way of doing things (i did say i was a newbie) is:
$string = $& if $_ = $hash{"key"} and /myexpr/;
any enlightenment would be greatly appreciated.
thanks,
rjsjr
------------------------------
Date: 24 Apr 1998 18:41:06 +0200
From: Piotr Piatkowski <kompas@galaxy.uci.agh.edu.pl>
Subject: Re: newbie =~ question
Message-Id: <6hqfb2$njg$1@galaxy.uci.agh.edu.pl>
Mr. Wobbet <wobbet@lbms.com> wrote:
: ($string) = $hash{"key"} =~ /myexpr/;
: print $string;
: thinking that the rhs of the = would now be evaluated in list context.
: but i still get "1" as the result. so my question,
: is the rhs of the = _not_ being evaluated in a list context?
Yes, it is.
: have i completely missed the boat here?
(what does this idiom mean? :-) ).
Actually, everything works fine, you've just forgot about parentheses
in your regexp :-)
quote from man perlop, under /PATTERN/...:
If used in a context that requires a list value, a
pattern match returns a list consisting of the
subexpressions matched by the parentheses in the
pattern, i.e., ($1, $2, $3...). (Note that here $1
etc. are also set, and that this differs from Perl
4's behavior.) If the match fails, a null array is
returned. If the match succeeds, but there were no
parentheses, a list value of (1) is returned.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
--
Piotr Pi1tkowski, Uczelniane Centrum Informatyki, AGH Krakow, POLAND
------------------------------
Date: Fri, 24 Apr 1998 17:46:42 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: newbie =~ question
Message-Id: <ErxIpu.MqE@world.std.com>
wobbet@lbms.com (Mr. Wobbet) writes:
>i got "1" as the output and that is sort of obvious because it is
>evaluating the pattern match in a scalar context and there was one
>match and $string got the value of 1. so i changed it to say:
> ($string) = $hash{"key"} =~ /myexpr/;
> print $string;
You forgot the parens around the group that you want to return.
($string) = $hash{"key"} =~ /(myexpr)/;
According to the perlop man page:
If used in a context that requires a list value, a
pattern match returns a list consisting of the
subexpressions matched by the parentheses in the
pattern, i.e., ($1, $2, $3...). (Note that here $1
etc. are also set, and that this differs from Perl
4's behavior.) If the match fails, a null array is
returned. If the match succeeds, but there were no
parentheses, a list value of (1) is returned.
--
Andrew Langmead
------------------------------
Date: Fri, 24 Apr 1998 13:54:56 -0400
From: "Les Woolsey" <lwoolsey@innovative.ca>
Subject: Perl on AS/400 Performance
Message-Id: <6hqk6c$nh$1@nr1.ottawa.istar.net>
I have a working Perl script that runs nice and quickly on Windows NT but on
an AS400 it crawls. The script puts out messages every so often and it runs
for a while then stops for 20 or 30 seconds then starts on again.
Anybody have any experience with Perl on an AS400 & any suggestions on
what's happenning.
Les
------------------------------
Date: Fri, 24 Apr 1998 16:10:58 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Reza Naima <newsgroups@reza.net>
Subject: Re: Random Number Generation PERL 5.0
Message-Id: <Pine.GSO.3.96.980424090501.5518c-100000@user2.teleport.com>
On Fri, 24 Apr 1998, Reza Naima wrote:
> open IN,"filename";
Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.
> @lines = <IN>;
> close IN;
>
> $line = $lines[int rand($#lines + 1)];
It would be simpler to write this...
$line = $lines[rand @lines];
...but if you wish to select just one line at random, it's more memory
efficient to avoid reading the entire file into memory.
> note, if you leave out the srand, it by default does a srand(time)...
No, this is not true in 5.004. In earlier versions of Perl, it's not
true for a different reason. Check the docs for srand.
> there are some other simple routines to increase the randomness,
No, there is no simple way to "increase the randomness" of rand in
Perl. (It could be replaced with a different generator, but that's another
matter.)
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 24 Apr 1998 09:54:54 -0700
From: "Jonathan R. Seagrave" <jrs@hermes.beltc.ctc.edu>
To: Inge Soetens <soetensi@se.bel.alcatel.be>
Subject: Re: removing spaces
Message-Id: <Pine.LNX.3.96.980424094704.2648A-100000@hermes.beltc.ctc.edu>
On Fri, 24 Apr 1998, Inge Soetens wrote:
> how can I remove all spaces from a line ?
> Suppose a line contains
> " blablabla "
> Is there a simple way to only get the "blablabla" ?
if, for example, $line = " blablabla ";
# globally substitute all white space characters with nothing
$line =~ s/\s//g;
- or -
# only take out leading and trailling spaces
$line =~ s/^\s+//g;
$line =~ s/\s+$//g;
There's most certainly a way to do this with one regex... but this was
the first thing that poped out of my fingers.
Jonathan :)
------------------------------
Date: 24 Apr 1998 16:41:57 GMT
From: Zenin <zenin@archive.rhps.org>
Subject: Re: Retreiving the args from a exec cmd call withing perl program
Message-Id: <893436558.183628@thrush.omix.com>
[posted & mailed]
Richard Newman <richard@phoneswitch.com> wrote:
: The call within the html looks like:
: <!--#exec cmd="/cgi-bin/test.shtml arg1 arg2 arg3" -->
You sure that's right? "test.shtml" doesn't look like a normal
program name. You sure you didn't meen "test.cgi", or just "test"?
Also, do you understand the differences between the "#exec cmd" and
"#exec cgi" calls? To quote The Princess Bride, "I don't think
that meens what you think it meens." Check the docs on SSI before
trying this again, as it's not likely to work the way you have it
on most servers.
: How do I retrieve arg1 arg2 and arg3 within my perl program?
man perlvar
Look for the @ARGV variable.
: I have looked at the enviroment variables and the args do not appear
: there.
That's because they are arguments, not environment settings.
: I think I will have to retrieve them the same way you would in a C
: program by using argv and argc but I do not now how to to this in PERL
: nor can I find a command that looks appropriate in the two books that I
: have.
You missed @ARGV? It's normally in start of the first chapter of
most books.
--
-Zenin
zenin@archive.rhps.org
------------------------------
Date: 24 Apr 1998 17:00:14 +0100
From: James Youngman <JYoungman@vggas.com>
Subject: Re: RMS should be invited to O'Reilly's "Free Software Summit"
Message-Id: <u11zunfbw1.fsf@noisy.vggas.com>
>>>>> "eon" == Eugene O'Neil <eugene@cs.umb.edu> writes:
eon> The only
eon> exception to this is if someone can prove you aren't really the
eon> copyright holder, and never had the right to issue the license
eon> in the first place. But if this is true, you certianly don't
eon> have the right to transfer the copyright either. Thus, the FSF
eon> is just as vulnerable to using badly-transferred copyrights as
eon> they would be vulnerable to using badly-issued licenses: the
eon> FSF copyright policy doesn't really protect anyone from
eon> anything
Actually it does. That is the point of the copyright disclaimer that
you have to get a company (vice) president to sign *before* you send
the copyright assignment to the FSF.
------------------------------
Date: 24 Apr 1998 13:52:37 -0400
From: psmith@baynetworks.com (Paul D. Smith)
Subject: Re: RMS should be invited to O'Reilly's "Free Software Summit"
Message-Id: <p5pvi7rtsq.fsf@baynetworks.com>
%% eugene@cs.umb.edu (Eugene O'Neil) writes:
eo> The only exception to this is if someone can prove you aren't
eo> really the copyright holder, and never had the right to issue the
eo> license in the first place. But if this is true, you certianly
eo> don't have the right to transfer the copyright either. Thus, the
eo> FSF is just as vulnerable to using badly-transferred copyrights as
eo> they would be vulnerable to using badly-issued licenses: the FSF
eo> copyright policy doesn't really protect anyone from anything, it
eo> only puts RMS in control of more copyrights.
You're completely wrong.
Have you ever _LOOKED_ at the documents the FSF uses for copyright
transference? There's one you sign, _AND_ there's one you must get
someone in your company to sign (if you work for a company that impounds
IP you may create in your spare time... which almost all do these
days).
That "someone" must be hold a title of vice president or better: in
other words, someone who _does_ have legal authority to perform the
transfer.
The FSF is quite well protected from this problem. And, should you
think it's a non-issue, please be aware that this _has_ happened in the
past, and it's not all that rare. I personally know of at least three
instances in the last two years where someone released code under a free
license, and their company retracted it, including all already-released
versions.
--
-------------------------------------------------------------------------------
Paul D. Smith <psmith@baynetworks.com> Network Management Development
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
These are my opinions--Bay Networks takes no responsibility for them.
------------------------------
Date: 24 Apr 1998 16:38:30 GMT
From: psf@euclid.jpl.nasa.gov (Peter Scott)
Subject: Using module outside @INC without changing @INC
Message-Id: <6hqf66$k8c@netline.jpl.nasa.gov>
I recently wanted to use a module whose path wasn't in @INC
but without modifying @INC (because I don't want its path
searched for later modules the caller might use - there is actually a
good reason for this that has nothing to do with this post), and the
only way I could think of was:
BEGIN {
unshift (@INC, '/path');
use Foo;
shift @INC;
}
but I was looking for a really concise idiom since others will use
this module and I would prefer to publish just a one-liner.
Of course, you can put a path in require, but then it's evaluated at
runtime, not compile time, and that won't do in this case.
I worked around the problem, but would still appreciate any suggestions.
--
This is news. This is your | Peter Scott, NASA/JPL/Caltech
brain on news. Any questions? | (psf@euclid.jpl.nasa.gov)
Disclaimer: These comments are the personal opinions of the author, and
have not been adopted, authorized, ratified, or approved by JPL.
------------------------------
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 2412
**************************************