[17267] in Perl-Users-Digest
Perl-Users Digest, Issue: 4689 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 22 14:05:38 2000
Date: Sun, 22 Oct 2000 11:05:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <972237914-v9-i4689@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 22 Oct 2000 Volume: 9 Number: 4689
Today's topics:
Re: Boolean query to Perl regexp match conversion <bart.lateur@skynet.be>
Re: Boolean query to Perl regexp match conversion (Tom Christiansen)
Re: Boolean query to Perl regexp match conversion <godzilla@stomp.stomp.tokyo>
Exporting from a cgi script <billy@nospamforme.com>
Great Employment Opportunities- NY/NJ Fortune 1000 Com <colleentagg@hotmail.com>
Re: Great Employment Opportunities- NY/NJ Fortune 1000 (Clay Irving)
help .. juneym@my-deja.com
Re: Help with array concatenation (Martien Verbruggen)
Re: Help with array concatenation (Martien Verbruggen)
Re: Help with array concatenation (Tad McClellan)
Re: Help with array concatenation <harrisr@bignet.net>
Re: Help with array concatenation <godzilla@stomp.stomp.tokyo>
Re: Help with array concatenation <Jodyman@usa.net>
Re: Help with array concatenation (Tad McClellan)
Re: Help with array concatenation <Jodyman@usa.net>
Re: help with system () <ren.maddox@tivoli.com>
Re: help with system () (Tad McClellan)
Re: help with system () <rsmallwood@mindspring.com>
Re: help with system () (Logan Shaw)
Re: help with system () (Mark-Jason Dominus)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 22 Oct 2000 10:37:09 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Boolean query to Perl regexp match conversion
Message-Id: <bkg5vscipf6obdhgsqpvdulagppte98rhu@4ax.com>
Tom Christiansen wrote:
>just require that
>
> (foo OR bar) AND blah* AND kernel
>
>be typed in with slashes as quote delimiters, yielding
>
> (/foo/ or /bar/) and /blah*/ and /kernel/
/blah.*/
or just /blah/. Linc MAdison made some other observations.
>which you are then free to compile as is. Benefits of this approach
>are many and strong, so you should not automatically disregard it.
Disadvantages: This entry is tainted. You just don't want to eval() any
user input just like that. I'm not familiar with Safe.pm, so I don't
know what this module can trap.
--
Bart.
------------------------------
Date: 22 Oct 2000 10:49:03 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: Boolean query to Perl regexp match conversion
Message-Id: <39f31a7f@cs.colorado.edu>
In article <bkg5vscipf6obdhgsqpvdulagppte98rhu@4ax.com>,
>Disadvantages: This entry is tainted. You just don't want to eval() any
>user input just like that.
Sure, you do (but see below). That's often why you have an interpreter
right there. Consider the debugger. Consider
% rename 's/$/sprintf(".%04d", $n++)/e' */*
Doesn't that just take your breath away? This simple yet powerful
demonstration illustrates the ease with which flexible applications
can be trivially constructed when one has available under one's
fingertips a complete programming language, instead of some mere
ad hoc syntactic golem that was idiosyncratically constructed anew
for each program and thus an onerous burden to both programmer and
user.
Consider it a matter of knowledge reuse--or, if you're thinking
programmatically, of code reuse through avoiding the gratuitous
re-inventing of a well-honed wheel that countless others have worked
long and hard to perfect.
Consider it laziness.
Should you find that term burdened with too many negative connotations
for your own personal comfort, you are perfectly welcome to consider
this an issue of applied wisdom, of knowing when not to waste time
inventing labyrinthine solutions to problems already solved. You're
merely an efficiency expert who recognizes that finite resources
(the programmer's time) must be thriftily applied.
[this is below]
The only situation where this awesome flexibility would be of any
reasonable concern would be the one in which you were unwisely
executing code upon behalf of someone else. So contorted and
unnatural a situation runs counter to the very notion of separation
of privileges, a fundamental principle underlying all security
systems, be they computational (read: operating systems) or otherwise.
If you don't want an operating system, then truly, you don't want users.
>I'm not familiar with Safe.pm, so I don't know what this module
>can trap.
Education through literacy: For that itch were manpages invented.
Alternatively, when you in margarite mistrust find yourself walking
through the valley of the shadow of death by insecurity, look to
the Twenty-Third Chapter of the most recent incarnation of the Book
of the Camel, wherein you shall find both explanations and examples
of many such matters, including the one to which you have just
alluded.
The moral of this story is that if you find yourself doing something
that Perl is better at than you are, such as the parsing of rather
Perlish code, whether that code be in the form of data structures,
pattern matches, logical expressions, or combinations of the same,
then you should by all means get out of the way and let Perl do
what it does best instead of trying to second-guess it. In short,
don't invent new syntax if you can possibly help it--and you nearly
always can. Be lazy.
--tom
+------------------------------------------------------------------------+
| "Programs that write programs are the happiest programs in the world." |
| --Andrew Hume, famous Unix philosopher |
+------------------------------------------------------------------------+
# This is a shell archive. Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file". Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
# pathedit
# rename (linked to pathedit)
# relink (linked to pathedit)
#
echo x - pathedit
sed 's/^X//' >pathedit << 'END-of-pathedit'
X#!/usr/bin/perl
X# pathedit/rename/relink -- rename or relink files
X# original rename and relink were by Larry Wall
X# this version by Tom Christiansen
X
Xuse 5.006;
Xuse strict;
Xuse warnings;
X
Xour(
X $errcnt, # how many didn't work
X $verbose, # trace actions
X $nonono, # but don't do them (implies verbose)
X $careful, # ask if target *appears* to exist
X $inspect, # ask about everything
X $quiet, # don't carp if target skipped
X $force, # overwrite existing target without prompting
X $nullpaths, # stdin paths are null terminated, not \n
X @flist, # list of magic filenames containing paths to edit
X $renaming, # rename paths (disimplies reslinker)
X $reslinking,# reslink paths (disimplies renamer)
X);
X
X$errcnt = 0;
X
Xopter();
Xcompiler();
Xfixer();
Xexit($errcnt != 0);
X
Xsub usage {
X warn "@_\n" if @_;
X die <<EOF;
Xusage: $0 [-ifqI0vnml] [-F file] perlexpr [files]
X -i ask about clobbering existent files
X -f force clobbers without inquiring
X -q quietly skip clobbers without inquiring
X -I ask about all changes
X -0 read null-terminate filenames
X -v verbosely says what its doing
X -n don't really do it
X -m to always rename
X -l to always symlink
X -F path read filelist to change from magic path(s)
XEOF
X}
X
Xsub accesstty {
X return 1 if defined fileno(TTYIN) &&
X defined fileno(TTYOUT);
X
X unless (open(TTYIN, "</dev/tty") && open(TTYOUT,">/dev/tty")) {
X return 0;
X }
X
X select((select(TTYOUT),$|=1)[0]);
X return 1;
X}
X
Xsub compiler {
X my $op = shift @ARGV || usage();
X *pathedit = eval qq{
X sub () {
X use warnings qw/FATAL all/; # XXX: does not work
X local \$SIG{__WARN__} = sub {
X local \$_ = "\@_";
X s/at \\(eval.*//;
X die "FATAL WARNING: \$_";
X };
X $op;
X }
X } || do {
X local $_ = $@;
X s/at \(eval.*//s;
X die "$0: can't compile perlexpr $op: $_\n";
X }
X}
X
Xsub get_targets {
X if (@ARGV) {
X usage "-F list exclusive of command line paths" if @flist;
X return @ARGV;
X }
X @ARGV = @flist ? @flist : '-';
X local $/ = "\0" if $nullpaths;
X my @paths = <>;
X chomp @paths;
X return @paths;
X}
X
Xsub fixer {
X
X my $oldslink;
X
XPATHNAME:
X for my $oldname (get_targets()) {
X
X if ($oldname =~ /\0/) {
X warn "$0: null found in $oldname; did you forget -0?\n";
X $errcnt++;
X next PATHNAME;
X }
X if ($renaming && !-e $oldname) {
X warn "$0: $oldname doesn't exist\n";
X $errcnt++;
X next PATHNAME;
X }
X
X if ($reslinking) {
X unless (-l $oldname) {
X warn "$0: $oldname ", (-e _)
X ? "not a symbolic link\n"
X : "doesn't exist\n"
X unless $quiet;
X $errcnt++;
X next PATHNAME;
X }
X $oldname = readlink($oldslink = $oldname);
X }
X my $newname = do {
X local $_ = $oldname;
X pathedit();
X $_;
X };
X next if $newname eq $oldname;
X
X local *confirm = sub () {
X next PATHNAME unless accesstty();
X print TTYOUT $renaming
X ? "rename $oldname to $newname? "
X : "symlink $oldslink to point to $newname? ";
X my $answer = <TTYIN>;
X no warnings 'exiting'; # hush, you: it's in my lexical scope
X last PATHNAME unless defined $answer; # exit?
X chomp $answer;
X last PATHNAME if "QUIT" =~ /^\Q$answer/i;
X next PATHNAME unless "YES" =~ /^\Q$answer/i;
X };
X
X confirm() if $inspect;
X
X # "I'd like to teach
X # The world to race
X # In perfect hackery!"
X my $was_there = do {
X no warnings 'newline';
X -e $newname;
X };
X
X if ($renaming) {
X
X if ($was_there && !$inspect && $careful) {
X confirm() unless $force || $quiet;
X next PATHNAME if $quiet;
X }
X
X unless (vrename($oldname, $newname)) {
X warn "$0: can't rename $oldname to $newname: $!\n";
X $errcnt++;
X next PATHNAME;
X }
X
X }
X elsif ($reslinking) {
X unless ($was_there) {
X warn "$0: symlinking $oldslink to nonexistent $newname\n"
X unless $quiet;
X }
X unless (vunlink($oldslink)) {
X warn "$0: can't unlink $oldslink: $!\n";
X $errcnt++;
X next PATHNAME;
X }
X if (!vsymlink($newname, $oldslink)) {
X warn "$0: can't symlink $newname to $oldslink: $!\n";
X $errcnt++;
X next PATHNAME;
X }
X }
X else {
X die "Not reached";
X }
X
X }
X
X}
X
Xsub vunlink {
X my $goner = shift;
X if ($verbose) {
X print "unlink $goner\n";
X return 1 if $nonono;
X }
X unlink $goner;
X}
X
Xsub vrename {
X my ($old,$new) = @_;
X if ($verbose) {
X print "rename $old $new\n";
X return 1 if $nonono;
X }
X rename($old,$new);
X}
X
Xsub vsymlink {
X my ($new,$old) = @_;
X if ($verbose) {
X print "symlink $old -> $new\n";
X return 1 if $nonono;
X }
X symlink($new,$old);
X}
X
Xsub opter {
X
XARG: while (@ARGV && $ARGV[0] =~ s/^-(?=.)//) {
XOPT: for (shift @ARGV) {
X
X m/^$/ && do { next ARG; };
X m/^-$/ && do { last ARG; };
X
X s/^0// && do { $nullpaths++; redo OPT; };
X s/^f// && do { $force++; redo OPT; };
X s/^l// && do { $reslinking++; redo OPT; };
X s/^I// && do { $inspect++; redo OPT; };
X s/^i// && do { $careful++; redo OPT; };
X s/^v// && do { $verbose++; redo OPT; };
X s/^m// && do { $renaming++; redo OPT; };
X s/^n// && do { $nonono++; redo OPT; };
X s/^q// && do { $quiet++; redo OPT; };
X
X s/^F(.*)//s && do { push @flist, $1 || shift @ARGV; redo OPT; };
X
X usage("Unknown option: $_");
X }
X }
X unless ($renaming || $reslinking) {
X $renaming = $0 =~ /name/;
X $reslinking = $0 =~ /link/;
X }
X if ($renaming && $reslinking) {
X usage "Can't both rename (-r) and relink (-h)";
X }
X unless ($renaming || $reslinking) {
X warn "$0: assuming renaming behavior requested\n";
X $renaming++;
X }
X $verbose++ if $nonono;
X
X if ($inspect) {
X accesstty() || usage "can't inspect without /dev/tty: $!";
X }
X
X}
END-of-pathedit
echo chmod +x pathedit
chmod +x pathedit
echo ln pathedit rename
ln pathedit rename
echo ln pathedit relink
ln pathedit relink
exit
------------------------------
Date: Sun, 22 Oct 2000 10:23:50 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Boolean query to Perl regexp match conversion
Message-Id: <39F322A6.C89F5905@stomp.stomp.tokyo>
Tom Christiansen wrote:
(snipped)
> Education through literacy: For that itch were manpages invented.
> Alternatively, when you in margarite mistrust find yourself walking
> through the valley of the shadow of death by insecurity, look to
> the Twenty-Third Chapter of the most recent incarnation of the Book
> of the Camel, wherein you shall find both explanations and examples
> of many such matters, including the one to which you have just
> alluded.
You will recall, Christiansen, your one and only article
directed at me, not long back, is an article riddled with
personal insult, degrading innuendo and outright hatred.
It is now my turn. However, inclusion of hateful remarks
is not my customary habit for personal writings. You will
read none.
You will perform a better service for our Perl community
and yourself, most certainly, to always keep in mind, you
are a Technical Journalist, not a writer.
Your attempts at writing creatively, are quite offensive
to this authoress.
Godzilla!
--
Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
BumScrew, South of Egypt ¦ HTML Programming Class
------------------------------
Date: Sun, 22 Oct 2000 15:35:31 +0100
From: "Billy" <billy@nospamforme.com>
Subject: Exporting from a cgi script
Message-Id: <yWCI5.5317$bL1.116562@news6-win.server.ntlworld.com>
Is there a straightfowrd way to export a file from a cgi script?
Ie, I'd like to be able to bring up a "Save..." dialog for the file
to be exported automatically, rather than saving the info to a file
and then generating a link to that file.
Any pointers greatly appreciated.
Billy.
---
After any salary raise, you will have less money at the end of the
month than you did before.
------------------------------
Date: Sun, 22 Oct 2000 10:41:34 -0400
From: "Colleen Tagg" <colleentagg@hotmail.com>
Subject: Great Employment Opportunities- NY/NJ Fortune 1000 Companies
Message-Id: <sv5v4lg241bl95@corp.supernews.com>
I would love to have the opportunity to work with you.
If you are looking to work for top companies such as
Merrill Lynch, Dow Jones,Citibank, Morgan Stanley, JP Morgan
and other top Financial/Brokerage firms, lets work together !
I am looking for strong professionals with stable backgrounds
preferably Java Programmers, Oracle DBA's and Developers, QA Testers and
Unix Administrators.
Please email a word attachment of your resume to colleentagg@hotmail.com I
will touch base with you once I review your resume !
------------------------------
Date: 22 Oct 2000 15:17:16 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: Great Employment Opportunities- NY/NJ Fortune 1000 Companies
Message-Id: <slrn8v617s.f8j.clay@panix2.panix.com>
On Sun, 22 Oct 2000 10:41:34 -0400, Colleen Tagg <colleentagg@hotmail.com>
wrote:
[ cc. to original poster ]
>I am looking for strong professionals with stable backgrounds
>preferably Java Programmers, Oracle DBA's and Developers, QA Testers and
>Unix Administrators.
Then post in a Java, Oracle or UNIX newsgroup if you must -- Don't spam the
Perl newsgroup!
--
Clay Irving <clay@panix.com>
1 trillion pins: 1 terrapin
------------------------------
Date: Sun, 22 Oct 2000 16:22:27 GMT
From: juneym@my-deja.com
Subject: help ..
Message-Id: <8sv47v$6gp$1@nnrp1.deja.com>
Hello!! i hav just downloaded and installed the Apache Server 1.3.14
and ActiveState Perl. How do i setup my perl interpreter so it will run
on my websever?? pls help..
thanks!!
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 22 Oct 2000 21:26:17 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Help with array concatenation
Message-Id: <slrn8v5g68.k23.mgjv@martien.heliotrope.home>
On Sun, 22 Oct 2000 02:30:21 -0400,
Jody Fedor <Jodyman@usa.net> wrote:
>
> Uri Guttman wrote in message ...
>
> >this is how you learn perl.
>
> I'm a learn by example type of programmer. I think I can learn
> more from the Perl Cookbook or programming to solve a problem
> better than reading a book from cover to cover. BUT, yes, I have
> read ALL the Camel book, All the Ram book, All the Llama book,
> Panther, Owl and currently reading the Cheetah book. I just ordered
Hmm, you've read more of them than I have :)
> Remember the first time you understood what $_ was? How
No, unfortunately, I don't. I started using Perl when all of the
documentation was a single page. $_ was mentioned very early on in the
page (just checked, about line 620 :)). The man pages for perl 4
mentioned it even earlier than that. I knew about $_ before I wrote my
first lines of Perl code. It was simply part of the language, just as
ARGV, FS and RS are part of awk, and regexes of sed.
> about #!/usr/bin/perl -w and use strict ? I've only been perl
The hash-bang notation wasn't strange to me, because I had been using
unices for quite a while already. It's not really a perl thing, but a
unix thing.
But I get your point. For someone with no exposure to awk, sed, shell,
unix, C or the early versions of Perl, the entry to Perl 5 can be quite
daunting.
But Uri's point is still valid. if you really want to learn Perl, you
_have_ to get comfortable with its documentation. Books get out of date.
Examples are sometimes not clear enough, and only describe one
particular case of the use of constructs and functions. The
documentation should always be used as a last reference. And while
you're at it, read some more of it. Some of it is actually quite
enlightening, and you might never read it unless you browse.
> programming for about a year now but I can remember asking
> the dumb questions. I wish I knew alot more so I could help
I still ask dumb questions. Or make dumb remarks. They're not ever a
problem, as long as you can get over your oen embarrassment.
> those who really are trying to learn perl by playing with the code
> until they get it right. I'll get there someday.
*nod*
> PS - I love the explained, step by step, examples given a lot of
> times, I learn more from them than a lecture or ref book.
Examples are about 43.8 times as powerful than dry description. And I am
not making that number up [1].
> PSS - Anyone heard of a Perl By Example book?
Hmmm.. I sort of see the Cookbook as a learn by example book. But I
guess you're talkingabout a learn Perl from the absolute beginnings by
example? Maybe Andrew Johnson's /Elements of Programming with Perl/
comes close?
Martien
[1] Ok, stop twisting my arm, I admit. I am making it up.
--
Martien Verbruggen |
Interactive Media Division | Can't say that it is, 'cause it
Commercial Dynamics Pty. Ltd. | ain't.
NSW, Australia |
------------------------------
Date: Sun, 22 Oct 2000 22:10:40 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Help with array concatenation
Message-Id: <slrn8v5ipg.k23.mgjv@martien.heliotrope.home>
On Sun, 22 Oct 2000 21:26:17 +1100,
Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
> I still ask dumb questions. Or make dumb remarks. They're not ever a
> problem, as long as you can get over your oen embarrassment.
^^^
own
> Examples are about 43.8 times as powerful than dry description. And I am
^^^^
42.8
Martien
--
Martien Verbruggen |
Interactive Media Division | Useful Statistic: 75% of the people
Commercial Dynamics Pty. Ltd. | make up 3/4 of the population.
NSW, Australia |
------------------------------
Date: Sun, 22 Oct 2000 08:51:16 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Help with array concatenation
Message-Id: <slrn8v5om4.dho.tadmc@magna.metronet.com>
On Sun, 22 Oct 2000 21:26:17 +1100, Martien Verbruggen
<mgjv@tradingpost.com.au> wrote:
>On Sun, 22 Oct 2000 02:30:21 -0400,
> Jody Fedor <Jodyman@usa.net> wrote:
>>
>> Uri Guttman wrote in message ...
>>
>> >this is how you learn perl.
>>
>> I'm a learn by example type of programmer. I think I can learn
>> more from
[ snip list of books ]
>But Uri's point is still valid. if you really want to learn Perl, you
>_have_ to get comfortable with its documentation. Books get out of date.
>Examples are sometimes not clear enough, and only describe one
>particular case of the use of constructs and functions.
Books have lots of disadvantages compared to the standard docs
(PODs) delivered with every perl distribution:
1) They are out of date before they hit the shelves. PODs are
updated with each new perl release.
2) They have been subjected to only limited "review" (perhaps
less than a dozen have "validated" it). PODs are reviewed
by hundreds/thousands of sets of eyes.
When a mistake slips through in a book, it can be fixed at
the next edition of the book (i.e. in a few years). Mistakes
in PODs can be fixed at the next perl release.
3) Authors may "know" Perl, or may not. PODs are written by the
people who code up the perl interpreter itself.
4) You can't cut and paste code from dead trees.
5) They cost money. PODs are free.
6) You have to go get them. PODs are installed when you install perl
(i.e. they are "already there", and you can count on every Perl
programmer having access to them.
)
Some of those are significant reasons, some of only middling
importance. But I think the one below is enough all by itself
to convince you (or me, at least) to prefer PODs to books:
7) You are at the mercy of the Indexer. I can word search the
PODs for any word I choose.
>The
>documentation should always be used as a last reference.
^^^^^^^^^^^^^^
Note that the usage of "last" above is as in "the final authority".
Since they are the most authoritative source of Perl info,
they should be a *first* reference chronologically speaking :-)
>> programming for about a year now but I can remember asking
>> the dumb questions. I wish I knew alot more so I could help
>
>I still ask dumb questions. Or make dumb remarks.
I can vouch for Martien on those statements.
heh heh.
>They're not ever a
>problem, as long as you can get over your oen embarrassment.
Posting gaffs in front of hundreds of people is a very effective
way of "internalizing" lessons learned.
I'm speaking from experience here. I've learned lots of Perl
by posting an incorrect solution on clpmisc :-)
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 22 Oct 2000 12:02:42 -0400
From: "Randy Harris" <harrisr@bignet.net>
Subject: Re: Help with array concatenation
Message-Id: <sv63rvcpgo9fd7@corp.supernews.com>
Jody Fedor <Jodyman@usa.net> wrote in message
news:8su1ov$4v8$1@plonk.apk.net...
>
> Uri Guttman wrote in message ...
>
> >this is how you learn perl.
>
> I'm a learn by example type of programmer. I think I can learn
> more from the Perl Cookbook or programming to solve a problem
> better than reading a book from cover to cover. BUT, yes, I have
> read ALL the Camel book, All the Ram book, All the Llama book,
> Panther, Owl and currently reading the Cheetah book. I just ordered
> the Mouse too! I'm keeping O'Reilly in business as well as alot
> of the GURU posters in this newsgroup. Excellent books all but
> hard to understand until you run into a problem that requires their
> expertise and then you read them in a new light.
>
> Remember the first time you understood what $_ was? How
> about #!/usr/bin/perl -w and use strict ? I've only been perl
> programming for about a year now but I can remember asking
> the dumb questions. I wish I knew alot more so I could help
> those who really are trying to learn perl by playing with the code
> until they get it right. I'll get there someday.
>
> Jody
>
My experience has been very similar. I've done more than my share to
help O'Reilly as well. My first purchase was the camel, I read it and
re-read it, but was unable to grasp many of the concepts. I've learned
by doing. I occasionally look back at some of my earlier efforts. I
would be highly embarrassed to show them to anyone. The code works, but
the style and technique are abominable.
OTOH, I've found CLPM a fabulous learning resource. Real world problems
at many different levels of complexity and sample solutions. I study
the sample code and learn from the responses. With maybe the exception
of the Ram, all of the books are very short on examples. Perldoc, too,
is good as a reference but certainly was not intended to instruct.
A number of participants in CLPM have reported that they found Perl easy
to learn. Not so for me. Thoughts of old dogs and new tricks come to
mind.
Randy Harris
> PS - I love the explained, step by step, examples given a lot of
> times, I learn more from them than a lecture or ref book.
>
> PSS - Anyone heard of a Perl By Example book?
>
>
>
------------------------------
Date: Sun, 22 Oct 2000 09:40:42 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Help with array concatenation
Message-Id: <39F3188A.CBB70E93@stomp.stomp.tokyo>
Tad McClellan wrote:
> Martien Verbruggen wrote:
> > Jody Fedor wrote:
> > > Uri Guttman wrote:
> > > > this is how you learn perl.
> > > I'm a learn by example type of programmer. I think I can learn
> > > more from
> [ snip list of books ]
> > But Uri's point is still valid. if you really want to learn Perl, you
> > _have_ to get comfortable with its documentation. Books get out of date.
> > Examples are sometimes not clear enough, and only describe one
> > particular case of the use of constructs and functions.
> Books have lots of disadvantages compared to the standard docs
> (PODs) delivered with every perl distribution:
(snipped)
Your displayed logic and rationale, McClellan, for a
best method to learn Perl programming is to make use
of documentation rather than textbooks, is analogous
to instructing young students the best way to learn to
read and write, is to make use of a dictionary rather
than make use of instructional textbooks.
Incidently Verbruggen, books don't "get" out-of-date.
Books "become" out-of-date. You won't learn this from
a dictionary. You will learn this from an instructional
textbook and, you can enhance your learning by use of
a dictionary.
Godzilla!
--
Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
BumScrew, South of Egypt ¦ HTML Programming Class
------------------------------
Date: Sun, 22 Oct 2000 13:09:10 -0400
From: "Jody Fedor" <Jodyman@usa.net>
Subject: Re: Help with array concatenation
Message-Id: <8sv76p$lpd$1@plonk.apk.net>
Ren Maddox wrote in message ...
>"Jody Fedor" <Jodyman@usa.net> writes:
>
>[snip]
>> Any help would be appreciated.
>
>Uri already gave you some great information that should get you going,
>but I thought I would point out the specific problem you are hitting...
>
>> @dates = unpack(A3 x ((length($cline)/3)+1), $cline);
>
>This lines replaces the value of @dates every time it executes. You
>probably want something like:
>
>push @dates, unpack...
push @dates = unpack("A3" x ((length($cline)/3)+1), $cline);
using this I get the following error:
Type of arg 1 to push must be array (not list assignment) at caltest.pl line
36.
Execution of caltest.pl aborted due to compilation errors.
Did I do something wrong?
Jody
------------------------------
Date: Sun, 22 Oct 2000 12:36:00 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Help with array concatenation
Message-Id: <slrn8v65rg.f4q.tadmc@magna.metronet.com>
On Sun, 22 Oct 2000 13:09:10 -0400, Jody Fedor <Jodyman@usa.net> wrote:
>
>>push @dates, unpack...
^
^
>
> push @dates = unpack("A3" x ((length($cline)/3)+1), $cline);
^
^
>using this I get the following error:
>
>Type of arg 1 to push must be array (not list assignment) at caltest.pl line
>36.
>Execution of caltest.pl aborted due to compilation errors.
>
>Did I do something wrong?
Yes.
Function arguments are separated by commas, not by equals signs :-)
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 22 Oct 2000 13:40:46 -0400
From: "Jody Fedor" <Jodyman@usa.net>
Subject: Re: Help with array concatenation
Message-Id: <8sv920$mku$1@plonk.apk.net>
Jody Fedor wrote in message <8sv76p$lpd$1@plonk.apk.net>...
>
>Ren Maddox wrote in message ...
>>Uri already gave you some great information that should get you going,
>>but I thought I would point out the specific problem you are hitting...
>>
>>> @dates = unpack(A3 x ((length($cline)/3)+1), $cline);
>>
>>This lines replaces the value of @dates every time it executes. You
>>probably want something like:
>>
>>push @dates, unpack...
>
> push @dates = unpack("A3" x ((length($cline)/3)+1), $cline);
I was able to get it to work doing the following but I'm sure using an extra
list array is probably not very perlish. i.e. easier way.
@date = unpack("A3" x ((length($cline)/3)+1), $cline);
push (@dates, @date );
I tried:
push (@dates, @dates = unpack("A3" x ((length($cline)/3)+1), $cline));
but still only returned the last row of dates.
Jody
------------------------------
Date: 22 Oct 2000 05:46:50 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: help with system ()
Message-Id: <m3bswdup9h.fsf@dhcp11-177.support.tivoli.com>
Russell Smallwood <rsmallwood@mindspring.com> writes:
> In article <MPG.145c47308969e261989683@news.giganews.com>,
> rsmallwood@mindspring.com says...
> >
> > Perhaps I've not taken my medication today, but I'm having trouble
> > passing a variable to an .exe file like this:
> >
> > system("d:\\my folder\\myprogram.exe $myvar");
You can save yourself a little trouble by using regular slashes
there. It works even on DOS/Windows...
> > If I use a literal
> >
> > system("d:\\my folder\\myprogram.exe 555");
> >
> > everything works, but with the var, the script just hangs.
> >
> > Have I missed something in the perldocs? Why can't you search the
> > perldocs? whah.
Type "perldoc perldoc" at a command prompt.
> I've also tried:
>
> @args=("d:\\my folder\\myprogram.exe",$myvar);
> system(@args)
>
> but to the same effect, the script hangs and the process doesn't
> terminate on the server.
Both of these look fine. It seems that $myvar is not set as you think
it is. Try replacing "system" with "print" and see if you get what
you expect.
Perhaps you could post a bit more of the code that exhibits the
problem, as this line isn't it.
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Sun, 22 Oct 2000 10:18:04 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: help with system ()
Message-Id: <slrn8v5tos.er1.tadmc@magna.metronet.com>
On Sun, 22 Oct 2000 05:28:25 GMT, Russell Smallwood
<rsmallwood@mindspring.com> wrote:
>Why can't you search the
>perldocs?
Why can't _you_ search the perldocs?
Most everybody else can.
They come with perl. You have perl so you have the docs somewhere.
Find them. Search them. No problem.
Or is there some other obstacle in your way?
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 22 Oct 2000 12:39:42 -0400
From: Russell Smallwood <rsmallwood@mindspring.com>
Subject: Re: help with system ()
Message-Id: <MPG.145ce255b028723b989687@news.giganews.com>
In article <m3bswdup9h.fsf@dhcp11-177.support.tivoli.com>,
ren.maddox@tivoli.com says...
> Russell Smallwood <rsmallwood@mindspring.com> writes:
>
> > In article <MPG.145c47308969e261989683@news.giganews.com>,
> > rsmallwood@mindspring.com says...
> > >
> > > Perhaps I've not taken my medication today, but I'm having trouble
> > > passing a variable to an .exe file like this:
> > >
> > > system("d:\\my folder\\myprogram.exe $myvar");
>
> You can save yourself a little trouble by using regular slashes
> there. It works even on DOS/Windows...
>
> > > If I use a literal
> > >
> > > system("d:\\my folder\\myprogram.exe 555");
> > >
> > > everything works, but with the var, the script just hangs.
> > >
> > > Have I missed something in the perldocs? Why can't you search the
> > > perldocs? whah.
>
> Type "perldoc perldoc" at a command prompt.
>
> > I've also tried:
> >
> > @args=("d:\\my folder\\myprogram.exe",$myvar);
> > system(@args)
> >
> > but to the same effect, the script hangs and the process doesn't
> > terminate on the server.
>
> Both of these look fine. It seems that $myvar is not set as you think
> it is. Try replacing "system" with "print" and see if you get what
> you expect.
>
> Perhaps you could post a bit more of the code that exhibits the
> problem, as this line isn't it.
>
>
A most useful reply, thank you for your input and patience.
Russell
------------------------------
Date: 22 Oct 2000 12:07:12 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: help with system ()
Message-Id: <8sv6s0$p35$1@provolone.cs.utexas.edu>
In article <slrn8v5tos.er1.tadmc@magna.metronet.com>,
Tad McClellan <tadmc@metronet.com> wrote:
>Why can't _you_ search the perldocs?
>
>Most everybody else can.
Is there any way of searching via perldoc? I've never found
one, but I've always wondered if I'm missing something,
since this seems like a bleedingly obvious thing to have.
For instance, I can type "perldoc -q faster" and get
information about increasing the performance of my Perl
script, but if I type "perldoc -q performance", I don't get
anything even thought this occurs in the text of the FAQ.
So, when I really want to search for a keyword, I find myself
doing things like:
$ cd /packages/perl/man
$ find . -type f -print | xargs grep -l performance
This *works*, but it doesn't seem like the best way. In
particular, it's a bit inconvenient because the rest of the
world doesn't store perl in /packages/perl like I do, so I have
to type a different pathname on different systems and stuff.
- Logan
------------------------------
Date: Sun, 22 Oct 2000 17:17:21 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: help with system ()
Message-Id: <39f32120.4873$3d5@news.op.net>
Keywords: Birmingham, Moloch, sidewise, steradian
In article <MPG.145c47308969e261989683@news.giganews.com>,
Russell Smallwood <rsmallwood@mindspring.com> wrote:
>Why can't you search the perldocs?
Print out documentation jsut for the 'system' function:
perldoc -f system
Print out parts of the perldocs that mention 'blarf':
perl -le 'print if /blarf/' pod/*.pod
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 V9 Issue 4689
**************************************