[6547] in Perl-Users-Digest
Perl-Users Digest, Issue: 172 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 25 00:07:28 1997
Date: Mon, 24 Mar 97 21: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 Mon, 24 Mar 1997 Volume: 8 Number: 172
Today's topics:
Re: : Q: cgi --directly execute program with added-info (Tad McClellan)
Re: A Call for Clarity (Schwartzian Transform Considere <merlyn@stonehenge.com>
Re: A Call for Clarity (Schwartzian Transform Considere (Mike Stok)
Re: Creating arrays... (Tad McClellan)
Re: foreach loop and printing <tchrist@mox.perl.com>
Re: Getting data in random order. <tshell@mcs.net>
Re: help needed connecting character strings <billc@tibinc.com>
Re: help needed connecting character strings (Mike Stok)
Re: help: 2d perl array doesn't work! (Mike Stok)
Live Randal Schwartz interview (Steve Wainstead)
Re: Looking backwards through a text file (Abigail)
Re: numerical values as hash indices: bad idea? <billc@tibinc.com>
Re: PERL Freelancers? (Nathan V. Patwardhan)
Re: Perl to interact like "expect" script ? <eryq@enteract.com>
PERL/VMS brian@bccls.org
Re: Posting to Newsgroups from Perl Script (I R A Aggie)
Problems Building perl on HP-UX B.08.00 A 9000/43S <www@alien.claser.tno.it>
Re: Unix 'Cat' equivelent <rob@netcentral.net.no.spam>
Re: Unix 'Cat' equivelent (Eric Bohlman)
Re: Unix and ease of use (WAS: Who makes more ...) <tim@a-sis.com>
Re: What's a bad Perl book? <dbenhur@egames.com>
Re: Wildcards in a system (mv, fn, fn) call won't work (Ceolas)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 24 Mar 1997 19:32:53 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: : Q: cgi --directly execute program with added-information
Message-Id: <50a7h5.is.ln@localhost>
Mousheng Xu (mxu@eecs.ukans.edu) wrote:
: Dear Perl/CGI experts:
Perl experts hang out in the perl newsgroup.
CGI experts hang out in the CGI newsgroup.
This is the perl newsgroup... and I'm no expert either.
: In a perl cgi program, if one wants to go to another program
: after some
: work, he can use require("anotherprogram.cgi") to do it. But How if I
: have to give my "anotherprogram.cgi" some extra information
: which is normally passed through $ENV variable?
How about just passing it through $ENV variable?
: Suppose I want to pass
: STUDENT-ID=12345 to "anotherprogram.cgi", is there a nice way to do it?
: I know you can use <form action="anotherprogram.cgi?STUDENT-ID=12345">
: .... to achieve this with one mouse click.
Sorry. I don't understand. That looks like HTML or something.
This is the perl newsgroup...
You probably meant to ask this in an on-topic newsgroup such as:
comp.infosystems.www.authoring.cgi
: Suppose I don't want even a
: signle mouse click -- I want it directly go to "anotherprogram.cgi" with
: "STUDENT-ID=12345" as the environment information.
^^^^^^^^^^^^^^^^^^^^^^^^^^^
$ENV{STUDENT_ID} = 12345; # no hyphens in envar names...
system "anotherprogram.cgi";
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 24 Mar 1997 05:09:06 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: aaron_watters@msn.com
Subject: Re: A Call for Clarity (Schwartzian Transform Considered Scary)
Message-Id: <8cd8spo5jx.fsf@gadget.cscaper.com>
>>>>> "aaron" == aaron watters <aaron_watters@msn.com> writes:
aaron> Actually, this was the wrong way to do it. It should be
aaron> def Schwartzian_Transform(List, F):
aaron> def my_cmp(e1, e2, metric=F):
aaron> return cmp(metric(e1), metric(e2))
aaron> List1 = List[:]
aaron> List1.sort(my_cmp) # sort, comparing F values
aaron> return List1
aaron> But that's a bit more magical, and also slower, oh well.
No, this is precisely *not* the ST. You are computing "metric" on
each element over and over again, which makes it the more traditional
approach. Your other code was much closer. The point of the ST is to
compute the metric on each element *once* and hang on to it.
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 526 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 25 Mar 1997 03:07:24 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: A Call for Clarity (Schwartzian Transform Considered Scary)
Message-Id: <5h7fhc$8nr@news-central.tiac.net>
In article <njzwwqx8h9m.fsf@jpmorgan.com>,
Olivier Dehon <dehon_olivier@jpmorgan.com> wrote:
>Well, I have to say something about this too:
>
>Isn't
>
>open(FILEHANDLE, "myfile") or die "Can't open myfile: $!";
I know at least one 6 year old who who has little difficulty understanding
finish your homework or go to your room!
one of the entertaining things about the effects of any kind of rigourous
(in a classical sense) "scientific" education is just how far smart people
are prepared to stretch the notions of "reasonable" and "obvious."
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: Mon, 24 Mar 1997 19:40:58 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Creating arrays...
Message-Id: <afa7h5.bu.ln@localhost>
Mr Matty (hayes@coventry.ac.uk) wrote:
: Can anyone help.. I am after a bit of a pointer,
: I want to take in a string and convert each word within that is delimited
: by a space into an array. For instance..
: Hello My Name Is
: would create
: @sentance{1} = "hello"
^
You don't use @ for array _elements_, only when referring to
the entire array. You use $ for referring to array elements.
: @sentance{2} = "My"
^ ^
You don't use {} for _array_ elements, only when referring to
hash elements. You use [] for array elements.
so, something like:
$sentence[1] = "hello"; # I fixed the spelling too ;-)
I think you should read the docs a little more before asking
questions. This is pretty basic stuff here...
---------------
#! /usr/bin/perl -w
while (<>) {
while (/(\w+)/g) {push(@words, $1)}
}
foreach (@words) {
print "$_\n";
}
---------------
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 25 Mar 1997 02:05:38 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: foreach loop and printing
Message-Id: <5h7bti$8iu$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
"Kaushal Shah" <kaushal@nwdc.com> writes:
:Why won't the following code create a file called uid.log assuming there is
:some data in
:open (LOG, ">uid.log");
You'll never know -- and neither will be -- because you forgot to check
the return code.
open (LOG, ">uid.log") || die "can't open uid.log: $!";
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
A truly wise man never plays leapfrog with a unicorn.
------------------------------
Date: Mon, 24 Mar 1997 22:07:02 -0600
From: Timothy Shell <tshell@mcs.net>
Subject: Re: Getting data in random order.
Message-Id: <33374F66.6BA9@mcs.net>
Thanks everyone for the good suggestions, and thanks to Tom Christiansen
and Nathan Torkington for their excellent FAQ. For the sake of
interested third parties, this is the solution I settled on.
#First, get all matching records into an array with:
push(@old, $_)
#Then:
srand;
@new = ();
while (@old)
{
push(@new, splice(@old, rand @old, 1));
}
Simple, and works like a charm!
--
Timothy Shell : tshell@mcs.net
Freedom's Nest: http://www.bomis.com/fn
------------------------------
Date: Mon, 24 Mar 1997 20:51:33 -0500
From: Bill Cowan <billc@tibinc.com>
To: Kathy Scott <kscott@uab.edu>
Subject: Re: help needed connecting character strings
Message-Id: <33372FA5.61B3@tibinc.com>
Kathy Scott wrote:
>
> I have a string of characters assigned in the variable $helixname
> For example $helixname=helix25
> I have had no problem refering to a file as $helixname.dt so that the file
> that is being dealt with is helix25.dt
> However, when I tried this line
> rename("existingfile", $helixname.dt);
^^^ Period as concatenation op.
Didn't you mean to enclose this in double quotes?
rename("existingfile", "$helixname.dt");
As it is, that period act as a concatenation operator with the bareword
"dt".
> The computer leaves out the period before the extension; so, the file's new
> name is helix25dt
> Can anyone explain this?
> Thank you very much,
> Kathy Scott
-- Bill
-----------------------------------------------------------------------
Bill Cowan <billc@tibinc.com> Voice:919-490-0034 Fax:919-490-0143
Tiburon, Inc./3333 Durham-Chapel Hill Blvd Suite E-100/Durham, NC 27707
------------------------------
Date: 25 Mar 1997 03:51:02 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: help needed connecting character strings
Message-Id: <5h7i36$c7e@news-central.tiac.net>
In article <5h6ts8$n5r@maze.dpo.uab.edu>, Kathy Scott <kscott@uab.edu> wrote:
>I have a string of characters assigned in the variable $helixname
>For example $helixname=helix25
>I have had no problem refering to a file as $helixname.dt so that the file
>that is being dealt with is helix25.dt
>However, when I tried this line
>rename("existingfile", $helixname.dt);
>The computer leaves out the period before the extension; so, the file's new
That's because
$helixname.dt
is interpreting the . as perl's string concatenation operator and dt as an
unquoted string, you might want to say
"$helixname.dt"
where $helixname is interpolated in the string, or something explicit
like
join ('.', $helixname, 'dt')
If you use the -w flag to perl then perl will try and warn you about
things like that e.g.
#!/usr/local/bin/perl -w
$helixname = 'helix';
print $helixname.dt;
print "\n";
__END__
says
Unquoted string "dt" may clash with future reserved word at try.pl line 4.
ond if you use the strict pragma (use strict;) perl becomes safer still
(at the expense of a long-winded tendency which can be frustrating if
you're whipping up quick scripts, but a life saver in terms of
maintainability...)
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: 25 Mar 1997 03:37:38 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: help: 2d perl array doesn't work!
Message-Id: <5h7ha2$b75@news-central.tiac.net>
In article <5h6eev$cim$1@news.nac.net>, Apple-O <appleo@cybercomm.net> wrote:
>can anyone can explain why this script doesn't work?
>(other than the fact that i'm a bonehead programmer)
>:/)
>
If you're comparing scalars as if they were strings you might want to use
the cmp operator rather than the <=> which tries to make its operands
numbers.
There's no such thing in perl as a multidimensional array or hash, but it
is possible to create the illusion of them bu using sincle dimensional
arrays or hashes whose elements can contain references to other things
such as arrays or hashes. There are syntactic shortcuts which allow perl
to represent accesses to these using a notation similar to that used in
languages like C, but in the code below @two_d_array is a 3 element list,
each element being a reference to another 3 element list.
Perl indicies are by default 0 based, so a 3 element list is typically
indexed by the values 0 through 2, the .. range operator can be used to
generate lists (but be aware that 0 .. 999999 is a big list and you might
want to resort to for ($index = 0; $index < 1000000; $index++) in cases
like that...)
In a perl sort block $a and $b are used to represent the values being
compared. You should see if this code does what you expect, and if it
does then read the perldsc (perl data structures cookbook) man page which
is distributed with recent perl 5.xxx as well.
#!/usr/local/bin/perl -w
use strict;
use vars qw/@two_d_array $row $col $sortCol/;
@two_d_array = (
[qw(e c f)],
[qw(d g b)],
[qw(h a i)]
);
foreach $row (0 .. 2) {
foreach $col (0 .. 2) {
print "$two_d_array[$row][$col] ";
}
print "\n";
}
foreach $sortCol (0 .. 2) {
print "Sorting on column $sortCol\n";
foreach $row (sort
{$two_d_array[$a][$sortCol] cmp $two_d_array[$b][$sortCol]}
0 .. 2) {
foreach $col (0 .. 2) {
print "$two_d_array[$row][$col] ";
}
print "\n";
}
}
__END__
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: 24 Mar 1997 16:24:25 GMT
From: swain@boojie.rt.csuohio.edu (Steve Wainstead)
Subject: Live Randal Schwartz interview
Message-Id: <5h69rp$sel@csu-b.csuohio.edu>
Keywords: Randal Schwartz perl unix security
Randal Schwartz will be interviewed live Tuesday March 25th at 6pm EST on
the radio show "31337". You can hear the program live via Audioactive.
For more details visit the WCSB-FM web site at http://www.wcsb.org. You
can download the Audioactive player from www.audioactive.com. It's a
helper app that once added to your browser allows you to click on the link
on the WCSB web site to hear the station in real time.
Unfortunately the interview cannot be archived at this time so it will not
be available for later listening.
--
---
The radio show 31337 -- http://wcsb.org/31337/
finger swain@wcsb.org for PGP key
When encryption is outlawed, ?o'AZ-,++o+i++##4AoA+-/-C++bI+/.+~
------------------------------
Date: Tue, 25 Mar 1997 01:47:11 GMT
From: abigail@ny.fnx.com (Abigail)
Subject: Re: Looking backwards through a text file
Message-Id: <E7Ksyn.nn@nonexistent.com>
On Sat, 22 Mar 1997 10:05:46 +0900, Christopher Wright wrote in comp.lang.perl.misc:
++ Hmm Thanks people.. I thought I was missing something obvious. All I
++ really wanted to do was to avoid having to create a huge array that I
++ was only going to use the end of. I just wanted to go backwards line by
++ line through a text log file until I found the first instance of a word,
++ copy that out to another file, and continue line by line until the last
++ instance of the word. It seemed silly to read the whole log into an
++ array since the only data I would be interested in 90% of the time was
++ the last section.
Uhm, the solutions presented here *do* read in the whole file.
You just don't notice it.
++ A different question though to solve the problem - can I write the file
++ "backwards" in the first place ? (ie put the line of log text at the
++ front of the file rather than at the end ?)
Well, only if you move the file. You end up with reading and writing
the entire file, in stead of just meddling with the end.
In most case, not at all worthwhile.
Abigail
------------------------------
Date: Mon, 24 Mar 1997 20:55:21 -0500
From: Bill Cowan <billc@tibinc.com>
To: Olivier Dehon <dehon_olivier@jpmorgan.com>
Subject: Re: numerical values as hash indices: bad idea?
Message-Id: <33373089.4AE1@tibinc.com>
If feasible for the application, another option would be:
use integer;
to get integer math, instead of the floating point. Or at least have
"use integer;" in effect when creating the hash keys.
Bill
Olivier Dehon wrote:
>
> really_eliot@dg-rtp.dg.com_but_mangled_to_stop_junk_email writes:
> >
> > I've been told many times that one should never attempt to compare two
> > floating-point values for equality, because, for example, you could be
> > trying to compare 1.0000000000 to 0.9999999999, and the result would
> > be "not equal", even if that isn't what you expected. Fair enough.
> >
> > Now Perl, by default, represents all numerical values as floating
> > point numbers. If I were to use such a value as a key to a hash
> > (associative array), the value would be converted into a string and
> > the string would be used as the actual key value. Right? Correct me
> > if I'm wrong. Later, if I go to access that array entry by
> > calculating a numerical value and using that as the key, once again a
> > floating point is converted to a string and used as the actual key.
> >
> > Thus I could end up generating a key of "1.00000000" (or perhaps just
> > "1") the first time, and "0.99999999999" the second time (depending on
> > what calculations I used to generate the index) and finding that my
> > array entry had "disappeared". Or so it appears to me.
> >
> > Should I conclude that using numerical values, or at least numerical
> > values that are the result of any kinds of calculations, as keys to an
> > associative array is a Bad Idea?
> >
> Yes, you're right.
>
> There is a way of getting around that problem, if you can assume that
> your keys will not be too close from one another. e.g. if the minimal
> difference between two consecutive keys is at least .001, then you
> could use sprintf on the keys to use keys with 3 decimal digits, that is:
> $key = sprintf("%.3f", $key);
>
> This will make sure that your keys are rounded off before parsing the hash.
> Gurus will tell if I'm wrong ;-)
>
> Hope this helps.
> Olivier Dehon
-----------------------------------------------------------------------
Bill Cowan <billc@tibinc.com> Voice:919-490-0034 Fax:919-490-0143
Tiburon, Inc./3333 Durham-Chapel Hill Blvd Suite E-100/Durham, NC 27707
------------------------------
Date: 25 Mar 1997 01:38:31 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: PERL Freelancers?
Message-Id: <5h7aan$bjt@fridge-nf0.shore.net>
Chester Bullock (chester@black-diamond.com) wrote:
: I am in need of a PERL programmer to do create a script. If
: interested, e-mail me at chesterb@toski.com and I will give you more
: details.
Would you give us more dollars, too? :-)
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: Mon, 24 Mar 1997 19:54:16 -0600
From: Eryq <eryq@enteract.com>
To: jtjioe@us.oracle.com
Subject: Re: Perl to interact like "expect" script ?
Message-Id: <33373048.4A924F15@enteract.com>
jtjioe@us.oracle.com wrote:
>
> All,
> Can Perl interact with program or shell just like "expect" ?
> I usually use expect script to do interaction with program say
> installation program, remote login etc.
>
> Is this possible with Perl also?
Yes... matter of fact, I think someone just announced an IO::Expect
module, or something similar. Try doing a DejaNews search for
"perl", "module", "expect".
HTH,
--
___ _ _ _ _ ___ _ Eryq (eryq@enteract.com)
/ _ \| '_| | | |/ _ ' / Hughes STX, NASA/Goddard Space Flight Cntr.
| __/| | | |_| | |_| | http://www.enteract.com/~eryq
\___||_| \__, |\__, |___/\ Visit STREETWISE, Chicago's newspaper by/
|___/ |______/ of the homeless: http://www.streetwise.org
------------------------------
Date: Mon, 24 Mar 1997 21:11:28 -0600
From: brian@bccls.org
Subject: PERL/VMS
Message-Id: <859258814.11645@dejanews.com>
Is anyone running PERL on a VMS machine, using the CERN web server? I
cannot get any perl scripts to run - is there something im missing I
hope???
please respond to brian@bccls.org
thank you
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Mon, 24 Mar 1997 19:06:33 -0500
From: fl_aggie@hotmail.com (I R A Aggie)
Subject: Re: Posting to Newsgroups from Perl Script
Message-Id: <fl_aggie-ya02408000R2403971906330001@news.fsu.edu>
In article <5h6l73$5iv@netnews.upenn.edu>, marcus@force.stwing.upenn.edu
(Marc Dworkin) wrote:
+ (How) Can I post to a Newsgroup from a Perl script?
You get the Net::NNTP module?
James - <url:http://www.perl.com/CPAN/>
--
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: Mon, 24 Mar 1997 18:31:01 -0800
From: Luis Ontanon <www@alien.claser.tno.it>
Subject: Problems Building perl on HP-UX B.08.00 A 9000/43S
Message-Id: <333738E5.63B3@alien.claser.tno.it>
Some time ago I've dowloaded the CPAN/src/latest.tar.gz file from a CPAN
archive. But, I hasn't been able to build it on the target system.
After I run Configure it does not generate neither the config.sh file
nor any makefile, so i cannot procceed.
I've read the README and INSTALL file as well as other material
including the FAQ on the CPAN archive, but I sill haven't found a way to
solve this problem.
I've tried using different settings to build up the interpreter but with
no results.
I've even tried to download a binary of perl 5.003 from a mirror of the
Liverpool archive, but it's built for v10.0 and doesn't work on the
target system (I may be doing something wrong... i just de-tar-ed the
file into the target destination, but no documentation was provided that
the procedure was different.) I had not found any binary for 68040 based
8.0.
I've set Configure it to use -O -DJMPCLOBBER as cc flags, as well as
other Options (for the linker, malloc and memory alignment) as i found
in a FAQ from the comp.sys.hp.hpux ng I've found. Still it hasn't work.
I would need:
a) someone explaining me the installation procedure for building it on
HP-UX B.08.00 A 9000/43S not using shared libraries and in a directory
different than /usr/local.
b) an url for a binary already built for the target system (HP-UX
B.08.00 A 9000/43S)
Few things apply:
I cannot be root; so I want it to be installed in a directory different
than /usr/local, since i don't have permissions to install it there.
I'm conscious that this is a lil off-topic in this ng since it does not
regard programming in perl, and I do apologize in advance for it. But
from other "more topical" newsgroups I haven't had any feedback up to
date.
Regards, Luis Ontanon.
(please CC to lontanon@concentric.net and/or www@alien.claser.tno.it)
------------------------------
Date: Mon, 24 Mar 1997 17:24:36 -0600
From: Rob Huffstedtler <rob@netcentral.net.no.spam>
Subject: Re: Unix 'Cat' equivelent
Message-Id: <33370D34.72D308E2@netcentral.net.no.spam>
You need to use a foreach loop or a while loop to either shift off the
command line arguments so that you can open a filehandle for each file.
Set $| to flush the buffers. Your code should end upsomtehing like
this. Note: this is off the top off my head so I'm not even going to
test it. that's up to you
#!/usr/bin/perl5 #If your using v4, upgrade
while (@ARGV) {
shift; #set $_ to each argument in turn
open FH, "<$_"; #open that file
while (<FH>) {
print; #print each line to STDOUT
}
}
exit (0);
Try that and let me know how it works.
Bryan Grenn wrote:
>
> I'm trying to replace a lot of my unix scripts
> with perl. I'm having problems trying to do
> simple file manipulation..
>
> ie
>
> cat filea.txt fileb.txt filec.txt > newfile.txt
>
> How can I easlily do this in perl ????
------------------------------
Date: Tue, 25 Mar 1997 03:22:51 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Unix 'Cat' equivelent
Message-Id: <ebohlmanE7KxE3.Dqp@netcom.com>
Rob Huffstedtler (rob@netcentral.net.no.spam) wrote:
: while (@ARGV) {
: shift; #set $_ to each argument in turn
: open FH, "<$_"; #open that file
: while (<FH>) {
: print; #print each line to STDOUT
: }
: }
: exit (0);
While this will work, it's a good idea to get used to two very common
Perl idioms for this sort of task. First of all,
while (@ARGV) {
shift;
#stuff
}
can be rewritten as
foreach (@ARGV) {
#stuff
}
which is at least to me a bit clearer ("foreach" can also be written as
just "for") as it describes the task to be done rather than the mechanics
of how to do it.
Second,
foreach (@ARGV) {
open FH,"<$_";
while (<FH>) {
#stuff
}
close FH;
}
can be rewritten as
while (<>) {
#stuff
}
Which again is somewhat easier to read as it emphasizes the #stuff rather
than the mechanics of getting and opening the files.
------------------------------
Date: 24 Mar 1997 20:09:19 GMT
From: "Tim Behrendsen" <tim@a-sis.com>
Subject: Re: Unix and ease of use (WAS: Who makes more ...)
Message-Id: <01bc388f$41537ac0$87ee6fce@timpent.a-sis.com>
Randy Wright <rw26@acf2.nyu.edu> wrote in article <5h68tm$or1$1@news.nyu.edu>...
> Stephane Plattner (NOSPAMplas@fmi.ch) wrote:
> : mwolfe@shrike.depaul.edu wrote:
> : >
> : > In the end Linux will bury MS. Linux is open. This means open
> : > competition. This means better products. LINUX RULES.
> : >
> :
> : IMHO this answer contradicts to the basics of economics. Openess means
> : to a great extent equality and equality prohibits competition.
> : (communism). Competition rises only when differences exists and it's
> : the market (or the environment), who dictates which product is better.
> :
> IMHO, if the sucess of Linux contradicts basic economics,
> then there really is something wrong with basic economics.
> I've seen companies try to compete with Linux go belly up.
> That is not the intent of the Linux community. It just happens
Depends on your definition of success. I would be interested
in a reference to which company you have seen go belly up
because of Linux.
In any case (getting past your hyperbole), Linux is certainly
successful, based on the fact that a lot of people like to use
it, but that's like saying that Costa Rica is a successful country.
It is, but it's puny in the scheme of things. That doesn't mean
it isn't a pleasant place to visit.
> B.Gates and Co. acknowledge having "missed" the popularity and
> significance of the internet. After all, they didn't see
> it competeing in their channels. Nobody was advertising it
> magazines or pushing it in egghead stores. The same thing is true
> of Linux. Now, Microsoft cannot see Linux. They will
> not realize the level of compitition they get from Linux.
Yes, and look what happened once they decided that the Internet
was viable.
> The figures are soft, but there are those claiming that Linux
> is now the number 3 OS with an installed base of about 6 million.
This number means nothing; sounds like the number of CDs that
have been sold. I have Linux on a partition on one of my
spare computers, but that doesn't mean it gets used for anything.
Linux would be lucky to get into six figures in terms of the
number of installed systems that actually *do* something
business related (I don't think it would reach six figures).
> But traditional economics and marketing and management thinking
> will not, as far as I know, be able to digest such an idea.
> It is not at all some socialist or communist thing, as some
> people around usenet have proposed.. It is NOT characterized
> by central planning, or authoritarian production.. That is
> much more like the model of Microsoft. Linux is not controlled.
> It cannot be made unprofitable. It is built BY its market and
> it becomes whatever that market wants it to be as the market
> decides what it wants.
Indeed, which is why it will never be dominant (note I did
*NOT* say successful, which is a different thing). Microsoft
et al have an incentive of fundamental survivability, and
Linux does not. Commercial operating systems will always be
a few steps ahead of free operating systems, simply because
they have to be to survive, and that is a much more powerful
incentive than some guy working part time on some part of
the operating system, particularly when that same guy is
probably working on a commercial O/S in order to put the kids
through college. Do you think he is going to put something
into Linux that he wouldn't put into his commercial baby?
--
==========================================================================
| Tim Behrendsen (tim@a-sis.com) | http://www.cerfnet.com/~timb |
| "Judge all, and be prepared to be judged by all." |
==========================================================================
------------------------------
Date: Mon, 24 Mar 1997 20:00:50 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
Subject: Re: What's a bad Perl book?
Message-Id: <33374DF2.6E74@egames.com>
"Foucault's Pendulum" by Umberto Eco is a terrible
Perl reference. Please avoid.
--
Devin Ben-Hur <dbenhur@egames.com>
eGames.com, Inc. http://www.egames.com/
eMarketing, Inc. http://www.emarket.com/
"It's better to be lucky than good." -- Elizabeth Bourne
------------------------------
Date: Mon, 24 Mar 1997 19:36:45 -0700
From: ceolas@celtic.stanford.edu (Ceolas)
Subject: Re: Wildcards in a system (mv, fn, fn) call won't work
Message-Id: <ceolas-2403971936450001@b461-powmac7500.stanford.edu>
Hallelujia!
I hope I'm not wasting more bandwith here, but I'd like to say a big
thank you to those kinds souls who took the time to answer my question. It
was probably another dumb beginners question, but it's been a *huge* help
to have it answered, so thanks! I hope at some stage to be able to
contribute too.
-Gerard Manning.
--
Ceolas - Celtic music on the internet: IrishNet: directory of Irish-related
http://celtic.stanford.edu/ceolas.html resources in America:
FTP: celtic.stanford.edu http://celtic.stanford.edu/IrishNet/
------------------------------
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 172
*************************************