[9359] in Perl-Users-Digest
Perl-Users Digest, Issue: 2954 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 23 21:07:48 1998
Date: Tue, 23 Jun 98 18:00:30 -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 Tue, 23 Jun 1998 Volume: 8 Number: 2954
Today's topics:
Re: after 5 hrs, the beginner beats the s/// (Bob Trieger)
Re: Comparing conditional ? with if..else construct (Larry Rosler)
Re: Comparing conditional ? with if..else construct <dformosa@st.nepean.uws.edu.au>
Re: Exit status from system() not what I expected (and <tchrist@mox.perl.com>
Re: Flames.... <ebohlman@netcom.com>
Re: Flames.... (John Stanley)
Re: Flames.... <ljz@asfast.com>
Re: Foreach not functioning!?! (Martien Verbruggen)
Re: Foreach not functioning!?! (Michael J Gebis)
Re: Help with site command in NET::FTP (Jeffrey Drumm)
Passing a method to another reesor@peoplescape.com
Perl on SVR3 ??? (Scott Dudley)
Re: Placeholder item in qw// <danboo@negia.net>
Re: Q: About creating user accounts from web logins <rootbeer@teleport.com>
Re: Running virus scanner from Perl <rootbeer@teleport.com>
Re: Sending files via mail in perl (John Stanley)
sort getpwent() by group? matt@msg.ucsf.edu
Re: STDIN on Win NT (Martien Verbruggen)
string substitution <hui.tang@tus.ssi1.com>
Re: string substitution <rootbeer@teleport.com>
Re: system() and security again (Marc Haber)
Re: Testing perl knowledge <ebohlman@netcom.com>
Re: Testing perl knowledge (Stuart McDow)
Re: Would someone tell me what this means? dgris@rand.dimensional.com
Re: Would someone tell me what this means? <danboo@negia.net>
Re: Would someone tell me what this means? <Joe.Kline@sdrc.com>
WWW server with perl for win95 <sibil@infinit.com.pl>
Re: WWW server with perl for win95 <rootbeer@teleport.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 23 Jun 1998 23:33:18 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: after 5 hrs, the beginner beats the s///
Message-Id: <6mpe3h$9mg$1@strato.ultra.net>
[ posted and mailed ]
gebis@albrecht.ecn.purdue.edu (Michael J Gebis) wrote:
-> sowmaster@juicepigs.com (Bob Trieger) writes:
-> }$line =~ s/^\s*(.*)\s*$/$1/;
->
-> }That is what you are looking for and if you checked the FAQs, you wouldn't
-> }have wasted 5 hours.
->
-> I personally find it funny that it took SEVEN (at this count) people
-> to show this guy up. Yeah, yeah, I know, the non-deterministic nature
-> of usenet makes all notions of simultaneity obsolete, but come on, did
-> EVERYBODY need to pick on the original poster? He said that he had
-> had a pretty bummed-out day already.
I didn't pick on him at all. I gave him 1 possible solution and I told him
that I didn't come up with it out of thin air, I found it in the FAQ.
Therefore telling him that he could have saved a lot of time.
The way I see it, I helped him twice in 1 short post.
Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-286-0591
and let the jerk that answers know that his
toll free number was sent as spam. "
------------------------------
Date: Tue, 23 Jun 1998 14:32:36 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Comparing conditional ? with if..else construct
Message-Id: <MPG.ff9becbe36280499896bd@nntp.hpl.hp.com>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <6mp4qo$bs$1@rand.dimensional.com>,
dgris@rand.dimensional.com says...
...
> It only looks loony because of the assignment in
> the conditional.
I finally worked this out, with your help and others by email, and by
recourse to the C grammar.
I had been assuming this:
conditional-expression:
logical-OR-expression
logical-OR-expression ? conditional-expression : conditional-expression
In fact, that last line reads:
logical-OR-expression ? expression : conditional-expression
So any expression at all, including assignments and commas, is acceptable
between the ? and the : . Instead of loony, it's sort of weird to reach
all the way down the precedence list here. It's the only such case in
the expression grammar, and I had forgotten all about it.
Thanks for the help, and sorry for the bandwidth.
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 23 Jun 1998 23:28:51 GMT
From: ? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au>
Subject: Re: Comparing conditional ? with if..else construct
Message-Id: <898644531.313154@cabal>
In <MPG.ff9839e58db68f09896b5@nntp.hpl.hp.com> lr@hpl.hp.com (Larry Rosler) writes:
[...]
>Language Syntax Semantics
>C Invalid Irrelevant (doesn't compile)
>C++ Valid Defined; assignment is higher precedence than ?:
>Perl Valid Test ignored; value is that of expression after :
>Am I correct in inferring that Perl has the worst approach:
>valid syntax and screwed-up semantics?
This could possably be right.
[...]
> My choice would be to invalidate the syntax; the parse tree seems
>screwy in any case.
I am a furm holder of the option that you shouldn't stop users (or
programmers) from doing stupid things because it limmits the ablity to do
smart things.
--
I'm a perl programer; if you need perl programing, hire me.
Please excuse my spelling as I suffer from agraphia; see the url. Support NoCeM
http://www.cit.nepean.uws.edu.au/~dformosa/Spelling.html http://www.cm.org/
I'm sorry but I just don't consider 'because its yucky' a convincing argument
------------------------------
Date: 23 Jun 1998 21:53:24 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Exit status from system() not what I expected (and other doc probs)
Message-Id: <6mp84k$meb$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Martin Gregory <mgregory@asc.sps.mot.com> writes:
:my $ExitStatus = system("yes > /dev/null");
:printf("Exit Status 0x%x\n",$ExitStatus);
:and see this:
:[djarraba-mg]{asc} foo.pl
:Exit Status 0x8200
:[djarraba-mg]{asc} foo.pl
:Killed
:Exit Status 0x8900
:[djarraba-mg]{asc}
:
:In the first case, I typed ^C at the command line.
When I do that, I get back 0x02
:In the second case I sent the 'yes' process a SIGKILL signal using top
:(so I know that I killed the 'yes', not the perl process).
Hold on, did you kill the sh or the yes? If I kill the yes,
I get 0x8900, as you do. But if I kill the sh, I get 0x9
as I expect.
Here's the current stuff from perlfunc/system:
Because system() and backticks block SIGINT and SIGQUIT, killing
the program they're running doesn't actually interrupt your program.
@args = ("command", "arg1", "arg2");
system(@args) == 0
or die "system @args failed: $?"
You can check all the failure possibilities by inspecting C<$?>
like this:
$exit_value = $? >> 8;
$signal_num = $? & 127;
$dumped_core = $? & 128;
--tom
--
It's there as a sop to former Ada programmers. :-)
--Larry Wall regarding 10_000_000 in <11556@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: Tue, 23 Jun 1998 22:02:49 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Flames....
Message-Id: <ebohlmanEv0yKp.n04@netcom.com>
J. Borneman <JdBornem@tivoli.com> wrote:
: You were new at this once too I assume? I don't see your name as Larry
: Wall, so I'll assume you were a newbie once yourself. Don't coddle the
: newbies, but don't berate them to the point that they don't _want_ to learn.
: If in school every time you asked your teacher a question, she put you in
: detention, you'd want to quit school pretty soon, right? Instead, teachers
: give hints, show them where to find the books, and let them learn that way.
: Much more civilized, and it creates much more learning on the part of the
: newbie.
While I agree with you that polite but firm pointers to the docs are the
way to go, I see a little problem with your teacher analogy. Answering
students' questions in school is part of a teacher's job duties that he
or she is being paid for. If a student, outside school hours, were to
come upon several teachers conversing among themselves, and began to ask
the questions, the teachers would have every right to tell the student
"this isn't the right time or place."
: yes, the stupid questions liek "How do I print text on the screen" should
: be ignored or flamed, whatever. But don't go bashing anyone who doesn't
: have a question about something that just may have been said before. And
: God forbid, sin of all sins, someone should ask a CGI question.
The only "bashing" I've seen here happens only under rather special
circumstances, such as:
1) The poster ends his question with "please e-mail me because I don't
read this group." This is just plain rude. It's even ruder to post with
a munged address and ask for an e-mail reply. Note that it is *not* rude
to ask for an e-mail CC due to legitimate problems like a flaky news
server; what's rude is implying that you don't want to spend the time to
look for a response.
2) The poster asks a question that has nothing to do with Perl at all. A
lot of the CGI questions fall into this category. This simply isn't the
group for general question about Web site design or general computer topics.
3) The poster presents a script he got from somewhere else and asks
people to modify it for him.
4) The poster's .sig indicates that he charges people money for work that
includes writing Perl scripts, but his posts indicate a newbie level of
knowledge of Perl. This is tantamount to asking other people to do free
work for him so he can sell it to others.
5) The poster, upon being pointed to the appropriate sections of the
docs, comes back and says "why can't you just give me the answer yourself?"
6) The poster claims that his program doesn't work and asks people to
tell him what he's doing wrong, but doesn't give any indication of what
he's doing in his program.
7) The poster posts what appears to be a copy of a homework or take-home
test problem and gives no indication that he's even tried to solve it.
: Lighten up. Just remember, we were all newbies once.
We all were, but most of us didn't take a "gimme" attitude.
------------------------------
Date: 23 Jun 1998 22:11:56 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Flames....
Message-Id: <6mp97c$e9j$1@news.NERO.NET>
In article <6mogn3$en4$1@csnews.cs.colorado.edu>,
Tom Christiansen <tchrist@mox.perl.com> wrote:
>You may have to wait a long time. Unless you're planning
>to campaign in favor of it, I can't help but think that the
>evil news.groupies FUD-spreaders shall have sunk it.
What shall have sunk it, if it is sunk, is a proponent who refused to
discuss the proposal during the discussion phase of the process and
failed to make corrections to the proposed charter that even he now
seems to be saying should have been made. Instead of posting a second
RFD with changes, we went right to a vote.
If you don't like the process for getting a new group, argue that it be
changed, don't argue that everyone else is evil because they won't let
you do whatever it is you want to do.
------------------------------
Date: 23 Jun 1998 20:18:16 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Flames....
Message-Id: <ltpvfzejp3.fsf@asfast.com>
Eric Bohlman <ebohlman@netcom.com> writes:
> J. Borneman <JdBornem@tivoli.com> wrote:
>
> : You were new at this once too I assume? I don't see your name as Larry
> : Wall, so I'll assume you were a newbie once yourself. [ ... ]
>
> While I agree with you that polite but firm pointers to the docs are the
> way to go, I see a little problem with your teacher analogy. Answering
> students' questions in school is part of a teacher's job duties that he
> or she is being paid for. If a student, outside school hours, were to
> come upon several teachers conversing among themselves, and began to ask
> the questions, the teachers would have every right to tell the student
> "this isn't the right time or place."
I totally agree. And the teachers in this scenario would *not* be
justified, in my opinion, to insult or berate the student.
Suitable response by the teachers in question:
"This isn't the right time or place for your question. Please
bring this up in class or research it on your own."
Non-suitable response by the teachers in question:
"You are a lazy freeloader who wants to make others do your work
for you. You are like a member of a swarm of flies who is
contaminating this area. Look up the answer yourself."
[ Note that the "flies" analogy was actually made here recently
by more than one person who was referring to newbies. ]
> [ ... ]
--
Lloyd Zusman ljz@asfast.com
perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
$t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
$x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'
------------------------------
Date: 23 Jun 1998 23:18:43 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Foreach not functioning!?!
Message-Id: <6mpd4j$rl3$1@comdyn.comdyn.com.au>
In article <358FE107.CDFDF45A@newfangled.com>,
"Michael S. Brito, Jr." <mike@newfangled.com> writes:
> diagnostics' and 'use strict' to reduce errors for now (I'll fix 'em
> later, what can I say I'm lazy). The error I am getting with the script
> as of now is:
Your loss. use strict and -w are there for programmer's _convenience_.
They make it _easier_ to write a correct program. Not harder. It's
actually lazier to have them switched on.
> Can't exec "/usr/bin/sendmail": No such file or directory at
> /home/mike/www/project/cgi-bin/sendlist.cgi line 23.
Maybe this means that you are trying to exec /usr/bin/sendmail, and it
doesn't exist. Now... why isn't that clear?
sendmail might be in a different place on your system. It might not be
available to you. I really don't know. You'll have to find out
yourself.
> Obviously, thanks.html does not exist. But I get that error so at least
Huh? How did you reach that conclusion?
> I know that it is making it all the way through the script. So I guess
> my question is, "WHY is sendmail not being launched". ANY advice would
In what way is the error message 'Can't exec "/usr/bin/sendmail": No
such file or directory' not clear? Sure, you are checking the return
value of your open, as in
> open (MAIL, "|$mailprog $address") || die "Cant open $mailprog:
but you obviously haven't read the documentation on open, where it
warns about what to do when opening a pipe. or perlfaq8, question 'Why
doesn't open() return an error when a pipe open fails?'.
It also isn't necessary to exec sendmail once for each address. There
are many much better ways to do this. You might have a look at one of
the Mail modules on CPAN, and avoid a few problems you're creating.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | I took an IQ test and the results were
Commercial Dynamics Pty. Ltd. | negative.
NSW, Australia |
------------------------------
Date: 24 Jun 1998 00:17:30 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Foreach not functioning!?!
Message-Id: <6mpgiq$l9e@mozo.cc.purdue.edu>
mgjv@comdyn.com.au (Martien Verbruggen) writes:
}In article <358FE107.CDFDF45A@newfangled.com>,
} "Michael S. Brito, Jr." <mike@newfangled.com> writes:
}> diagnostics' and 'use strict' to reduce errors for now (I'll fix 'em
}> later, what can I say I'm lazy). The error I am getting with the script
}> as of now is:
}Your loss. use strict and -w are there for programmer's _convenience_.
}They make it _easier_ to write a correct program. Not harder. It's
}actually lazier to have them switched on.
You're wrong. It's much, much worse. :)
Michael: You'll never be able to add these back in later. You might
think it's possible, but by the time you try to do it, you program
will be so disorganized and muddled that you will effectively have to
re-write everything.
Unfortunately, I speak from experience.
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: Wed, 24 Jun 1998 00:28:37 GMT
From: drummj@mail.mmc.org (Jeffrey Drumm)
Subject: Re: Help with site command in NET::FTP
Message-Id: <359240d4.798071238@news.mmc.org>
[posted and mailed]
On Tue, 23 Jun 1998 08:34:51 -0700, "James Isaacson" <jcisaac@pacbell.com>
wrote:
>I need advice on using the site command. The node I'm
>connecting to has a 'site cm' command that automatically connects
>to another server. In the debug I can see it connects but no
>matter what I try the @files array is empty. I can maunally
>ftp to this site and type site cm and then a dir and it works.
(snip)
>$ftp->command('site cm') or die "Unable to send command";
Hmm. Haven't used the command method myself. I've had excellent luck
sending commands to ftp servers with quot, though.
$ftp->quot('site cm') or die . . . etc.;
You should then be able to check $ftp->message for any return code the
server gives you.
--
Jeffrey R. Drumm, Systems Integration Specialist
Maine Medical Center Information Services
420 Cumberland Ave, Portland, ME 04101
drummj@mail.mmc.org
"Broken? Hell no! Uniquely implemented." -me
------------------------------
Date: Tue, 23 Jun 1998 22:44:54 GMT
From: reesor@peoplescape.com
Subject: Passing a method to another
Message-Id: <6mpb57$1ok$1@nnrp1.dejanews.com>
Please excuse me if this question has already been addressed.
Assume I have a class called "cars". One of the methods in this class returns
engine: cars->engine() Let's say this returns either "SIX" or "EIGHT".
Assume I have another class called "engines". One of the methods in this
class is engines->isSix()
Is there any way I can do
$c = new cars;
$e = new engines;
$e->isSix($c);
cars is in one module, engines is in another.
The subroutine isSix() would look something like:
sub isSix
{
local($c) = @_;
($c->engine() EQ "SIX") ? 1 : 0;
}
I admit this contrived example is pretty strange, but my real life situation
requires this.
When I run this, I get an error claiming that "can't locate object method
engine via package cars".
Well, this is certainly the case. But, is there a way to do this?
I am in a newsless state, so please answer directly if you don't mind.
Thanks in advance!!
Rob
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Tue, 23 Jun 1998 18:39:19 GMT
From: scottd@goodnet.com (Scott Dudley)
Subject: Perl on SVR3 ???
Message-Id: <358ff5fe.17082532@news.goodnet.com>
Has anyone ported Perl to SVR3? I'd like to run it on a Motorla M88K
R32v3 System? I have both Greenhills and GCC but can't seem to get it
to compile (not a 'C' programmer, yet). Any and all assistance is
very much appreciated.
Thanks.
------------------------------
Date: Tue, 23 Jun 1998 18:00:09 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: Placeholder item in qw//
Message-Id: <35902569.BECC1DE8@negia.net>
Larry Rosler wrote:
>
> In article <35900701.DE68D6EF@us.oracle.com>, Allen Choy
> <achoy@us.oracle.com> says...
> > Hi,
> >
> > I was wondering if there was a way of putting a null item with qw//, as
> > you can with @z = ( undef )?
>
> Not that I know of.
>
> @a = (qw( a b c ), '', qw( x, y, z ));
shouldn't that be an undef instead of an empty string?
and i'm guessing the commas in the second set are superfluous.
@a = (qw( a b c ), undef, qw( x y z ));
in thinking about it more the original poster could also create
a sub that replaces the string 'undef' with the value undef:
sub myqw {
map $_ eq 'undef' ? undef : $_, split ' ', shift;
};
my @z = myqw('foo undef bar');
hmm, i don't really like it that much, but it's a thought.
cheers,
--
Dan Boorstein home: danboo@negia.net work: danboo@y-dna.com
"THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."
- Cosmic AC
------------------------------
Date: Tue, 23 Jun 1998 21:01:10 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Q: About creating user accounts from web logins
Message-Id: <Pine.GSO.3.96.980623135648.3227E-100000@user2.teleport.com>
On Tue, 23 Jun 1998 fgump@my-dejanews.com wrote:
> It is possible to create password protected directories in UNIX, so that
> when HTML pages in those directories are accessed on the web, a login
> box will appear on the screen. The information is pulled from the
> .htaccess and .htpasswd files related to that directory.
Sure, it's possible. You could even choose to do some of the programming
in Perl, although I've heard of people using other languages from time to
time. :-)
If you have questions about how you would go about implementing this, the
docs, FAQs, and newsgroups about server programming and other web-related
issues should be helpful. If you know what to do, but you can't find how
to do it in Perl, after checking the Perl docs and FAQs please ask here.
Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 23 Jun 1998 21:18:14 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Running virus scanner from Perl
Message-Id: <Pine.GSO.3.96.980623141732.3227I-100000@user2.teleport.com>
On Tue, 23 Jun 1998 bidyut@yahoo.com wrote:
> So how can i call a virus scanner like McAfee or Norton from Perl to do
> a virus checking??
See the perlipc manpage. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 23 Jun 1998 22:17:01 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Sending files via mail in perl
Message-Id: <6mp9gt$eaf$1@news.NERO.NET>
In article <6mp6qe$5uq$3@client3.news.psi.net>,
Abigail <abigail@fnx.com> wrote:
>There are just too many programs sending mail automatically not to have
>a mail deamon on every machine. cron, vi, rcs, etc, they all send mail.
You do not need a mail daemon on a machine just so you can send mail
from that machine.
It is simply too much useless work to be forced to upgrade every machine
on a net to the latest version of sendmail every time a new security
hole is found in it. Run it as a daemon on one system and upgrade that when
needed. Let the others be daemon-less and you don't have to worry about
missing one system -- and learning too late that the spammers didn't
miss it.
------------------------------
Date: Tue, 23 Jun 1998 23:59:06 GMT
From: matt@msg.ucsf.edu
Subject: sort getpwent() by group?
Message-Id: <6mpfga$9fk$1@nnrp1.dejanews.com>
I can't figure this out. I want to:
1.) Read password entries with getpwent()
2.) Sort entries by GID
3.) Substitute a groupname for GID
4.) Print out login, name, groupname as in:
matt Matt Harrington Admin
joe Joe User Admin
fj Fred Jones Engineer
bs Bob Smith Math
etc.
I want to use getpwent() because I use NIS.
Should I store lines in an array and then print it out? Or should I use a
hash?
I'll append what I've done so far.
Thanks for any help,
Matt
#!/usr/local/bin/perl -w
my $count = 0;
while (($login,$passwd,$uid,$gid,$quota,$comment,$gcos,$home,$shell) =
getpwent())
{
($name,$office,$workphone,$homephone)=split(/,/,$gcos);
if ($passwd !~ /\*/) {
$group = "Unknown";
if ($gid == 101) {$group = "Admin";}
if ($gid == 102) {$group = "Engineer";}
if ($gid == 103) {$group = "Math";}
write;
}
$count++;
}
format =
@<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<
$login,$name,$group
.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 23 Jun 1998 23:08:05 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: STDIN on Win NT
Message-Id: <6mpcgl$rj5$1@comdyn.comdyn.com.au>
In article <358fe9b2.0@vortex.netcentral.co.uk>,
"john goodenough" <jg@inf-ltd.co.uk> writes:
> Having trouble with STDIN with WinNT.
> I have a loop which contains an @lin_in = <STDIN>
> the first iteration works OK, subsequent ones do not.
What does this loop do? I hope you're not trying to iterate over each
line in STDIN with that loop, because that statement you have there
will read in all lines at once.
# perldoc perlop
[snip]
If a <FILEHANDLE> is used in a context that is looking for a
list, a list consisting of all the input lines is returned,
one line per list element. It's easy to make a LARGE data
space this way, so use with care.
[snip]
If you want to read each line in turn, you want something like:
while (defined(my $line = <STDIN>))
{
# Do something with $line
}
If you want to use an array you'd do something like:
my @lines = <STDIN>;
foreach my $line (@lines)
{
# Do something with $line
}
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Hi, Dave here, what's the root
Commercial Dynamics Pty. Ltd. | password?
NSW, Australia |
------------------------------
Date: Tue, 23 Jun 1998 15:26:07 -0700
From: Hui Tang <hui.tang@tus.ssi1.com>
Subject: string substitution
Message-Id: <35902B7F.2424@tus.ssi1.com>
Hi, all,
I saw a problem when I do string substitution if the string is a
variable with meta characters, e.g,
$a="reg(3)";
$b="xxx";
$c="reg(3)+bus";
$c=~s/$a/$b/;
I want $c to be "xxx+bus", but it is not changed. I also tried to escape
using '\', it doesn't work, either. Anybody got an idea how to do this?
Thanks.
Hui
------------------------------
Date: Tue, 23 Jun 1998 22:37:02 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: string substitution
Message-Id: <Pine.GSO.3.96.980623153545.3227W-100000@user2.teleport.com>
On Tue, 23 Jun 1998, Hui Tang wrote:
> I saw a problem when I do string substitution if the string is a
> variable with meta characters,
Look up \Q in the perlre manpage. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 24 Jun 1998 00:43:19 GMT
From: Marc.Haber-usenet@gmx.de (Marc Haber)
Subject: Re: system() and security again
Message-Id: <6mpi43$k5i$2@nz12.rz.uni-karlsruhe.de>
Eli the Bearded <*@qz.to> wrote:
>In comp.lang.perl.misc, Russ Allbery <rra@stanford.edu> wrote:
>> Probably, but there's a better method. If you look at the documentation
>> of system(), it refers you to exec(). Under the documentation of exec()
>
>I concur. Only use system if you need the shell's interpretation of
>those meta-characters (and in that case they should be ones that
>/you/ as author of the program have provided, not ones that the user
>has provided).
exec() does the same than system(), invoking a shell when
metacharacters are present. And I am concerned about metacharacters
contained in strings that come in from the outside and are not
supposed to contain any metacharacters..
Greetings
Marc
--
-------------------------------------- !! No courtesy copies, please !! -----
Marc Haber | " Questions are the | Mailadresse im Header
Karlsruhe, Germany | Beginning of Wisdom " | Fon: *49 721 966 32 15
Nordisch by Nature | Lt. Worf, TNG "Rightful Heir" | Fax: *49 721 966 31 29
------------------------------
Date: Tue, 23 Jun 1998 22:14:55 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Testing perl knowledge
Message-Id: <ebohlmanEv0z4v.16D@netcom.com>
Perry Statham <pstatham@dev.tivoli.com> wrote:
: My boss just informed me that as the resident perl "expert" he would
: like me to interview some job candidates for their perl knowledge. Does
: anyone out there have any tests or lists of questions they have come up
: with in the past to interview for this?
How you go about this is going to depend on the candidates' backgrounds
and the nature of the jobs you're interviewing for. Are your candidates
experienced programmers, so that you can assume that they've got a good
grasp of algorithms, data structures, etc. and all you need to do is
evaluate how well they can apply this knowledge to Perl? Or are they
fresh-out-of-school types whose knowledge of programming fundamentals
needs to be evaluated as well?
One thing I'd definitely evaluate is their knowledge of and ability to use
Perl resources. They should definitely know how to use the various POD
documents that come with Perl and know how to look up modules on CPAN.
I'd stay away from measures of "nerdismo" like the ability to memorize
the order of parameters to standard functions or the ability to read
deliberately obfuscated code. Many excellent programmers are bad at this
sort of thing, and many mediocre programmers can parrot material that
they've read without understanding it.
------------------------------
Date: 23 Jun 1998 23:20:02 GMT
From: smcdow@arlut.utexas.edu (Stuart McDow)
Subject: Re: Testing perl knowledge
Message-Id: <6mpd72$f16$1@ns1.arlut.utexas.edu>
"Michael S. Brito, Jr." <mike@newfangled.com> writes:
> Is there no perl certification, or atleast certificate of completion for
> some perl course????????
Of course there is. Send me an email and I'll certify you. See how
easy? No perl course required.
--
Stuart McDow Applied Research Laboratories
smcdow@arlut.utexas.edu The University of Texas at Austin
"Look for beauty in roughness, unpolishedness"
------------------------------
Date: Tue, 23 Jun 1998 22:11:40 GMT
From: dgris@rand.dimensional.com
Subject: Re: Would someone tell me what this means?
Message-Id: <6mp8is$eo$1@rand.dimensional.com>
[posted and mailed to the cited author]
In article <01bd9eef$d228bf20$1cb0c9d0@chiefs>,
Chris Edwards <chiefs@fulton-net.com> wrote:
>I would like to know what these few short lines mean.
>
>if ($FORM{'name'}) {
> $name = "$FORM{'name'}";
> $name =~ s/"//g;
> $name =~ s/<//g;
> $name =~ s/>//g;
> $name =~ s/\&//g;
> }
> else {
> &error(no_name);
>
>Thanks for your time.
They mean-
$FORM{'name'} ?
map {local $_ = $_; s/[<>"&]//g;} $FORM{'name'}
:
&error(no_name);
All in all, not particularly useful.
Daniel
--
Daniel Grisinger dgris@perrin.dimensional.com
"No kings, no presidents, just a rough consensus and
running code."
Dave Clark
------------------------------
Date: Tue, 23 Jun 1998 18:15:16 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: Would someone tell me what this means?
Message-Id: <359028F4.608689D2@negia.net>
david lee altenburg wrote:
>
> Chris Edwards wrote:
>
> > I would like to know what these few short lines mean.
>
> ok...i'll go through it, line by line
>
> > if ($FORM{'name'}) {
>
> this line is checking to see if the "name" entry in the %FORM hash
> exists.
[snip]
actually it's checking to see if the value *associated* with the key
is "true". remember that perl has an 'exists' function that tells you
if a key exists in a hash.
and the rest of it is essentially a wordy and slow way of saying:
$name =~ tr/"<>&//d;
cheers,
--
Dan Boorstein home: danboo@negia.net work: danboo@y-dna.com
"THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."
- Cosmic AC
------------------------------
Date: Tue, 23 Jun 1998 20:23:26 -0400
From: Joe Kline <Joe.Kline@sdrc.com>
To: Chris Edwards <chiefs@fulton-net.com>
Subject: Re: Would someone tell me what this means?
Message-Id: <359046FD.CBC55C45@sdrc.com>
Sender sent a reply as well.
Chris,
this is just doing some simple text processing
I am assuming that there is a hash called %FORM.
'name' is a key in this hash
Chris Edwards wrote:
>
> I would like to know what these few short lines mean.
>
> if ($FORM{'name'}) {
> $name = "$FORM{'name'}";
^ assign the value of $FORM{'name'} to $name
> $name =~ s/"//g;
^ strip out all double quotes
> $name =~ s/<//g;
^ strip out all greater than symbols
> $name =~ s/>//g;
^ strip out all less than symbols
> $name =~ s/\&//g;
^ strip out all ampersands
> }
> else {
> &error(no_name);
call error subroutine since there is no
name value...
>
> Thanks for your time.
--
Joe.Kline@sdrc.com
------------------------------
Date: Wed, 24 Jun 1998 00:06:28 +0200
From: Michal Sibilski <sibil@infinit.com.pl>
Subject: WWW server with perl for win95
Message-Id: <359026E4.5660980D@infinit.com.pl>
Hi !
i'm looking for any web server with perl interpretator for win95
if you have please mail me:
sibil@infinit.com.pl
thanks,
Mike
------------------------------
Date: Tue, 23 Jun 1998 22:18:04 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: WWW server with perl for win95
Message-Id: <Pine.GSO.3.96.980623151643.3227S-100000@user2.teleport.com>
On Wed, 24 Jun 1998, Michal Sibilski wrote:
> i'm looking for any web server with perl interpretator for win95
It sounds as if you want a newsgroup about servers - or, even better, that
group's FAQ. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
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 2954
**************************************