[10964] in Perl-Users-Digest
Perl-Users Digest, Issue: 4564 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 6 14:07:23 1999
Date: Wed, 6 Jan 99 11:00:23 -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 Wed, 6 Jan 1999 Volume: 8 Number: 4564
Today's topics:
Re: $a = `$cmd` repost <newsposter@cthulhu.demon.nl>
Re: Any good docs on maintaining Perl distributions? <newsposter@cthulhu.demon.nl>
Re: Can't find my way with a map (Larry Rosler)
Re: Can't find my way with a map (Andrew M. Langmead)
Re: Can't find my way with a map <michael_mongeau@stratus.com>
Re: CGI offline mode: enter name=value pairs on standar <jeromeo@atrieva.com>
Re: CGI offline mode: enter name=value pairs on standar dave@mag-sol.com
Re: Changing Environment Variables in a shell <bradw@newbridge.com>
Re: Combining Animated Gifs in Perl? <support@counter.w-dt.com>
Re: Combining Animated Gifs in Perl? (brian d foy)
Re: comp/comp3 numbers in Perl or maybe C JBHenry@excite.com
Re: comp/comp3 numbers in Perl or maybe C <wmklein@nospam.netcom.com>
Re: Does 'require' run the script automatically? <newsposter@cthulhu.demon.nl>
Re: I can't resist sharing this with you.... (Geoff Kinnel)
i can't understand a program <julou@france-mail.com>
Re: If Larry Wall's listening out there.... <dennis.kowalski@daytonoh.ncr.com>
Re: image editing <mike@crusaders.no>
Re: Interlinked file link checker (was: Passing vars to <uri@home.sysarch.com>
Re: JOB - CONTRACT POSITION <support@counter.w-dt.com>
Re: JOB - CONTRACT POSITION dave@mag-sol.com
Re: Nasty regexp .... help! (Lack Mr G M)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 06 Jan 1999 12:35:07 -0500
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: $a = `$cmd` repost
Message-Id: <36939EC9.1EE79C3E@cthulhu.demon.nl>
Edmond Shum wrote:
>
> Just found out that I posted this article in HTML yesterday. I hope this
> time
> it comes out in plain text.
It did :) If it had been html I wouldn't have read it.
[snip]
> I tried to modify the perl source code ( util.c ) of perl4.036.
> Basically
> I added the line in mypopen, which did an extra close when fork failed.
> This works good but I am not sure it will break any other things or not
You should really, really, really upgrade to a more recent version
of perl... 4.036 is unsupported and obsolete. Your problem probably
has been fixed already in a more recent version of perl.
Erik
--
Sure, doesn't everyone sign up for internet service so as to have
their mailbox stuffed with megabytes of postage-due rubbish every day?
Absolutely. And everyone who owns a car intends that it be used as a
portable dumpster. Any unwanted garbage in their vehicle they can
simply throw away, after all.
------------------------------
Date: Wed, 06 Jan 1999 13:05:33 -0500
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: Any good docs on maintaining Perl distributions?
Message-Id: <3693A5EB.CD74B8F2@cthulhu.demon.nl>
Jon Trudel wrote:
>
> I've searched the newsgroups, and looked through the perl FAQs at perl.org,
> and I haven't really come across any single document that talks about
> managing a Perl distribution. I've got several different architectures to
> maintain, and I've seen some things about acquiring Perl and installing
> modules, but nothing much that's on a higher level than nuts -n- bolts
> items.
What exactly do you mean by 'managing a distribution'?
> Does such a document exist? If so, please give me a pointer. Thanks!
In the CPAN man page there are some hints on how to install modules
on multiple machines/architectures. As far as I can remember the
'INSTALL/Makefile/README' files in the source code distribution
have some hints/suggestions as well.
Erik
--
Sure, doesn't everyone sign up for internet service so as to have
their mailbox stuffed with megabytes of postage-due rubbish every day?
Absolutely. And everyone who owns a car intends that it be used as a
portable dumpster. Any unwanted garbage in their vehicle they can
simply throw away, after all.
------------------------------
Date: Wed, 6 Jan 1999 09:11:05 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Can't find my way with a map
Message-Id: <MPG.10fd38ff151c2dda98997b@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <DR2nTBAvx4k2EwgS@connected.demon.co.uk> on Wed, 6 Jan 1999
16:16:47 +0000, Jerry Pank <jerryp.usenet@connected.demon.co.uk> says...
> I want to use map to remove leading/trailing quotes that may exist in a
> tab delimited file:
>
> Something along the lines of:
>
> @data = map { s/^"|"$//g; } split /\t/, $line;
>
> What do I need to change so @data is the result of the s/// rather than
> the number of matches?
Simpler than you expect. The 'map' returns the value of the last
expression evaluated, so:
@data = map { s/^"|"$//g; $_ } split /\t/, $line;
I haven't benchmarked it, but judging from the FAQ on trimming spaces
front and back, this might be faster (though not as clever):
@data = map { s/^"//; s/"$//; $_ } split /\t/, $line;
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 6 Jan 1999 17:33:27 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Can't find my way with a map
Message-Id: <F55FFr.DuC@world.std.com>
Jerry Pank <jerryp.usenet@connected.demon.co.uk> writes:
> @data = map { s/^"|"$//g; } split /\t/, $line;
>What do I need to change so @data is the result of the s/// rather than
>the number of matches?
>I can obviously do this in two lines but one would be neater and the map
>answer would satisfy my curiosity.
How about with more than one statement inside the map? The value
returned from map is the last expression evaluated.
@data = map { s/^"//; s/"$//; $_ } split /\t/, $line;
(The substitution was separated into two statements for the
performance advantage discussed in the FAQ entry about stripping
whitespace from strings.)
--
Andrew Langmead
------------------------------
Date: Wed, 6 Jan 1999 12:50:55 -0500
From: "Michael Mongeau" <michael_mongeau@stratus.com>
Subject: Re: Can't find my way with a map
Message-Id: <7707j6$be2@transfer.stratus.com>
Jerry Pank <jerryp.usenet@connected.demon.co.uk> wrote in message
news:DR2nTBAvx4k2EwgS@connected.demon.co.uk...
>I want to use map to remove leading/trailing quotes that may exist in a
>tab delimited file:
>
>Something along the lines of:
>
> @data = map { s/^"|"$//g; } split /\t/, $line;
>
>What do I need to change so @data is the result of the s/// rather than
The value returned from the map block is the result of the expression within
the block. Since s/// returns the number of substitutions made, that's
what's returned. You can have multiple statements in the block - simply
return the changed variable ($_) as the last statement, like this:.
@data = map { s/^"|"$//g; $_ } split /\t/, $line;
The problem with this is that the s/// modifies the original list being
mapped. If that's a problem you can create a local variable and perform the
substitution on that:
@data = map { (my $x = $_) =~ s/^"|"$//g; $x } split /\t/, $line;
This example is courtesy of "Effective Perl Programming", an excellent book.
I highly recommend it for intermediate to advanced Perl programmers.
Michael Mongeau
------------------------------
Date: Wed, 06 Jan 1999 09:12:07 -0800
From: Jerome O'Neil <jeromeo@atrieva.com>
To: Uwe Kohl <kohl@dik.maschinenbau.tu-darmstadt.de>
Subject: Re: CGI offline mode: enter name=value pairs on standard input
Message-Id: <36939967.D0390EE9@atrieva.com>
Uwe Kohl wrote:
> I get the error message: "offline mode: enter name=value pairs on
> standard input"
> With Cntrl D input the script goes on, but I want to call it from
> HTML.
>
> What's wrong?
Nothing. CGI.pm will ask your for name/value pairs if run offline.
This is to give you an opportunity to add form input values. It's quite
handy. If your program is called by the server in response to a client
request, it will run normaly.
--
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947
The Atrieva Service: Safe and Easy Online Backup http://www.atrieva.com
------------------------------
Date: Wed, 06 Jan 1999 17:43:32 GMT
From: dave@mag-sol.com
Subject: Re: CGI offline mode: enter name=value pairs on standard input
Message-Id: <7707c4$rbm$1@nnrp1.dejanews.com>
In article <36937783.B9353E9E@dik.maschinenbau.tu-darmstadt.de>,
Uwe Kohl <kohl@dik.maschinenbau.tu-darmstadt.de> wrote:
>
> --------------09769D5682964EB83CDEE103
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
*Please* don't send MIME-encoded messages to newsgroups.
> Hello,
> I just installed Perl 5.00502 to use CGI.pm.
> It seems all ok, but when I start, for exampel, this test-script:
>
> #!/dfs/users/kohl/perl/bin/perl
> use CGI qw/:standard/;
> print header (),
> start_html(-title=>'Wow!'),
> h1('WOW!'),
> 'Look MA no hands!',
> end_html();
>
> I get the error message: "offline mode: enter name=value pairs on
> standard input"
> With Cntrl D input the script goes on, but I want to call it from HTML.
>
> What's wrong?
Nothing is wrong. It's CGI.pm's extremely useful command-line debugging
facility. I suggest you read the CGI.pm documentation carefully before doing
any more coding.
hth,
Dave...
--
Dave Cross
Magnum Solutions Ltd: <http://www.mag-sol.com/>
London Perl M[ou]ngers: <http://london.pm.org/>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 06 Jan 1999 12:50:55 -0500
From: bj <bradw@newbridge.com>
Subject: Re: Changing Environment Variables in a shell
Message-Id: <op1ww30b88w.fsf@kannews.newbridge.com>
ced@bcstec.ca.boeing.com (Charles DeRykus) writes:
> In article <368C9587.DDFE742C@mihy.mot.com>,
> Ramanujam Parthasarathi <rpsarathi@usa.net> wrote:
> >
> >I'm trying to change the environment variables of the shell using PERL.
> >Its a fact that the modifications are 'local' (PERLish) to the script
> >(and any child processes). Is there any way I can modify the Environment
> >variables (%ENV) of the current shell?
> >
> >What I want to do is to set the environment variables (like PATH, etc.,)
> >dynamically as when required - this way we can have a script which can
> >take the s/w package name as argument and make the appropriate settings
> >to the environment.
> Something like this may work if you have a reasonable shell:
> (where 'host:' is your shell prompt)
>
> host: eval `perl -we 'print q(export BACK_TO_SHELL=foo)'`
or
1) source wrapper script
2) wrapper script calls perl program
3) perl program builds tmp shell specific syntax file
4) wrapper script sources tmp file
Current environment, in current shell is changed, according to
whatever you built in tmp file. Child shells inherit changed
environment and tool is happy.
You can easily pass arguments though the wrapper to the perl program
and have it take action accordingly.
We do exactly this, using a central database to define all the
environmental requirements for all the different cad tools we
support. The perl program verifies that the requirements are
compatible and then builds appropriate environments for user requested
"toolsuites". With one database and one perl program we can support
multiple versions of all our cad tools, running on multiple os's and
shells, from an envrionmental variable prespective.
It is really more of a os/environment issue so email me and we can
take it offline, if you want more details.
bj
------------------------------
Date: Wed, 06 Jan 1999 11:11:43 -0600
From: Mike <support@counter.w-dt.com>
Subject: Re: Combining Animated Gifs in Perl?
Message-Id: <3693994E.157C29E2@counter.w-dt.com>
Gif construction set doesn't combine them on the fly in a perl script now
does it?
dana wrote:
> You don't even need perl for this. The easiset way to do this is to use
> GIF Construction Set. It's a super easy to use program that lets you do
> this sort of thing and can be found at http://www.mindworkshop.com/ the
> have a fully functioning demo version.
>
> Diana
>
> Mike wrote:
>
> > Does any one know of a program that would allow me to combine two gifs,
> > one animated and one unanimated? By combining I mean place the
> > unanimated one to the right of the animated one and combine it into one
> > image file. I have been using fly but it seems that it doesn;t support
> > animated gifs. Please reply if you know of any program or if you have
> > some source code that would allow this in perl. Thanks.
------------------------------
Date: Wed, 06 Jan 1999 13:46:04 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Combining Animated Gifs in Perl?
Message-Id: <comdog-ya02408000R0601991346040001@news.panix.com>
In article <3693994E.157C29E2@counter.w-dt.com>, Mike <support@counter.w-dt.com> posted:
> Gif construction set doesn't combine them on the fly in a perl script now
> does it?
Image::Magick can do what you want in a few lines of code.
good luck :)
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Wed, 06 Jan 1999 17:07:30 GMT
From: JBHenry@excite.com
Subject: Re: comp/comp3 numbers in Perl or maybe C
Message-Id: <77058f$pcm$1@nnrp1.dejanews.com>
In article <76tolm$kh2$1@nnrp1.dejanews.com>,
aixgod@ix.netcom.com wrote:
>I'm trying to write out a data file from Perl (on unix) that the mainframe
>guys are telling me needs to have a "comp3" number in it (I think this is
>also called a Cobol signed comp-3 number maybe). What I'm encoding is
>actually a date listed as "julian packed" on my little sheet of info here,
>for that's worth. Clearly, I have little idea what these numbers are or how
>to make one....I'm just throwing this post out here in hopes that someone has
>some code that will do the conversion. I'd like to write this number out
>from Perl, but I'll use C if necessary.
A "COMP-3" number in Cobol is a binary coded decimal integer. Basically,
each digit of your number is "packed" into 4 bits (nyble) of the COMP-3
number, with the last nyble becoming the sign. For example, converting
the number 1234 would give you 0x01234F (in hexidecimal). Hex 'F' or 'C'
are used for a positive sign, and 'D' is used for negative. Note the
extra leading 0 fill it out to a full byte. Your mainframer's will
probably expect a field of a certain size, so you may have to do further
pading. This should be pretty easy to do using perl's pack and unpack
functions with the 'H' format. Sorry I don't have any example code
handy.
By "julian packed" they probably mean something in the format YYDDD or
YYYYDDD. This will pack nicely into a 3 or 4 byte COMP-3.
>Additionally, for a separate file that will eventually be loaded into DB2 on
>the mainframe, I need to write out a normal "comp" number (not comp3),
>whatever that is. Any help here would be appreciated to.
A "COMP" in Cobol is just a binary integer, like an int or long in C.
Again, pack and unpack will be your friends.
>I'm hoping that if I select binary format on the ftp to the mainframe that
>none of this data will get distorted or converted on the way up....
Shouldn't be a problem, but remember that if you use binary mode, all of
your text data will _not_ get translated from ASCII to EBCDIC. The m/f
probably expects EBCDIC for everything. Looks like you might be stuck
doing your own translation.
>Thanks for any assistance!
>Dylan Tynan
>
I hope this helps, and good luck!
Jeff Henry.
P.S. Please don't tell anybody that I acted like I know COBOL! :-)
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 6 Jan 1999 11:57:38 -0600
From: "William M. Klein" <wmklein@nospam.netcom.com>
Subject: Re: comp/comp3 numbers in Perl or maybe C
Message-Id: <770851$ct6@dfw-ixnews4.ix.netcom.com>
For those who are about to scream about the answer that was given by Jeff
BUT ALL THE COMP values are HARDWARE/SOFTWARE/COMPILER dependent,
Please notice the original reference to "DB2" which makes the assumption
that the "mainframe" is an "IBM mainframe" fairly safe.
Note to original requester: If you are *NOT* talking about an IBM
mainframe, then the answers given below may (and probably ARE) *wrong*
FYI,
The response given for "COMP" (not COMP-3) is a little incomplete. There
are methods in IBM mainframe COBOL of specifying COMP fields that create
half-word, full-word, or double-word binary fields (and with many PC
products single-byte binary fields - but if you get into PC's, then you need
to worry about big-endian/little-endian issues as well).
JBHenry@excite.com wrote in message <77058f$pcm$1@nnrp1.dejanews.com>...
>In article <76tolm$kh2$1@nnrp1.dejanews.com>,
> aixgod@ix.netcom.com wrote:
>>I'm trying to write out a data file from Perl (on unix) that the mainframe
>>guys are telling me needs to have a "comp3" number in it (I think this is
>>also called a Cobol signed comp-3 number maybe). What I'm encoding is
>>actually a date listed as "julian packed" on my little sheet of info here,
>>for that's worth. Clearly, I have little idea what these numbers are or
how
>>to make one....I'm just throwing this post out here in hopes that someone
has
>>some code that will do the conversion. I'd like to write this number out
>>from Perl, but I'll use C if necessary.
>
>A "COMP-3" number in Cobol is a binary coded decimal integer. Basically,
>each digit of your number is "packed" into 4 bits (nyble) of the COMP-3
>number, with the last nyble becoming the sign. For example, converting
>the number 1234 would give you 0x01234F (in hexidecimal). Hex 'F' or 'C'
>are used for a positive sign, and 'D' is used for negative. Note the
>extra leading 0 fill it out to a full byte. Your mainframer's will
>probably expect a field of a certain size, so you may have to do further
>pading. This should be pretty easy to do using perl's pack and unpack
>functions with the 'H' format. Sorry I don't have any example code
>handy.
>By "julian packed" they probably mean something in the format YYDDD or
>YYYYDDD. This will pack nicely into a 3 or 4 byte COMP-3.
>
>>Additionally, for a separate file that will eventually be loaded into DB2
on
>>the mainframe, I need to write out a normal "comp" number (not comp3),
>>whatever that is. Any help here would be appreciated to.
>
>A "COMP" in Cobol is just a binary integer, like an int or long in C.
>Again, pack and unpack will be your friends.
>
>>I'm hoping that if I select binary format on the ftp to the mainframe that
>>none of this data will get distorted or converted on the way up....
>
>Shouldn't be a problem, but remember that if you use binary mode, all of
>your text data will _not_ get translated from ASCII to EBCDIC. The m/f
>probably expects EBCDIC for everything. Looks like you might be stuck
>doing your own translation.
>
>>Thanks for any assistance!
>>Dylan Tynan
>>
>I hope this helps, and good luck!
>
>Jeff Henry.
>
>P.S. Please don't tell anybody that I acted like I know COBOL! :-)
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 06 Jan 1999 13:31:31 -0500
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: Does 'require' run the script automatically?
Message-Id: <3693AC00.CCB556ED@cthulhu.demon.nl>
strattner@my-dejanews.com wrote:
>
> I am new to Perl, aware of the common reaction to newbie questions in this
> newsgroup, and decided to post a question anyway...how's that for unjustified
> optimism? (Please keep any snide answers to yourself)
This is like waving a red flag in front of a bull :)
> Anyway, here's my question/problem: I have some Perl scripts. Each contain
> exactly one subroutine. The subroutines handle the bulk of the processing;
> the main program merely presents it in a verbose manner. In general, the
> scripts are of the form:
>
> #!/usr/bin/perl
> ....sub code (returns an array)
> ....main code
> .....call sub
> .....print results of sub in a user-friendly format
> .end
[snip]
> I have the Perl documentation (in html format), but I can't find
> anything of relevance there either. Could someone direct me to where the
> answer can be found? Any constructive help will be appreciated.
from the documentation on 'require':
Otherwise, demands that a library file be included if it hasn't already
been included. The file is included via the do-FILE mechanism, which is
essentially just a variety of eval().
from the documentation on 'do':
do EXPR
Uses the value of EXPR as a filename and executes the contents of
the file as a Perl script. Its primary use is to include subroutines
from a Perl subroutine library.
So yes, require runs the entire required script, including your user-friendly
formatted code, but you already figured that out.
Split the required files into two files. One containing the actual subroutines,
the other containing the 'main' code (and requiring the subroutine script).
Your main program can now require the plain subroutine scripts, and by running
the scripts containing the 'main' code, you can get the user-friendly
formatted output.
Erik
------------------------------
Date: Wed, 06 Jan 1999 12:13:18 -0500
From: kinnelg@bms.com (Geoff Kinnel)
Subject: Re: I can't resist sharing this with you....
Message-Id: <kinnelg-0601991213180001@d2465-hp4m.lvl.pri.bms.com>
In article <76uhd4$ofh$1@news.akl.netlink.net.nz>, "Andrew Mayo"
<andrew@geac.co.nz> wrote:
>
> while (<>)
> {
> ($re=$_)=~s/(\()|(\))|./\1.\2/sg;
> print ((/$re/s)[0]);
> }
>
> Try it with
>
> (a+b+(c/d)+e)+(g+h)
>
> and it will match the first part of the expression i.e (a+b+(c/d)+e)
>
> but, gentlefolk, how does it work?. Hint: try printing $re to see what the
> initial substitution does.
Wow. This just blew me away.
The first substitution, in effect, goes through $_ one char at a time,
replacing what's there with one of the following: (. or . or .) and
assigning the result to $re, as you see.
The second match matches $re against $_ in an array context, and prints
the first element. Try print ((/$re/s)[1]); and see what you get.
perlop tells us this about m//:
"If used in a context that requires a list value, a pattern match returns
a list consisting of the subexpressions matched by the parentheses in the
pattern, i.e., ($1, $2, $3...)."
I learned about ten things from these two lines of perl. Thanks.
Geoff
------------------------------
Date: Wed, 06 Jan 1999 19:07:03 +0100
From: julou <julou@france-mail.com>
Subject: i can't understand a program
Message-Id: <366C1B3F.22AAD94@france-mail.com>
hi errybody there,
is anyone here able to understand that?
$_ = "112"
$_ = $1 while (/(12)/);
print;
i'm just a beginner in perl, and i try to understand a program, but i'm
just a beginner
also, i'm looking for a good book about perl, for to learn it, in frecnh
if possible, so if anyone here know a good one :)
thank you
julien
------------------------------
Date: Wed, 06 Jan 1999 13:28:29 -0500
From: Dennis Kowalski <dennis.kowalski@daytonoh.ncr.com>
Subject: Re: If Larry Wall's listening out there....
Message-Id: <3693AB4D.AD6@daytonoh.ncr.com>
Andrew Mayo wrote:
>
> Dear Larry and friends,
>
> What a wonderful thing you have wrought.... but there's one small
> detail.....
>
> Those of us working in a Windows environment generally will use notepad as a
> text editor. Simple-mindedly, notepad does *not* display line numbers. (it
> also doesn't do brace matching, but this I can live with)
>
> Unfortunately, perl's syntax checker appears to assume we'll be using
> something like vi, and so I get things like
>
> Missing right bracket at line 101...
>
> and with no printed context of where the parser blew up, I have to count
> lines. This gets rapidly tedious. Particularly since I am not a very
> experienced Perl programmer, to say the least...
>
> I cannot find a command-line switch to give me more detailed error
> reporting; if there is one, my apologies, but what I really would like is
>
> foo(x,y,z
> ^
> Missing right bracket at line 101
>
> (the ^ is supposed to be just after the z, should your browser mangle the
> above)
>
> Is there any way I can get Perl to print the context of the error message or
> am I stuck counting lines. If the latter, may I humbly suggest this as an
> enhancement for a future version?. While you're in there, how about a
> severity level option for warnings, too, so that the -w flag could take a
> parameter to indicate just how picky Perl ought to be.
>
> PS:
>
> At the risk of incurring the flames and wrath of a zillion Perl programmers,
> and, worse, being a novice by my own admission, some aspects of Perl strike
> me as worthy of mention, in comparison to other programming languages I have
> used.
>
> Pros
>
> 1. Incredibly powerful for text munging - which is why I am using it, since
> I have a bunch of VB programs to mangle and I certainly wouldn't want to try
> mangling them given VB's very limited string functions.
>
> 2. Portable and concise, yet efficient; can process a lot of stuff with
> amazing speed on even humble hardware.
>
> 3. Rock-solid and extremely well documented (thanks, O'Reilly and
> associates).
>
> 4. Can't beat the price.
>
> 5. Tied variables - what an excellent idea. Also the package concept and the
> way objects have been implemented.
>
> Cons
>
> (note: I raise these because I want to write elegant yet maintainable code
> and these cons seem to put barriers up in front of me - perhaps illusory
> ones, of course, were I more knowledgeable)
>
> 1. Programs rapidly become unreadable if special care isn't taken to comment
> carefully. This is due not just to leaning toothpick syndrome, which is
> curable by careful choice of quote characters, as well as the quotemeta
> function, but because almost every metacharacter sequence that could exist
> has a semantic meaning which of course can't be deduced without looking it
> up, until you become a Perl veteran. Of course C++ suffers badly from this,
> too. At the other extreme, I know COBOL has been roundly condemned for its
> verbosity but MOVE A TO B or PERFORM X VARYING Y FROM 1 BY 1 UNTIL Y > 3
> express the intent in such a way that the syntax, once learnt, is never
> forgotten. I have not written a line of COBOL for 10 years, but I think most
> of the language is still with me - it has so much noise in it.
>
> 2. No macro pre-processor (AFAIK) which would let me add a bit of syntactic
> sugar; most experienced C programmers find #define and #typedef are
> invaluable for rendering sense out of chaos.
>
> 3. The variable argument list array is a nice idea but lack of proper
> subroutine prototypes makes code rather obscure. Yes, I do see the section
> on Perl 5.003 prototypes but, using VB as an example this time..
>
> sub DrawImage(pic as Picture, optional rotation as degrees=zero_degrees)
>
> it is relatively clear that the first argument is a picture, and the second,
> optional argument is the rotation in degrees, with the default being zero
> (degrees would be defined as an enum, probably, with perhaps four values for
> 0,90,180, and 270 degrees). Also the noiseword 'sub' tells me this routine
> returns nothing, as does
> 'void' in C - how do I indicate this in Perl?.
>
> I don't see how to write Perl code which comes close to being
> self-documenting in this way, particularly function arguments.
>
> A further, related issue is that arguments appear to be passed by reference,
> so that special care needs to be taken to avoid side-effects and there does
> not appear to be an easy way for the function prototype to define that an
> argument or arguments should be passed by value instead, as there is in both
> C and VB.
>
> 4. Lack of structures (aka VB types) and enums - at least, I can't find such
> things. Sure, hashes are very nice, but they're not really the same thing.
>
> 5. Try as I might, I find the bind operator counter-intuitive. Operating on
> $_ by default was probably a good idea back when Perl was sort of
> ancestrally-related to Awk, but having to use $myvar=~.... to get around
> this still seems peculiar; I may or may not actually be assigning to $myvar
> depending on whether the right-hand side of the expression is a match or a
> substitute.
>
> 6. Lack of strong typing. There are times when you want to prevent someone
> from assigning a string to an integer and I don't see how to do this with
> Perl - in fact, I don't know how to define a variable as being of a specific
> type (other than an array, or a hash or a simple variable). Variables just
> 'spring into existence' as they did in early versions of BASIC - which can
> lead to some very obscure programming errors. Does 'use strict' really help
> here?.
>
> 7. Lack of structured exception handling (I may, however, be wrong here, I
> just haven't found it yet).
>
> 8. No switch() or case statement, leading to nasty indented if... else if
> type of constructs.
>
> I conclude from these observations, some or all of which may turn out to be
> mistaken, that Perl is suitable for fairly small programs (and indeed, was
> designed this way, in all fairness) but that large Perl programming projects
> will need considerable care in order to be maintainable. Has anyone out
> there had experience in maintaining large (>10,000 line) Perl programs or
> program suites, and if so, what techniques would you recommend to maximise
> maintainability, other than the obvious recourse of commenting every line,
> which is currently what I am doing?.
>
> You may think that the notion of writing larger systems in Perl is
> ludicrous, but consider that if you want platform portability your current
> mainstream choices are
>
> (a) C/C++ - compiled, hence slow development cycle, needs to be rebuilt on
> each target platform, limited string processing (to say the least), easy to
> create memory leaks.
>
> (b) Java - primitive runtime libraries, lacks powerful string functions,
> still evolving, not under ANSI or open source control and hence subject to
> vendor change. Has to be compiled to JVM each time source is changed, unless
> someone knows of an incremental Java compiler (in which case this would have
> to be widely available across platforms
>
> or
>
> (c) Perl - open source, hence widely available for almost all platforms,
> interpreted, short development cycle, powerful string processing,
> extendable.
>
> As we move to GUI RAD environments under, say, Linux, we need a quick
> development language, similar to what we have with Visual Basic under
> Windows. Is Perl going to be that future, or Java, or some other language?.
> I understand someone's working on a Visual Perl, for instance.
I use edit.com in my WINDOWS95/NT environment.
It gives the line numbers.
------------------------------
Date: 6 Jan 1999 17:28:33 GMT
From: Trond Michelsen <mike@crusaders.no>
Subject: Re: image editing
Message-Id: <7706g1$5bt$1@romeo.dax.net>
On 6. Jan 4:32, Rahul K wrote:
> I would like to implement a *very simple* image editor using asp. The
> person would post an image (.jpg) and a string of text and the perl
> script will
> return a jpeg image with the text embeded in the image.
Sounds like you need ImageMagik, which has a perl-interface. ImageMagik can
do a lot more than just paste text onto an image, so maybe you'll find inspiration
to expand the web-service further ;-)
<URL:http://www.wizards.dupont.com/cristy/>
--
// Trond Michelsen
\X/ mike@crusaders.no
------------------------------
Date: 06 Jan 1999 13:11:59 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: Interlinked file link checker (was: Passing vars to HTML::Parser/globals with strict/link checking)
Message-Id: <x7aezwmftc.fsf@home.sysarch.com>
>>>>> "CM" == Chris Maden <crism@oreilly.com> writes:
CM> I am interested in hearing comments on my programming style (as my
CM> formal CS training is (nearly) zero), as well as if anyone finds this
CM> useful. It's primarily for sanity-checking interlinked sets of
CM> documents (like the O'Reilly CDs), not for checking if your bookmarks
CM> have gone stale.
it's hunting season guys! heh heh heh! i see wabbit twacks!
:-)
i don't have time to comment no on all the code but i found a few little
sections i could work over. for a supposedly self educated programmer,
you get passing marks. but you could definitely do better.
CM> #!/usr/local/bin/perl -w
CM> # I'm a good boy. Boy, is this a pain.
CM> use strict;
good boy on both -w and strict.
it is not pain, it is discipline, grasshopper.
why not make the main code a sub. i like programs to just have a few top
level sub calls in the beginning of the file. then it is very easy to
see the flow. putting main code at the end is a very C thing which i
don't like there either.
put all your argv handling code into a sub. cleans up the noise level.
CM> # You've got to give some arguments. DWIM is in the next version.
CM> if (!@ARGV) {
<SNIP>
CM> $verbose = 0;
CM> }
now here we get to something a little more meaty. why do you store the
file name in the object and use it from there. make that another my
variable and use it. then store it in the object if you need to keep it
for later use (which i don't see but i haven't looked too closely).
CM> # Parse each of the files on the command line.
CM> while ($p->{"file"} = shift @ARGV) {
while( $file = shift @ARGV) {
$p->{'file'} = $file;
another subtle stye point. use single quotes unless you are doing some
interpolation in the string. it is slightly faster (i think) but more
semantically accurate.
CM> # If the file's readable and a normal file,
CM> if (-r $p->{"file"} && -f $p->{"file"}) {
the second test could use the shortcut _ for the previous file tested.
if ( -r $file && -f _ )
CM> # ... otherwise, give an error.
CM> print "Can't open file " . $p->{"file"} . " for parsing.\n";
CM> }
CM> }
in general there is no need for a top level . operator in a print
statement. the comma will do the same and is much faster as you don't
build an intermediate string along the way. or using a here file or a
single string would look better. don't use . unless you have to. it is
hard to see and there are better ways to do the same things. one of the
few major wins for . is .= (append). or sometimes you must build a
string and store it, but when just printing it is not needed.
i haven't looked at most of the program but those are my quick comments.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Wed, 06 Jan 1999 11:09:06 -0600
From: Mike <support@counter.w-dt.com>
Subject: Re: JOB - CONTRACT POSITION
Message-Id: <369398B1.97C99DC3@counter.w-dt.com>
I could probably create it for you. Do you have a preference on what database
it uses? You would also want an interface to add stuff to it too right?
Anyway, down to the point, how much does it pay?
DICO wrote:
> Hi,
>
> I need a perl programmer to create a database program. This database
> will contain about 200 entries. Some entries will have more fields then
> others. The field information in each entry will be used to create a
> simply web page which will basically list the information in a neat table
> and show an image.
>
> So basically what will happen from a web surfers point of view is that
> they will want information on product A8395 and the perl script searches
> the database, finds the entry which matches that product id number, and
> then creates a web page which reflects the information in the database.
>
> If this sounds like something you can do, please email
> info@internetworks.ca for more information.
>
> Notes: Perl, Unix
------------------------------
Date: Wed, 06 Jan 1999 17:45:18 GMT
From: dave@mag-sol.com
Subject: Re: JOB - CONTRACT POSITION
Message-Id: <7707fe$re8$1@nnrp1.dejanews.com>
In article <MPG.10fd580ced933bcd989681@news.mtt.net>,
dico@internetworks.ca (DICO) wrote:
> Hi,
>
> I need a perl programmer to create a database program. This database
> will contain about 200 entries. Some entries will have more fields then
> others. The field information in each entry will be used to create a
> simply web page which will basically list the information in a neat table
> and show an image.
>
> So basically what will happen from a web surfers point of view is that
> they will want information on product A8395 and the perl script searches
> the database, finds the entry which matches that product id number, and
> then creates a web page which reflects the information in the database.
>
> If this sounds like something you can do, please email
> info@internetworks.ca for more information.
How much were you thinking of paying for this?
Dave...
--
Dave Cross
Magnum Solutions Ltd: <http://www.mag-sol.com/>
London Perl M[ou]ngers: <http://london.pm.org/>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 06 Jan 1999 17:34:33 GMT
From: gml4410@ggr.co.uk (Lack Mr G M)
Subject: Re: Nasty regexp .... help!
Message-Id: <1999Jan6.173433@ukwit01>
In article <36938F64.A4DA4A9C@altavista.net>, Zack <zack44@altavista.net> writes:
|> I don't know if it's possible to do this in a single expression, but here's what I've been beating my head against the wall trying to do:
|>
|> Scan a text string with the following rules:
|>
|> 1. Some words are "required"
|> 2. Other words are "optional"
|> 3. Others are to be "screened"
|>
|>....
|> What I've done so far is build up arrays containing the search terms (@opt, @req, @screen) and then try and go through them, building a big regexp string. No luck, and quite frankly, my brain is a bit cooked from looking at it so long.
|>
|> Any ideas? Is it possible to do this in a single =~ line?
Why get hungup on doing it in one line? Try concentrating on getting
it to work in a way that you (and others...) can see what is happening
and is reasonably efficient.
What about inverting the problem and doing something like this:
%required = qw( req1 => 1,
req2 => 1,
req3 => 1);
%optional = qw( opt1 => 1,
opt2 => 1,
opt3 => 1);
%screened = qw( scr1 => 1,
scr2 => 1,
scr3 => 1);
while (<DATA>) {
$required = $optional = $screened = 0;
foreach $word (split) {
exists $required{$word} && $required++;
exists $optional{$word} && $optional++;
exists $screened{$word} && $screened++;
}
print "$required required, $optional optional and $screened screened\n";
}
__DATA__
req1 req1 scr1 opt1 scr1
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 4564
**************************************