[14056] in Perl-Users-Digest
Perl-Users Digest, Issue: 1466 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 23 12:05:45 1999
Date: Tue, 23 Nov 1999 09:05:15 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <943376715-v9-i1466@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 23 Nov 1999 Volume: 9 Number: 1466
Today's topics:
Re: "The Art of Perl" (was Re: Perl programming sytle) (Mark W. Schumann)
Re: [JOB]: Web Developer/Senior Web Developer: SGML, XM <kbandes@home.com>
Re: A Cyber-Cigar for any Expert Help with Image Button (Dan Wilga)
Re: A tiny shell written in Perl <newsposter@cthulhu.demon.nl>
Re: A tiny shell written in Perl (Brett W. McCoy)
Re: Assigning an element of n associat. array to a scal (Tad McClellan)
Re: binarie operators like and & or .. (Clinton Pierce)
Re: cgi_mail to 2 ppl at once (Clinton Pierce)
Re: Commercial Open Group (COG) development (Tad McClellan)
Re: Deleting or Unlinking a file help <uri@sysarch.com>
Re: Deleting or Unlinking a file help <sariq@texas.net>
Re: file descriptors already used when perl starts (M.J.T. Guy)
Re: file descriptors already used when perl starts lee.lindley@bigfoot.com
getlogin() <paul.walker@st.com>
Re: getlogin() <gellyfish@gellyfish.com>
Re: GMT Time hdesa22@my-deja.com
HASH Implementation <bilcox@wnt.sas.com>
Re: HASH Implementation <Wm.Blasius@ks.sel.alcatel.de>
How to program Pseudo-TTY? <washmon@bigfoot.com>
Re: How to program Pseudo-TTY? (Clinton Pierce)
Re: How write records to ASCII file (Brett W. McCoy)
Re: How write records to ASCII file (Brett W. McCoy)
Re: How write records to ASCII file <lr@hpl.hp.com>
Need help with class-dependent constants <Wm.Blasius@ks.sel.alcatel.de>
Re: New dialect of perl: xperl (or reinventing perl, or excalibor@my-deja.com
Re: Newlines in formats <nospam@my-liquidinformation.net>
Re: Newlines in formats <rick.delaney@home.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 23 Nov 1999 10:08:00 -0500
From: catfood@apk.net (Mark W. Schumann)
Subject: Re: "The Art of Perl" (was Re: Perl programming sytle)
Message-Id: <81eakg$o3d@junior.apk.net>
In article <UMCZ3.62501$5W2.1736624@news6.giganews.com>,
Dave Roth <rothd@roth.REMOVE.net> wrote:
>Well agreed. When we code for our clients we run into a problem that they
>may have only C or VB experience. If we were to cop an attitude that we
>program in a Perlish way this would make it difficult for them to modify the
>code once the project is completed.
Maybe so, but that's why they called upon you. If they wanted the code
in C, they should have specified that.
Where did I read, "There is no substitute for knowing what you are
doing"? If you want to read someone else's Perl code, there's no
substitute for doing what you need to do to learn some Perl.
>Personally I find if fun to obfuscate however when others have to sort
>through my code they find it easier and quicker I use something like
>Hungarian notation or at least break it out is an easier to follow format.
>Even when I have to revise scripts that I have forgotten about it is easier
>for me if the code is easy to follow.
"Perl idiom" != "obfuscation" though.
------------------------------
Date: Tue, 23 Nov 1999 10:01:13 -0500
From: Kenneth Bandes <kbandes@home.com>
Subject: Re: [JOB]: Web Developer/Senior Web Developer: SGML, XML, PERL5, LINUX
Message-Id: <383AAC39.560B57C6@home.com>
"Christopher R. Maden" wrote:
>
> In article <slrn83j8gf.6u1.dha@panix.com>, dha@panix.com (David H. Adler) wrote:
> > You have posted a job posting or a resume in a technical group.
>
> You have failed to read the charter and/or FAQ for this newsgroup.
>
> Job postings, if on-topic, succinct, and clearly labeled, are appropriate
> for this newsgroup.
This is sheer fiction, although it may apply to another of the many
groups to which you have posted.
As for this group, comp.lang.perl.misc, the charter (posted
frequently as a mini-FAQ by Nathan Torkington) says:
"comp.lang.perl.misc is for questions on the Perl language."
Period.
What's your question on the Perl language?
Ken Bandes
------------------------------
Date: Tue, 23 Nov 1999 09:46:36 -0500
From: dwilgaREMOVE@mtholyoke.edu (Dan Wilga)
Subject: Re: A Cyber-Cigar for any Expert Help with Image Buttons
Message-Id: <dwilgaREMOVE-2311990946360001@wilga.mtholyoke.edu>
In article <81cf1j$lfn$1@nnrp1.deja.com>, colorcard@my-deja.com wrote:
> A Cyber-Cigar for anyone who can help me with this one...
>
> I have a form which uses a CGI script (AF2.CGI) for processing
> information. I MUST use images for the submit buttons and I am using
> multiple submit buttons. If I use standard (non-image) submit buttons
> such as
> <INPUT TYPE="SUBMIT" NAME="_browser_out" VALUE="preview1.txt">
> it works fine, but as soon as I use something like
> <INPUT TYPE="IMAGE" SRC="pics\layout2.jpg" NAME="_browser_out"
> VALUE="preview1.txt">
Your problem is probably that you're expecting a click on the INPUT
TYPE="IMAGE" to return something in the CGI variable called _browser_out.
It doesn't. Instead, you should check for the presence of _browser_out.x
and _browser_out.y, which are the X- and Y-coordinates of the location the
user clicked on.
Dan Wilga dwilgaREMOVE@mtholyoke.edu
** Remove the REMOVE in my address address to reply reply **
------------------------------
Date: 23 Nov 1999 14:28:10 GMT
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: A tiny shell written in Perl
Message-Id: <81e89q$605$4@internal-news.uu.net>
Song Wang <wsong@ece.uci.edu> wrote:
> I want to use Perl to write a tiny shell which includes
> the following functionalities:
> (1) executing a small set of commands, probably with arguments.
> (2) autocompletion of those commands.
> (3) executing a script containing commands.
> I don't know if CPAN has already had this kind of Perl modules.
> Any pointers to this kind of tiny shell are appreciated.
You could have a look at the CPAM.pm module itself.
Erik
------------------------------
Date: Tue, 23 Nov 1999 16:05:29 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: A tiny shell written in Perl
Message-Id: <slrn83lev1.9a2.bmccoy@moebius.foiservices.com>
Also Sprach Song Wang <wsong@ece.uci.edu>:
>I want to use Perl to write a tiny shell which includes
>the following functionalities:
A shell as in a Unix-like shell?
>(1) executing a small set of commands, probably with arguments.
>(2) autocompletion of those commands.
>(3) executing a script containing commands.
>
>I don't know if CPAN has already had this kind of Perl modules.
Maybe it does, maybe it doesn't. Try searching and seeing what it does.
Or grab a copy of the source to sh and rewrite it in Perl.
--
Brett W. McCoy bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek) http://www.foiservices.com
FOI Services, Inc./DIOGENES 301-975-0110
---------------------------------------------------------------------------
------------------------------
Date: Tue, 23 Nov 1999 05:59:32 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Assigning an element of n associat. array to a scalar variable
Message-Id: <slrn83kssk.b0e.tadmc@magna.metronet.com>
On Tue, 23 Nov 1999 20:55:54 +1100, Andrew Bleakley <pullen@one.net.au> wrote:
>I have parsed the information from a form and assigned the name/value pairs
>to assoc. array formdata.
>I then need to assign the value associated with 'name' to variable called
>$user_name. I cannot seem to make the assignment. Any help would be
>appreciated.
$user_name = $formdata{name};
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 23 Nov 1999 14:25:37 GMT
From: cpierce1@ford.com (Clinton Pierce)
Subject: Re: binarie operators like and & or ..
Message-Id: <383ca2f2.896238342@news.ford.com>
[poster cc'd in e-mail]
On Tue, 23 Nov 1999 13:01:08 +0100, "jan smit" <duthler@tebenet.nl> wrote:
>how can i compare bits in things ..like
>$something = "a";
>$something2 = $something & 0x80;
What are you trying to do here? Do an AND with the bit-representation of
"a"? Or are you really trying to AND a literal "a" and 0x80?
The former you've got wrong. Try this:
$something="a";
$something2= ord($something) & 0x80;
That compares the bits in the ASCII representation of "a" to 0x80.
The latter is nonsensical. "a" is being used where a number is expected,
so Perl is going to use the value of 0 instead. This works out to:
$something2 = 0 & 0x80;
Which is consistant, but utterly useless.
>that kinda stuff ..loolol .. could someone help me .. cuz im screwing up
>..loolol
"loolol" must be a weird .nl thing. Or maybe it's the bitstring you've
lost.
--
Clinton A. Pierce "If you rush a Miracle Man, you
clintp@geeksalad.org get rotten Miracles." -- Miracle Max,
http://www.geeksalad.org The Princess Bride
------------------------------
Date: Tue, 23 Nov 1999 14:12:39 GMT
From: cpierce1@ford.com (Clinton Pierce)
Subject: Re: cgi_mail to 2 ppl at once
Message-Id: <383aa060.895580296@news.ford.com>
On Tue, 23 Nov 1999 13:18:18 GMT, vod@writemail.com wrote:
>#!/usr/bin/perl
>
>require "../cgi-lib.pl";
Ouch. Have you considered using CGI.pm?
>my $mailTo = "tellmeall\@usa.net";
Have you considered simply adding a second address to this string?
$mailTo = "tellmeall\@usa.net foo\@bar.com";
>print MAIL "From: ghost\n
Tsk tsk tsk. That's not a valid return address. Naughty.
--
Clinton A. Pierce "If you rush a Miracle Man, you
clintp@geeksalad.org get rotten Miracles." -- Miracle Max,
http://www.geeksalad.org The Princess Bride
------------------------------
Date: Tue, 23 Nov 1999 06:08:52 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Commercial Open Group (COG) development
Message-Id: <slrn83kte4.b0e.tadmc@magna.metronet.com>
On Tue, 23 Nov 1999 01:06:40 GMT, Henning Strandin
<henning@travellab.com> wrote:
>The pay will be in company stock.
Programmers work for money.
Programmers are not (necessarily) investors.
misc.invest.* newsgroups would be a good place to look for
investors (well, better than in a computer language newsgroup
anyway).
>Stock is cheap now, but will probably increase to about 400-600% within
>a year.
Investors speculate, not programmers.
>Pay will be calculated from an hourly fee and an aproximation of the
>number of hours it would take a reasonably skilled programmer to finish
>the task. We don't care how long you spend, what your credentials are or
>whether you've ever programmed before. When the deadline arrives we
>evaluate any contributions and pay one or several people, depending on
>how we use the code.
So the programmer might get paid or might not?
That is not going to help you attract good programmers.
Good programmers can easily get paid for programming somewhere else.
>We need perl programmers most of all.
Get enough financing to hire programmers, then post to a
newsgroup with "jobs" in its name.
> Our systems run on Linux, use
>Apache and we plan to be using MySQL soon.
That is the only thing in your whole post that sounds attractive.
:-)
> I'm taking a leap with this,
>and I'm extremely interested in any reactions you might have to a scheme
>like this.
It ain't gonna work.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 23 Nov 1999 09:21:25 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Deleting or Unlinking a file help
Message-Id: <x71z9hnva2.fsf@home.sysarch.com>
>>>>> "JAL" == Jonathan A Laub <lakesoft@skypoint.com> writes:
JAL> This newsgroup is about PERL, not format-correct posting..get
JAL> enough of that crap at work.
strange to followup some flames with poor code.
JAL> Anyway, I did manage to figure out why files that are stored in
JAL> $vars are not deleted correctly. Do not know exactly why but
JAL> here is the solution:
best not to post code that "works' if you don't know why.
JAL> 1. You must install an "until file does not exist" loop.
JAL> 2. This will execute until the alias is closed and unlinked.
JAL> 3. Maybe it's a problem related to being run on a P600?? NT
JAL> environment???
maybe not?
JAL> Jon
why are you using c++ comments IN ALL CAPS in perl?
JAL> $kill= ("$xCOUNT.INP"); // PUT FILE TO DELETE INTO A NEW $VAR.
why the unnessasary parens? and a horrible name for a file about to be
unlinked.
JAL> print "</body>\n</html>\n"; // THIS MY LAST LINE WRITTEN TO THE
JAL> HTML.
JAL> until (!(-e"$xCOUNT.inp")){ // THE LOOP UNTIL THE FILE
double neagtive. add white space.
also as i said somewhere else in this thread (caps for the poster) THAT
NAME DOES NOT MATCH THE EARLIER ONE. USE THE SAME VAR
while ( -e $kill ) {
JAL> close(newfile); // CLOSE THE ALIAS
why keep closing a file in a loop?
JAL> $file_to_go = ($kill); // THIS IS PROBABLY
why more parens? why another assignment?
JAL> unlink ($file_to_go) // ATTEMP TO
how about testing this in a loop? and printing an warning if it fails
and even WHY it failed with $!
JAL> HHH wrote in message <38359CE5.FCFC2B07@westat.com>...
>> Uri Guttman wrote:
<snip>
and finally a TOTALLY SUPERFLUOUS JEOPARDY QUOTE WHICH YOUR POSTING
DOESN'T EVEN REFER TO!
hand,
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Tue, 23 Nov 1999 09:09:52 -0600
From: Tom Briles <sariq@texas.net>
Subject: Re: Deleting or Unlinking a file help
Message-Id: <383AAE40.62A8EE49@texas.net>
"Jonathan A. Laub" wrote:
>
> This newsgroup is about PERL
What's this 'PERL' I keep hearing about? And why is it that the people
who talk about it never seem to *know* much about it? And why don't
they have their own newsgroup?
> 3. Maybe it's a problem related to being run on a P600??
That would be my guess. I've certainly heard lots of reports of people
having problems removing files after upgrading their CPU.
> #
> ### THIS WORKS TO DELETE THE INPUT FILES FROM CLIPPER.
> #
> $kill= ("$xCOUNT.INP"); // PUT FILE TO DELETE INTO A NEW $VAR.
> print "</body>\n</html>\n"; // THIS MY LAST LINE WRITTEN TO THE
> HTML.
> until (!(-e"$xCOUNT.inp")){ // THE LOOP UNTIL THE FILE DOES NOT
> EXIST ANYMORE!
> close(newfile); // CLOSE THE ALIAS
> $file_to_go = ($kill); // THIS IS PROBABLY OPTIONAL -
> SINCE NO CHANGES HAVE BEEN MADE.
> unlink ($file_to_go) // ATTEMP TO DELETE/UNLINK THE
> FILE. -- GOOD LUCK!
> }
>
Hmmm...this PERL thing seems *somewhat* similar to Perl. Comments sure
are weird, though. PERL must have strange regex syntax.
If I were you, though, I'd add:
until ($kill= ("$xCOUNT.INP")) {
$kill= ("$xCOUNT.INP");
}
Just to be safe, you know? In fact, you could wrap *all* of your
statements in 'until' loops. Of course, to be *extra* safe, you should
wrap your 'until' loops in 'until' loops, too.
HTH. HAND.
- Tom
------------------------------
Date: 23 Nov 1999 15:37:29 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: file descriptors already used when perl starts
Message-Id: <81ecbp$n19$1@pegasus.csx.cam.ac.uk>
In article <81biia$uui$1@nnrp1.deja.com>, <g0177325@my-deja.com> wrote:
> mjtg@cus.cam.ac.uk (M.J.T. Guy) wrote:
>>
>> As various others have remarked, they aren't for me.
>>
>> But I'll gaze into my crystal ball and guess that you're running on
>> some flavour of Linux. There is a bug in some versions of glibc
>> that causes open to allocate a file descriptor other than the lowest
>> available, explicitly contrary to POSIX and to Linux's own man page.
>
>And from Lee lindley's posts, apparently Solaris is afflicted too.
Nope. Solaris 2.6, at least, gives '34'.
When I said "they aren't for me", that referred to Solaris 2.6 among others.
Mike Guy
------------------------------
Date: 23 Nov 1999 16:13:45 GMT
From: lee.lindley@bigfoot.com
Subject: Re: file descriptors already used when perl starts
Message-Id: <81eefp$cfj$1@rguxd.viasystems.com>
M.J.T. Guy <mjtg@cus.cam.ac.uk> wrote:
:>In article <81biia$uui$1@nnrp1.deja.com>, <g0177325@my-deja.com> wrote:
:>> mjtg@cus.cam.ac.uk (M.J.T. Guy) wrote:
:>>>
:>>> As various others have remarked, they aren't for me.
:>>>
:>>> But I'll gaze into my crystal ball and guess that you're running on
:>>> some flavour of Linux. There is a bug in some versions of glibc
:>>> that causes open to allocate a file descriptor other than the lowest
:>>> available, explicitly contrary to POSIX and to Linux's own man page.
:>>
:>>And from Lee lindley's posts, apparently Solaris is afflicted too.
:>Nope. Solaris 2.6, at least, gives '34'.
:>When I said "they aren't for me", that referred to Solaris 2.6 among others.
I got '37' running in an xterm and from a telnet session in Solaris 2.7.
My shell was /bin/ksh.
I got '34' running from "at". I assumed it was some tty driver code.
Oh. How very bizarre. Now I cannot reproduce it. And yet I look back
at my posts and there it was. I must not have been doing what I
thought I was doing.
--
// Lee.Lindley /// I used to think that being right was everything.
// @bigfoot.com /// Then I matured into the realization that getting
//////////////////// along was more important. Except on usenet.
------------------------------
Date: Tue, 23 Nov 1999 15:44:15 +0000
From: Paul Walkerp <paul.walker@st.com>
Subject: getlogin()
Message-Id: <383AB64F.774CF282@st.com>
Hi all,
Quick question - getlogin() is limited to returning 8 characters for a
username. Is that because the OS only returns 8 characters, or just a
limitation for some other reason?
Thanks,
------------------------------
Date: 23 Nov 1999 16:19:50 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: getlogin()
Message-Id: <383abea6_2@newsread3.dircon.co.uk>
Paul Walkerp <paul.walker@st.com> wrote:
> Hi all,
>
> Quick question - getlogin() is limited to returning 8 characters for a
> username. Is that because the OS only returns 8 characters, or just a
> limitation for some other reason?
>
It should return what your OS would return - on most Unix the Username is
ignored after eight characters ... although I cant find anywhere in the
includes that this is defined to be the case ...
/J\
--
"When the boys in the playground found out that I had a potentially
fatal peanut alergy they would shove me up against a wall and make me
play Russian roulette with a bag of Revels" - Milton Jones
------------------------------
Date: Tue, 23 Nov 1999 16:32:03 GMT
From: hdesa22@my-deja.com
Subject: Re: GMT Time
Message-Id: <81efi4$3l9$1@nnrp1.deja.com>
Thanks I used gmtime(). It worked perfectly
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 23 Nov 1999 14:39:27 GMT
From: Bill Cox <bilcox@wnt.sas.com>
Subject: HASH Implementation
Message-Id: <z6Q6ONbjjT2cnA1tM95X6Df7wQ6e@4ax.com>
A question about how Perl implements hashes. So this is a question on
how Perl works not how to work in Perl.
Since I did not have the compiler course, I don't know how you would
implement an associative array by the book. I can only guess.
Question:
Does Perl basically assign an exclusive name space for each hash then
just assign variables in that namespace to create elements of the
array? (To then get all the elements - just return all the variables
created in that namespace.)
------------------------------
Date: Tue, 23 Nov 1999 16:35:46 +0100
From: William Blasius #42722 <Wm.Blasius@ks.sel.alcatel.de>
To: bilcox@wnt.sas.com
Subject: Re: HASH Implementation
Message-Id: <383AB452.43E4@ks.sel.alcatel.de>
[ a copy of this reply was sent to bilcox@wnt.sas.com]
Bill Cox wrote:
>
> A question about how Perl implements hashes. So this is a question on
> how Perl works not how to work in Perl.
>
> Since I did not have the compiler course, I don't know how you would
> implement an associative array by the book. I can only guess.
>
> Question:
> Does Perl basically assign an exclusive name space for each hash then
> just assign variables in that namespace to create elements of the
> array? (To then get all the elements - just return all the variables
> created in that namespace.)
Short answer, no.
More helpful short answer: see the HV section of perldoc perlguts
hth
Wm Blasius
------------------------------
Date: 23 Nov 1999 14:21:53 GMT
From: BlueShine <washmon@bigfoot.com>
Subject: How to program Pseudo-TTY?
Message-Id: <81e7u1$21m$1@news.seed.net.tw>
Hi,
Could Anyone tell me how toprogram pseudo-tty in perl?
I want to monitor a active tty, and auto-input key, like "expect".
or I must use TCL/TK to write it?
where could I find the infomation?
thank you very much.
------------------------------
Date: Tue, 23 Nov 1999 14:51:03 GMT
From: cpierce1@ford.com (Clinton Pierce)
Subject: Re: How to program Pseudo-TTY?
Message-Id: <383ea8d9.897749485@news.ford.com>
[poster cc'd in e-mail]
On 23 Nov 1999 14:21:53 GMT, BlueShine <washmon@bigfoot.com> wrote:
>Hi,
> Could Anyone tell me how toprogram pseudo-tty in perl?
>I want to monitor a active tty, and auto-input key, like "expect".
>
>or I must use TCL/TK to write it?
God no. If it weren't for "expect" and "Tk" TCL would have died the
miserable stillborn death it deserved. What a horrible misguided little
language.
Don't bother with it. Tk and Expect are both possible in Perl (and other
languages).
>where could I find the infomation?
Go to http://search.cpan.org, and plug in the word "Expect". There's a
module for doing expect-like stuff and if you really want to know how it
works, you can read the source.
>thank you very much.
You're very welcome.
--
Clinton A. Pierce "If you rush a Miracle Man, you
clintp@geeksalad.org get rotten Miracles." -- Miracle Max,
http://www.geeksalad.org The Princess Bride
------------------------------
Date: Tue, 23 Nov 1999 16:09:57 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: How write records to ASCII file
Message-Id: <slrn83lf7d.9a2.bmccoy@moebius.foiservices.com>
Also Sprach Jan Andersen <jad@edekamapson.dk>:
>On Mon, 22 Nov 1999 21:23:08 +1100, Stephen J Whitfield
><rwhitfie@speedlink.com.au> wrote:
>
>>open FILE, >>$filename or die "Could not open $filename: $!";
>>print FILE "data\n";
>>close FILE || die "Could not close $filename: $!";
>
>Re: Perl style.
>
>A newbie asks: Why do you change between 'or' and '||' ?
>
>They are the same thing. Right?
They have different precedences. The English forms have a lower
precedence. Otherwise they function identically.
--
Brett W. McCoy bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek) http://www.foiservices.com
FOI Services, Inc./DIOGENES 301-975-0110
---------------------------------------------------------------------------
------------------------------
Date: Tue, 23 Nov 1999 16:16:01 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: How write records to ASCII file
Message-Id: <slrn83lfip.9a2.bmccoy@moebius.foiservices.com>
Also Sprach Jan Andersen <jad@edekamapson.dk>:
>I just don't understand what need you have for a lower (or higher)
>precedence on his open/close statements? What 'difference' does it
>make?
It can make a difference if you have complex statements -- the || will
need parentheses around the left and right expressions for the precedence
to work out correctly. The following are not equivalent:
unlink "file1", "file2" || print "Did not work\n", next;
unlink "file1, "file2" or print "Did not work\n", next;
The first statement would need to be
unlink("file1, "file2") || (print "did not work\n", next);
This, too, is in the documentation.
--
Brett W. McCoy bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek) http://www.foiservices.com
FOI Services, Inc./DIOGENES 301-975-0110
---------------------------------------------------------------------------
------------------------------
Date: Tue, 23 Nov 1999 08:20:30 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: How write records to ASCII file
Message-Id: <MPG.12a45ea9fe175ca198a25b@nntp.hpl.hp.com>
In article <383a49ac.8204918@news.inet.tele.dk> on Tue, 23 Nov 1999
08:05:23 GMT, Jan Andersen <jad@edekamapson.dk> says...
> On Mon, 22 Nov 1999 21:23:08 +1100, Stephen J Whitfield
> <rwhitfie@speedlink.com.au> wrote:
>
> >open FILE, >>$filename or die "Could not open $filename: $!";
That isn't valid Perl, because the second argument to 'open' needs to be
a string, which needs quotes around it.
> >print FILE "data\n";
> >close FILE || die "Could not close $filename: $!";
>
> Re: Perl style.
>
> A newbie asks: Why do you change between 'or' and '||' ?
>
> They are the same thing. Right?
No, they are not the same thing, because of operator precedence (the
order in which an expression is parsed).
Because the 'or' is very low precedence (parsed very late), the first
expression divides the 'open' part from the 'die' part. Had the
programmer incorrectly used ||, the statement would be only a call to
open(), whose second argument would be (quotes added):
">>$filename" || die "Could not open $filename: $!"
As the first part is 'true', the second part can never be executed, so
is meaningless noise.
As for changing from 'or' to || for the 'close' statement -- it works,
but stylistically it is inexplicable. I use && and || to build up the
result of a logical calculation:
$x = $y && $z || $w;
And I use 'and' and 'or' to indicate possible change of flow of
execution, as in the statements you presented.
Any of the precedences can be controlled by parentheses, but that
doesn't mean it is good style to do so:
open(FILE, ">>$filename") || die "Could not open $filename: $!";
I have no serious objection to the parentheses, but I would still use
'or' to avoid upsetting my stomach.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 23 Nov 1999 16:31:15 +0100
From: William Blasius #42722 <Wm.Blasius@ks.sel.alcatel.de>
Subject: Need help with class-dependent constants
Message-Id: <383AB342.6FE0@ks.sel.alcatel.de>
Greetings,
I am trying to do something which, on the face of it, seems obvious
enough, but I can't come up with a elegant (or even reasonable) way
to do it.
Problem:
I have a number of flat files which use an undelimited fixed format
where the information is similar but with different length, offset,
and coding (ie ascii, bin, &c.) in each file type. There are also a
few which are radically different in semantics.
There are quite a few methods which manipulate the information with
the only differences being the record layout. I created a different
object type for each filetype to keep the formatting separate. Each
class for similar filetypes is identical except for the constants I
use to do the unpacking. This seems very grotty and will soon be an
utter nightmare to maintain.
There must be an elegant way to have one set of methods which I can
keep in a heritable class and customize them "on the fly" depending
on the actual object type.
I've though of a few ways, but none of them are very satisfying. So
the question is - what is a tight, elegant, efficient way to do it?
I'll settle for a reasonable compromise. ;-)
Thanks in advance,
Wm Blasius
! .sig
------------------------------
Date: Tue, 23 Nov 1999 14:10:59 GMT
From: excalibor@my-deja.com
Subject: Re: New dialect of perl: xperl (or reinventing perl, or perl-izing jpython)
Message-Id: <81e79g$snj$1@nnrp1.deja.com>
In article <slrn83j9cr.m2v.abigail@alexandra.delanet.com>,
abigail@delanet.com wrote:
> excalibor@my-deja.com (excalibor@my-deja.com) wrote on MMCCLXXIV
> September MCMXCIII in <URL:news:81c10s$ain$1@nnrp1.deja.com>:
(Aside comment: if those romans are the date of the post, something
is very wrong somewhere between my clock and that script... :)
> {} I am curious: regarding OO, what do you consider usable OO? I am a
> This is anti-Perl:
>
> { package something;
>
> sub new {
> bless {array => []} => shift;
> }
>
> sub foo {
> my $self = shift;
> push @{$self -> {array}} => shift;
> }
> }
>
> Punctuation bloat (8 (!!) punctuation chars to access an array), no
> lexical scoped 'array', and if you type 'arrya', it's not even a run
> time error. You can use all the -w and use stricts you want, all you
> get is mysterious behaviour. Sure, sure, sure, you can put in extra
> checks. But that's something I want from the *language*, after all,
> that's what "use strict" is doing for me for non-OO. Not to mention
that
> you have to do lots of repeated work yourself: building the objects
[1],
> and extracting yourself from @_.
Well, I have to agree with you in that... Although powerful, it's
somehow a bit too complex. Some syntactical sugar (at the very least)
would be gladly welcome.
> Perl OO violates the basic reason OO exists: implementation hiding.
Mmmm... Well, if you provide a clear interface (which can get pretty
tricky, that's true... specially if you need some complex data for
your objects like hashes of hashes...) it shouldn't matter how that's
implemented... (actually that's something I am exploring with
OO::Closures... when I have complex data types, things can get a bit
complex there as well, although it's a really clever hack, I take my
hat off :)
>[I still] cannot take a random module from CPAN, study no more than its
interface,
> subclass it, and be garanteed it works. I would still have to study
the
> internals to make sure it works; and if it doesn't use a myriad of
tricks,
> but just "normal OO" (that is, objects as a hashref), any update of
the
> module could break my subclass, even if it isn't changing the
interface.
There are several serious problems concerning Perl's OO (or modules
work, for that matter) for which the susceptibility of implementation
of instance data vs. class data is not the biggest. For some cases,
this separation provides some really powerful tricks (that both Tom and
Damian have explained), for others it's really annoying when
implementing your class...
> I guess that when Perl 5 was designed, it was an interesting exercise
> to do the minimalist approach: Perl objects are just syntactical sugar
> for ADTs with weak binding. But I think it was the wrong decision.
It was an elegant solution... and it made usable a lot of things with
little hassle... but for the long run, some changes may be welcome...
> {} I actually would rather have a pvm ready to digest perl-bytecoded
> {} programs (eg. CGI scripts would start/generally work, (much?)
faster
>
> There's already mod_perl that more or less does this.
ah, cool... :) Then it's use should be more spread out, specially in CGI
where server load is high and new processes are always expensive...
> But that only eliminates the compiling stage, which is only worthwhile
> for programs with a relatively very short runtime which are run often.
Nod... but it would avoid a native solution if it's not wanted... the
perl compiler already provides for that...
> I am aware of the hassle you'd have doing things in C, that's why I
use
> Perl. I'm also aware speed *is* often an issue, and for many people
it's
> an important issue. The speed factor is something working against
Perl.
I disagree... for some things, you cannot put speed over many other
issues... if you really need speed, do it in assembler on a parallel
box (or net)
It's not really fair just comparing performance of already done
programs... take into account man-hours of work and stress and then
we'll be able to discuss in a more fair ground... perl is pretty darn
fast for what it offers, imo...
> I don't think there's much point in discussing what could be changed
to
> Perl. It'll never happen. Just look what a proposal for a single new
> operator does to the people in p5p. The sun will be a cold lump of
iron
> before you see a significant language change in Perl.
:) That's because they are too deep into bad habits like not receiving
too many proposals... It can be cured if we put ourselves hands on :)
> [1] And please, don't come with the argument that's more flexible.
> That's just crap. If there just were 'object instance variables',
> there wouldn't *be* any need to group them in Perl structure,
> eliminating the need to offer the subclasser a potential
headache.
Nod... it's actually something that can be done... aren't they adding
an 'our' kind of variable... well, 'private', 'really_my' or anything
fancy could do the trick... it should just imply another scope (I
dunno how hard can this be, though...)
And if not, it's time to have a serious chat with p5p and Chip so they
have changed their minds for Topaz :)
laters,
d@
--
David S de Lis
print AGAIN "Just another Perl hacker";
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 22 Nov 99 12:50:15 GMT
From: Alan Didey @ Liquid Information <nospam@my-liquidinformation.net>
Subject: Re: Newlines in formats
Message-Id: <943275015922@liquidinformation.net>
I've only been learning Perl for two weeks, so apologies if this is too
obvious.
I am using the format feature of Perl to produce various reports, and am
having a problem when dropping a scalar containing a string with newlines
in it into a format similar to:
^<<<<<<<<<<<<<<<<<<<
$string
~~^<<<<<<<<<<<<<<<<<<<
$string
The idea is that if $string is set equal to (say) "This is the first
line.\nThis is the second line.\nThis is the third line." then all of
these willprint on separate lines (wrapping each line if necessary), but
they just wrap continuously as though the "\n" characters weren't there.
I've tried fiddling with the word separating global variable $/ to no
effect.
-- Alan
------------------------------
Date: Tue, 23 Nov 1999 14:19:24 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Newlines in formats
Message-Id: <383AA28B.C138FA2E@home.com>
Alan Didey @ Liquid Information wrote:
>
> ^<<<<<<<<<<<<<<<<<<<
> $string
> ~~^<<<<<<<<<<<<<<<<<<<
> $string
>
> The idea is that if $string is set equal to (say) "This is the first
> line.\nThis is the second line.\nThis is the third line." then all of
> these willprint on separate lines (wrapping each line if necessary), but
> they just wrap continuously as though the "\n" characters weren't there.
perldoc perlform
Inside of an expression, the whitespace characters \n, \t
and \f are considered to be equivalent to a single space.
Thus, you could think of this filter being applied to each
value in the format:
$value =~ tr/\n\t\f/ /;
The remaining whitespace character, \r, forces the
printing of a new line if allowed by the picture line.
> I've tried fiddling with the word separating global variable $/ to no
> effect.
Well, of course, since that is the input record separator.
perldoc perlvar
--
Rick Delaney
rick.delaney@home.com
------------------------------
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 1466
**************************************