[12118] in Perl-Users-Digest
Perl-Users Digest, Issue: 5718 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 18 20:07:18 1999
Date: Tue, 18 May 99 17:00:23 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 18 May 1999 Volume: 8 Number: 5718
Today's topics:
Re: __END__ in eval (Charles DeRykus)
Re: _Please_ improve localtime! <jeromeo@atrieva.com>
Re: _Please_ improve localtime! (Lee)
appending a box form (Twarren10)
Browser's current URL? <airman@inreach.com>
Re: error passing a CGI object to a function in a pm. <cassell@mail.cor.epa.gov>
Gtk, Gnome and Enlightenment (loads of ideas such as Pe <occitan@esperanto.org>
HELP:Directory or File exists?? kgentes@gentek.net
Re: HELP:Directory or File exists?? (Alastair)
Re: How to move a directory? <cassell@mail.cor.epa.gov>
IRIX and Perl Menu <radaelli@digipoint.it>
Re: Linux is just another Unix (yawn) (Chris Costello)
Re: Linux is just another Unix (yawn) (anonymous)
Re: Linux is just another Unix (yawn) (Chris Costello)
Re: newbie problems with Perl CGI and Netscape <m.brinkhuis@student.kun.nl>
Re: Perl "constructors" armchair@my-dejanews.com
Re: Perl "constructors" armchair@my-dejanews.com
Re: Perl "constructors" <jdporter@min.net>
Re: Perl "constructors" (Randal L. Schwartz)
PerlCtrl question, Win32 <james.wiltshire@lexis-nexis.com>
Posting to forms via a script sneak2@hotmail.com
Re: Posting to forms via a script <jdporter@min.net>
Re: Problem With Scope <stampes@xilinx.com>
Re Perl Tutoring ???? arts@artnfact.com
Re: Saving/Reading Hashes <stampes@xilinx.com>
Re: Saving/Reading Hashes (Randal L. Schwartz)
SDBM doesn't create a file, HELP! <m.brinkhuis@student.kun.nl>
Shell Vars <toddm@waltz.rahul.net>
Re: Shell Vars (Alastair)
split and empty leading fields <Rod.Munro@ibm.net>
The Vi Lovers Home Page <tmgil@cs.vu.nl>
Re: The Vi Lovers Home Page (Lee)
using gethostbyaddr? <globus@infonet.ee>
Re: Y2K. localtime(time) (Norman Gaywood)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 18 May 1999 21:37:42 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: __END__ in eval
Message-Id: <FBy6qu.5Fo@news.boeing.com>
In article <7hnlsg$fnn$1@agate.berkeley.edu>,
Jed Parsons <jed@socrates.berkeley.edu> wrote:
>Greetings:
>
>I'm trying to slurp some perl code out of another file and run it. If
>I eval this code, it halts at __END__ without reading any DATA. For
>example, if I run this script:
>
> open (FILE,"file");
>
> while (<FILE>) {
> $code .= $_; # this is simplified for the sake of example
> }
> eval $code;
Hopefully, your 'simplified' comment means you elided all
error checking on the C<open> and C<eval>.
>on this file:
>
> for (<DATA>) { print; }
> __END__
> Hello!
>
>I get nothing. Can anyone help out?
>
The __DATA__ token makes stuff from separate files
capturable so change the __END__ in "file" to __DATA__.
Then in the main script, scrap the eval and just say:
do '/path/to/file'; # for details: perldoc -f do
or, even better, enable "file" to be C<require> worthy
by returning true.
require '/path/to/file'; # for details: perldoc -f require
But, as to your original question: The C<eval>'ed code
doesn't see its own __DATA__ tokens. I'm not sure why.
hth,
--
Charles DeRykus
------------------------------
Date: Tue, 18 May 1999 15:33:29 -0700
From: Jerome O'Neil <jeromeo@atrieva.com>
Subject: Re: _Please_ improve localtime!
Message-Id: <3741EAB9.E551DD38@atrieva.com>
Daniel Pfeiffer wrote:
>
> Going from 2 to 3 digits in the year returned by localtime is hardly a
> feature, though it should mostly avert the Y2k headaches.
It has little to do with Y2K issues. It is a well understood mechanism,
easily adjusted for 2038 issues. ;->
> This likely means touching a lot of proggies before year's end.
If you have abused localtime() and ignored the documentaion, you are
right.
> The other hassle is the absurd month number (time and again I have
> fallen into the trap). It prevents me from writing something neat like
> join '.', (localtime)[5,4,3].
Even if it was "fixed" as you suggest, you would still end up with
5.100.18 next year at this time. If you want a custom date format,
there are tools available to do just that.
> So, hey, give us poor programmers a break. Introduce a $^something
> option to give localtime more useful semantics.
How about printf()? Or one of the many Date::* modules? localtime() is
supposed to return a representation of a moment in time, not a pretty
format of human readable text. Thats what "us programmers" are suppsed
to do.
--
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: Tue, 18 May 1999 18:58:11 -0500
From: rlb@intrinsix.ca (Lee)
Subject: Re: _Please_ improve localtime!
Message-Id: <B36768C39668309CA@0.0.0.0>
In article <7hsmpi$r6q$1@nnrp1.deja.com>,
Daniel Pfeiffer <occitan@esperanto.org> wrote:
>So, hey, give us poor programmers a break. Introduce a $^something
>option to give localtime more useful semantics.
I think what you want to do is write yourself a realtime() sub that calls
localtime and does the things you want, and then never call localtime
directly.
Lee
------------------------------
Date: 18 May 1999 23:15:43 GMT
From: twarren10@aol.com (Twarren10)
Subject: appending a box form
Message-Id: <19990518191543.11088.00002256@ng-fr1.aol.com>
I am a relatively new Pearl programmer working on a search cgi. I call the
search cgi from a html form message=post. It's all working, but what I need to
know is, is there any way when the search results links come up, to place
(append) the form box to the bottom of the search results with an option to
search again? I've tried everything I can think of, what am I missing. I even
tried using the print statements to print in the form, but the result was
nothing showed up. Can anyone help me on this? Thanks.
------------------------------
Date: Tue, 18 May 1999 16:40:28 -0700
From: LEB <airman@inreach.com>
Subject: Browser's current URL?
Message-Id: <3741FA6C.2E2B74B@inreach.com>
Anyone know of a way to grab the current url in a browser or window?
i.e. You are at http://www.aeropublishers.com. I need to grab that url
information to a variable if possible???? Also, I will need to grab the
url in a frame of the browser window, etc.
Two frames:
Frame1 has content
Frame2 is running a perl program that submits the url of Frame1
Sorry for the brain twister, but I need to figure it out and am pretty
new at this.
Thanks for your input.
------------------------------
Date: Tue, 18 May 1999 16:55:47 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: "Bradley W. Langhorst" <bwlang@genome.wi.mit.edu>
Subject: Re: error passing a CGI object to a function in a pm.
Message-Id: <3741FE03.95AE0AF1@mail.cor.epa.gov>
Bradley W. Langhorst wrote:
>
> Ronald J Kimball wrote:
>
> > I think you got no meaningful response for other reasons. In
> > particular:
> >
> > 1. Too much code: we generally prefer to debug _short_ code samples.
> > 190 lines takes too much time to go through.
> >
>
> I first asked the question with reformatted pseudocode so it would be easy
> to read but somebody
> started telling me about a semicolon missing...
> John Porter said
>
> > Did you actually cut-and-paste this from your
> > actual code?
> >
> so i did cut and paste it.
> There must be some happy medium. I'm trying to find it.
Cut-and-paste is *good*. But the general assumption in this
ng is that the poster will make an effort to trim his program
down to less than 40 lines which still reproduce the problem.
*Then* cut-and-paste it after testing that it runs and
gives the same error|result|disaster .
Sometimes that's much easier said than done. But it will
vastly improve your chances of getting help here. And if
your comments wrap, consider reducing the number of comments
and putting comments on their own lines above the commented
code. Remember: if you need to comment every line for the
people in *this* ng, then there's something scary about
your code. :-)
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 18 May 1999 22:42:39 GMT
From: Daniel Pfeiffer <occitan@esperanto.org>
To: gnome-list@gnome.org
Subject: Gtk, Gnome and Enlightenment (loads of ideas such as Perl)
Message-Id: <7hsqcv$tjp$1@nnrp1.deja.com>
Hi!
I am new to Gnome and Enlightenment (but not to Gimp) and I find them
way cool! I've tried icewm and wmaker, but they don't compare. Here
are many ideas, possibly some of them already implemented:
Though Gtk seems the greatest of all, I find it awful that we get yet
another look and feel in the terribly disparate X11 world. This
solution however should do away with that: Gtk should become a
functional
superset of other toolkits (especially Motif and Qt) and should for
one thing provide dropin-replacement header files, so that those apps
can be transparently compiled with native Gtk, and for another, the
shared libs should function as dropin-replacements for those of the
other toolkits so we can run any off-the-shelf programme with Gtk.
As far as I understand we have completely separate sets of themes for
window-managers and applications, and, of all the screenshots in the
web, none blend in _really_ well. A single theme should be able to
cover apps, desktop and wm as well as a default background image.
Each desk/workspace might switch to such a wm/app combined theme.
Window background should acquire new magic capabilities of
autoreduction. I am thinking of irregular window shapes. Any pixel
further than N pixels from a widget would be transparent, unless it
were in a bay, to which access would be through a channel narrower
than M pixels. This would allow for rounded corners, and large empty
surfaces close to the border being left to the desktop/other windows.
This would for one thing work via X resources of a specific or any
window background. For another the window manager might detect this
and modify the window accordingly. (With rounded borders
etc. depending on the theme.) And give us an option to simply turn
off a useless frame around a whole window content, since more often
than not, that doesn't blend in well with the WM's border or even
prevents the WM from denting into the background.
Coming from fvwm where this is tightly coupled, I see the strong
distinction between wm and desktop as a step backwards. Make
enlightenment the wm of choice, give it all the functionality
(possibly through theme engines) found in any wm or OS, and give us a
single control panel for the whole thing!!! The control panel in turn
might take on most diverse looks, e.g. the NeXTish one looks nicer
than Gnome's of evident MS Windows inspiration/desperation.
Pulling menubars and iconbars out of windows is neat, but I would like
options such as dragging the bar out of one window makes it disappear
in all windows of the same app. Making it stick to any
desktop/workspace where I have windows of that app. Making bars from
the same window glue together when I approach them. Swallowing it into
a panel (or Mac theme screen menubar) and making it replace the
corresponding applauncher button there. In this sense the Gimp
controlpanel should also become an iconbar, freely rearrangeable in
rows and columns to fit into a panel. Panelspace being limited, it
should be easy to put little used icons into a popup menu.
Since I regularly have various windows of the same app running, and
since I often have like 30 windows open, it would be great is the
task-list of the pager could simply show the app, as a popup menu
launcher, that would list" the windows.
Also I would sometimes like to join several related windows into a
single WM-controlled window. Fvwm's button box allows to do this in a
somewhat limited way but more would be possible. For example cutting
close-buttons out of the windows and putting them at the bottom. And
even for dialog boxes that don't normally allow this, it can be very
useful to change their size. Make it possible if I insist, most react
quite usefully, like widening input fields that contain long strings.
My biggest concern of all are the config files, where currently
various simple syntaxes or the language "scheme" are used. Mostly
they seem to define data and data-structs which get read in and stored
in some form in memory. All very static and what comes in where is
not directly evident. My dream would be to link a Perl-interpreter
into this and make it be the data-handler and action dispatcher. The
data syntax is well-defined, and the expressive power would be
immense! All actions would still be in C, unless I need a special
case, where I would override or enhance this with a Perl function.
The GUI configurator would write Perl files with plain data (likely in
hashes - for parameters - and lists - for menus) and I could then
modify these in my config file or even at any time via a timer or
event driven function. These functions would have access to a list of
windows, with all attributes.
O.K., enough ranting, I am alas not going to help, knowing nothing
of X programming nor being a C guru.
--
Perl |berallhin:
Perl everywhere: http://beam.to/iPerl/
Perl ^cien:
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Tue, 18 May 1999 23:32:07 GMT
From: kgentes@gentek.net
Subject: HELP:Directory or File exists??
Message-Id: <7hst9n$vk4$1@nnrp1.deja.com>
How do I test the existance of a directory or
file in Perl?
thanks
Kim
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Tue, 18 May 1999 23:58:27 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: HELP:Directory or File exists??
Message-Id: <slrn7k437v.5o.alastair@calliope.demon.co.uk>
kgentes@gentek.net <kgentes@gentek.net> wrote:
>How do I test the existance of a directory or
>file in Perl?
One reads the documentation. It's much faster than usenet usually. See
'perlfunc' and the section '-X' (-X filetest operators).
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: Tue, 18 May 1999 16:44:18 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: How to move a directory?
Message-Id: <3741FB52.96BAC4D9@mail.cor.epa.gov>
Tad McClellan wrote:
>
> Jalil Feghhi (jalil@corp.home.net) wrote:
> : Is there a function for moving directories in Perl?
>
> Yes. The same one that moves files.
>
> perldoc -f rename
But.. Tad didn't bother to mention that `rename' has some
portability issues that you might want to investigate
before getting too deeply enmired. Read the perlport
POD page.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 19 May 1999 00:11:27 +0200
From: "Marco Radaelli" <radaelli@digipoint.it>
Subject: IRIX and Perl Menu
Message-Id: <7hsoj9$qtj$1@nslave1.tin.it>
I am working with an SGI Indigo 2 (R4000) with IRIX 6.5.
------------------------------------------------------------------------
Problem: Unable to add Curses and PerlMenu !!!!!!!!
------------------------------------------------------------------------
I tried the perl version 5.00503 in the tardist format and no problems in
installing and using it.
When I tried the Curses 1.0.2 module no way to easly compile it and no way
to make it work.
1) The first problem is that a long list of C routines are not found (while
using perl Makefile.PL or make itself I do not remember...)
2) The second problem is that the -n32 is not vailable to the cc compiler
(the -32 option is)
Question: The tardist points to the irix-n32 version (where is this written?
may be I would prefer to use the -o32 version that I saw with a smart old
fascion -32 option in the Config.pm module (apropos I don't know even of
what I am talking of since I am a real beginner in the Unix and IRIX arena))
I forced the -32 option in the makefile and replace -mips3 with -mips2
the "make" now fails in time.h for a redefinition, at this point I commented
the time.h and used again "make".
Finally the "make" and "make install" worket.
But when trying the "demo" I saw that even if it finds and uses Curses.o
library (asked by the DynaLoader.pm) it does not "map correctly" (what does
this mean ?) and the program dies.
Please help me, possibly without asking me difficult questions.
Question: Is there a tardist also for the Curses.1.0.2 ?
Question: Any hint for compilation options and include libraries...?
Thank in advance
Marco Radaelli
Radaelli@digipoint.it
------------------------------
Date: Tue, 18 May 1999 22:04:12 GMT
From: chris@holly.dyndns.org (Chris Costello)
Subject: Re: Linux is just another Unix (yawn)
Message-Id: <slrn7k3p20.ekj.chris@holly.dyndns.org>
In article <7hsm83$ocu$1@bgtnsc03.worldnet.att.net>, anonymous wrote:
> >You don't even know if Perl has a debugger? Do you know what percentage of
> >CGI's running the WWW are written using Perl? As a user (past) of VB and
> >of Perl (current). VB is perhaps 30% as useful as Perl, and that is being
> >generous.
>
> Really? Perl has component abstraction? A windowing interface? An
I'm not exactly sure. Yep.
> integrated debugger? How about doing something simple, like connecting to a
Yep.
> database table without writing code? Anything? 30% as useful? No, you are
Yep (I assume you mean connecting to a database and selecting
from a table). Yep. 3000% as useful.
--
Chris Costello
The computer is mightier than the pen, the sword, and usually, the programmer.
------------------------------
Date: Tue, 18 May 1999 22:42:45 GMT
From: anon@anon.org (anonymous)
Subject: Re: Linux is just another Unix (yawn)
Message-Id: <7hsqdr$epa$6@bgtnsc01.worldnet.att.net>
In article <slrn7k3p20.ekj.chris@holly.dyndns.org>, chris@holly.dyndns.org (Chris Costello) wrote:
>In article <7hsm83$ocu$1@bgtnsc03.worldnet.att.net>, anonymous wrote:
>> >You don't even know if Perl has a debugger? Do you know what percentage of
>> >CGI's running the WWW are written using Perl? As a user (past) of VB and
>> >of Perl (current). VB is perhaps 30% as useful as Perl, and that is being
>> >generous.
>>
>> Really? Perl has component abstraction? A windowing interface? An
>
> I'm not exactly sure. Yep.
>
>> integrated debugger? How about doing something simple, like connecting to a
>
> Yep.
>
>> database table without writing code? Anything? 30% as useful? No, you are
>
> Yep (I assume you mean connecting to a database and selecting
>from a table). Yep. 3000% as useful.
>
This is COMPLETE crap. Have you EVER even used PERL?? Apparently not.
------------------------------
Date: Tue, 18 May 1999 23:14:25 GMT
From: chris@holly.dyndns.org (Chris Costello)
Subject: Re: Linux is just another Unix (yawn)
Message-Id: <slrn7k3t5j.ekj.chris@holly.dyndns.org>
In article <7hsqdr$epa$6@bgtnsc01.worldnet.att.net>, anonymous wrote:
> In article <slrn7k3p20.ekj.chris@holly.dyndns.org>, chris@holly.dyndns.org (Chris Costello) wrote:
> >In article <7hsm83$ocu$1@bgtnsc03.worldnet.att.net>, anonymous wrote:
> >> >You don't even know if Perl has a debugger? Do you know what percentage of
> >> >CGI's running the WWW are written using Perl? As a user (past) of VB and
> >> >of Perl (current). VB is perhaps 30% as useful as Perl, and that is being
> >> >generous.
> >>
> >> Really? Perl has component abstraction? A windowing interface? An
> >
> > I'm not exactly sure. Yep.
> >
> >> integrated debugger? How about doing something simple, like connecting to a
> >
> > Yep.
> >
> >> database table without writing code? Anything? 30% as useful? No, you are
> >
> > Yep (I assume you mean connecting to a database and selecting
> >from a table). Yep. 3000% as useful.
> >
>
>
> This is COMPLETE crap. Have you EVER even used PERL?? Apparently not.
Yes I have. I also know how to use the debugger. I also know
how to access a database with two lines of Perl. I also know how
to edit Perl in a window. I also know how to create a window
with Perl.
Can VB do regular expressions? Can VB access many different
types of databases with extreme ease? Can VB reimplement
important utilities needed to have a decent system? Perl can do
all of those. For the reimplementing-the-tools thing, see
http://language.perl.com/ppt/
PS: It's not "PERL", it's "Perl".
--
Chris Costello
I must have slipped a disk; my pack hurts.
------------------------------
Date: Tue, 18 May 1999 14:11:59 +0200
From: Matijs <m.brinkhuis@student.kun.nl>
Subject: Re: newbie problems with Perl CGI and Netscape
Message-Id: <3741590F.FB4578A8@student.kun.nl>
You should use:
print "Content-type: text/html\n\n"; # don't forget the double \n
or when using cgi.pm use
print &PrintHeader;
because there is no print command in the package, it only returns a
scalar that contains "Content-type: text/html\n\n" that you still have
to print.
Ciao,
Tijs
Drifter wrote:
>
> When I print out html code in my cgi script it works great in IE but in
> Netscape,
> all i get is a listing of the code and not the web page.
>
> i have tried using print "Content-type: text/html";
>
> tried cgi-lib.pm
>
> &PrintHeader;
>
> &HtmlTop;
> .
> .
> html code
> .
> .
>
> &HtmlBot;
>
> everything works great in IE, but nothing works in Netscape!
>
> Can neone help me?
>
> --
> Drifter
> ~
>
> The softest stuff in the world
> Penetrates quickly the hardest;
> Insubstantial, it enters
> Where no room is.
>
> TAO TE CHING
------------------------------
Date: Tue, 18 May 1999 21:55:38 GMT
From: armchair@my-dejanews.com
Subject: Re: Perl "constructors"
Message-Id: <7hsnkp$rso$1@nnrp1.deja.com>
In article <7hrosq$6vj$1@nnrp1.deja.com>,
John Porter <jdporter@min.net> wrote:
> In article <7hqo34$hlt$1@nnrp1.deja.com>,
> armchair@my-dejanews.com wrote:
> Groovy. Although, even if Perl did add support for overloading, the
> restriction on naming you propose would still be bogus.
Actually, it would be totally rad my good man!
>
> > > But this is a bogus restriction that makes life worse for Perl
> > > programmers while adding nothing of any benefit to anyone else.
> >
> > I think there is some benefit to be looking at code and
> > instantly see
> > that a method is a constructor, or not.
>
> You suppose that you do. But have you ever worked with a system
> that did not have this "benefit"? I can imagine that if suddenly
> C++ let you name your constructors anything and everything, you'd
> be pulling your hair out, because of the memory management issues.
> "Who allocated this? Where? Who owns it? Where's it gonna get
> deleted"? But these issues are absent in Perl.
??? The name of the constructor is not an allocation/deallocation issue
(and destructors handle memory deallocation transparently). I proposed
it for code readability. And not reading your own code, reading someone
else's code.
>
> > > "Right" is only meaningful in context. When you're programming
> > > in Perl, the Perl way *is* the right way. At least, "more right"
> than
> > > the way of some alien language.
> >
> > I would agree that "right" is a matter of opinion in many things,
> > including this.
>
> Sure; but that's not what I said. When you're programming in Perl,
> the Perl way is the right way. That's context.
So if I gave an assignment to a 100 Perl programmers they'd all program
it the same way?
> Here's your analogy corrected: Perl is a squeegee and spray bottle
> used by the mall lot crew. C++ is the high-pressure hose at the
> truck depot.
So are you trying to make a distinction that Perl is good for some
things, but not others, and the same for C++?
>
> > And yet.... now Perl has objects. The point being,
> > Perl is a dynamic language, like most languages seeing continued
> > usage.
> > Things have been added to Perl over the years, and I am sure they
> > will
> > continue to be added, in the same way C++ has added strings, and via
> > the
> > STL, dynamic arrays and maps. So I can only hope that you won't try
> > and
> > put Perl in a box regarding things like records. I don't think Perl
> > would like that.
>
> Oh, records. As I said elsewhere -- You have the source code.
Stand back. Here come's Earl.
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Tue, 18 May 1999 22:01:36 GMT
From: armchair@my-dejanews.com
Subject: Re: Perl "constructors"
Message-Id: <7hsnvv$rvp$1@nnrp1.deja.com>
In article <7hrnic$5ta$1@nnrp1.deja.com>,
John Porter <jdporter@min.net> wrote:
> In article <7hrbsk$ur3$1@nnrp1.deja.com>,
> armchair@my-dejanews.com wrote:
> > Returning an integer gives you a perfect way to show different
> > types
> > of
> > failure, and is why I prefer it. Since you (and others here) only
> > return
> > undef or a success/result , how are you differentiating between
> > failures?
>
> Um, what about proceeding as normal on success (no return code to
> test), and throwing an exception on error?
>
I'm all for that. But the "exception handling" of Perl is not covered in
introductory books and is not easily picked up from what is referred to
as "the manual". But if you are writing general purpose "will be used by
everybody" code, throwing exceptions is the way to go, because then
people who don't check return codes still find out about it - right
away.
And is that how you code? Is that the Perl way? Or is returning undef
the Perl way?
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Tue, 18 May 1999 22:19:42 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Perl "constructors"
Message-Id: <7hsp1t$sn4$1@nnrp1.deja.com>
In article <7hjsip$1bk$1@nnrp1.deja.com>,
armchair@my-dejanews.com wrote:
> > :my $reference = myclass->new();
> > :if ( $reference == 0 )
> >
> > No, that's wrong. Don't test for 0.
> >
> > if ($value) suffices for truth, and
> > unless ($value) for falsehood. This == 0 business
> > is brain-damange.
>
> Why shackle someone's code style to your biases. Try and be more
> libertarian, like Perl and Larry Wall
Unfortunately, your biases are far more encumbering.
The idea that a reference should be number which equals zero
to mean nil is, well, ridiculous. But that's the way it is in C.
However, even that being the case, to test a number for zero-ness
by comparing to 0 is redundant. And it's just plain laughable
when the thing being tested is conceptually not even numeric.
> Is raising an exception supposed to be the die function?
Not merely supposed to be, my non-doc-reading friend.
> no sane man, woman or child would ever call it intuitive.
Fortunately, this has nothing to do with sanity.
Anyone familiar with Perl's concept of contexts (that would be
scalar context, list context, and void context) would have no
trouble seeing the "intuitiveness" of this formulation.
--
John Porter
Put it on a plate, son. You'll enjoy it more.
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: 18 May 1999 16:39:35 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Perl "constructors"
Message-Id: <m1so8uhrrc.fsf@halfdome.holdit.com>
>>>>> "armchair" == armchair <armchair@my-dejanews.com> writes:
armchair> The only people that can "criticize" Catholocism are the
armchair> Pope, bishops, priests, and nuns.
And your point? I don't get the analogy. And I'm nun (:-) of the
above, and I can criticize Catholicism all day (since I can spell it
right), but I'd be deluding myself if I thought it would change
anything, so I'm wasting my breath.
I didn't see any Perl in that post.
ObPerl: print "Just another Perl hacker,"
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 18 May 1999 22:41:59 GMT
From: "Jim Wiltshire" <james.wiltshire@lexis-nexis.com>
Subject: PerlCtrl question, Win32
Message-Id: <01bea17f$a831b120$99120c8a@lnxwiltjs>
I've tried running the Win32 sample apps distributed with the ActiveState
PDK, with no luck. The apps connect to the dll/com libraries but the
methods do not return the correct data. Returned data is always 0 or the
null string.
Is this a known problem with PerlCtrl? (Obviously a major bug, if it's a
bug)
With ActiveState?
Do I have something setup wrong?
Thanks for any help.
Jim
------------------------------
Date: Tue, 18 May 1999 22:12:58 GMT
From: sneak2@hotmail.com
Subject: Posting to forms via a script
Message-Id: <7hsol9$scb$1@nnrp1.deja.com>
Is it possible to write to a form on an HTML page from a perl program
not associated with the HTML page? By that, I mean the script would act
like a user by entering in information, and pulling back the next page?
I know it is possible to pull back a page (I've done that before). But,
what about having the script entering the information?
Chris
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Tue, 18 May 1999 22:39:12 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Posting to forms via a script
Message-Id: <7hsq6g$tgk$1@nnrp1.deja.com>
In article <7hsol9$scb$1@nnrp1.deja.com>,
sneak2@hotmail.com wrote:
> Is it possible to write to a form on an HTML page from a perl program
> not associated with the HTML page? By that, I mean the script would
act
> like a user by entering in information, and pulling back the next
page?
> I know it is possible to pull back a page (I've done that before).
But,
> what about having the script entering the information?
This is all described in the documentation of the module which
enables it: LWP.
--
John Porter
Put it on a plate, son. You'll enjoy it more.
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: 18 May 1999 21:36:31 GMT
From: Jeff Stampes <stampes@xilinx.com>
Subject: Re: Problem With Scope
Message-Id: <7hsmgv$a21@courier.xilinx.com>
Ryan Ngi <ryanngi@hotmail.com> wrote:
: $x = 5
: sub{
: my($x)=3;
: $y= ..... # how to assign y to the global $x, not the my($x)
: }
If you must:
i
#!/usr/local/bin/perl -w # You *do* use -w, right?
use strict; # And of COURSE you 'use strict';
use vars qw($x); # So if you want a 'global', declare it
$x = 5; # Here's my 'global' $x
foo(); # Call my function
sub foo
{
my $x = 3; # This declares a 'private' $x
my $y = $main::x; # or my $y = $::x;
print $y;
}
--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com
------------------------------
Date: Tue, 18 May 1999 19:30:34 -0400
From: arts@artnfact.com
Subject: Re Perl Tutoring ????
Message-Id: <3741F819.8FA5905C@artnfact.com>
Perl Tutoring ????
Any LI NYers willing to tutor perl for cgi programming, please reply
with your per/hr rate.
--
Best Regards-
Mr. Oded Kotler
------------------------------
Date: 18 May 1999 21:43:12 GMT
From: Jeff Stampes <stampes@xilinx.com>
Subject: Re: Saving/Reading Hashes
Message-Id: <7hsmtg$a22@courier.xilinx.com>
Jalil Feghhi <jalil@corp.home.net> wrote:
: I have a complex hash table that I need to save to disk when my progrm stops
: and read it at the startup.
: I don't want to iterate through the whole thing and save/read all elements.
: Is there another way to do this? Anyway to use printf for example to write
: the whole thing to a file and then read everything back with one simple read
: operation?
Check out CPAN for MLDBM
--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com
------------------------------
Date: 18 May 1999 16:46:56 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Saving/Reading Hashes
Message-Id: <m1ogjihrf3.fsf@halfdome.holdit.com>
>>>>> "Daniel" == Daniel Grisinger <dgris@moiraine.dimensional.com> writes:
Daniel> For single dimensional data structures use Data::Dumper (standard
Daniel> with 5.005+, from CPAN for obsolete perls). For multi-dimensional
Daniel> structures use MLDBM (from CPAN for all versions of perl).
Daniel> Both provide reasonably good persistence mechanisms.
But both are far slower and less robust than something like Storable
for large data in keys/values or complicated interrelationships.
"use Storable" it rocks.
use Storable qw(freeze thaw); print@{thaw(freeze(["Just another Perl hacker,"]))};
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Wed, 19 May 1999 00:39:28 +0200
From: Tijs <m.brinkhuis@student.kun.nl>
Subject: SDBM doesn't create a file, HELP!
Message-Id: <3741EC20.AB12F297@student.kun.nl>
Hi,
I need help on a SDBM_File database I wish to make. I am using the
following program, it seems to work fine but no file is created. I tried
it on a machine running Linux and on a machine stumbling with W95 :) .
Both didn't create a file, what am I doing wrong?
Thanks!
#!/usr/bin/perl
# file : test.pl
# purpose : testing
use strict vars; # using strict causes perl to complain about O_RDWR and
O_CREAT
# BTW can anyone explain the | between those, is a OR?
use SDBM_File;
my (%db);
my @list = ('Uno','Due','Tres');
tie (%db, 'SDBM_File', 'data.sdbm', O_RDWR | O_CREAT, 0777);
%db = (
'key1' => [@list],
'key2' => [@list], # last , optional I know
);
print $db{'key1'}[1]; # for testing if the hash actually contains
something
untie (%db);
------------------------------
Date: 18 May 1999 23:44:39 GMT
From: Todd McLaughlin <toddm@waltz.rahul.net>
Subject: Shell Vars
Message-Id: <7hsu17$n8t$1@samba.rahul.net>
How can a get the value of a shell variable in my perl script? Namely, I want ~.
Thanks.
Todd
------------------------------
Date: Tue, 18 May 1999 23:56:13 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Shell Vars
Message-Id: <slrn7k433q.5o.alastair@calliope.demon.co.uk>
Todd McLaughlin <toddm@waltz.rahul.net> wrote:
>How can a get the value of a shell variable in my perl script? Namely, I want ~.
>Thanks.
>
>Todd
Your news reader needs better wrapping methinks.
'~' isn't a shell 'var' AFAIK. You want $HOME I think. Check the %ENV hash.
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: Tue, 18 May 1999 23:12:54 +0100
From: "Rod Munro" <Rod.Munro@ibm.net>
Subject: split and empty leading fields
Message-Id: <3741da2a@news.uk.ibm.net>
Is there a way of stopping split preserving empty leading fields?
For example I use some (modified) code from Tom Christiansen's 1996
Irregular Expressions article and the first item caught by the split is the
empty field.
use English; use FileHandle; use Data::Dumper;
$RS = ''; $Data::Dumper::Useqq = 1;
while ( $line = ARGV->getline() ) {
%hash = split(/^([^:]+):\s*/m, $line);
print Dumper(\%hash);
}
With the following data:
field: value here
somefield: some value here
morefield: other value here
field: second record's value here
somefield: some value here
morefield: other value here
newfield: other funny stuff
gives the following result (when I would like to put the FIELD: VALUE pairs
into a hash)
perl re.pl data.txt
$VAR1 = {
"" => "field",
"value here\n" => "somefield",
"other value here\n\n" => undef,
"some value here\n" => "morefield"
};
$VAR1 = {
"second record's value here\n" => "somefield",
"" => "field",
"other value here\n" => "newfield",
"other funny stuff\n\n" => undef,
"some value here\n" => "morefield"
};
Perl version 5.005_02 win32 build 509
--
Rod
------------------------------
Date: Wed, 19 May 1999 00:37:12 +0200
From: "Thomer M. Gil" <tmgil@cs.vu.nl>
Subject: The Vi Lovers Home Page
Message-Id: <7hspt7$dsu$1@star.cs.vu.nl>
Hi,
Please visit the Vi Lovers Home Page. Vi is *the* editor under Unix, Windows
95/98/NT and many other operating systems.
The Vi Lovers Home Page:
http://www.cs.vu.nl/~tmgil/vi/vi.html
The Vi Lovers Home Page contains much Vi related info and links to:
- Many downloadable Vi versions for a large range of operating systems,
- Vi FAQs,
- Tutorials,
- FTP sites,
- jokes and the like,
- and much more.
The Vi Lovers Home Page:
http://www.cs.vu.nl/~tmgil/vi/vi.html
Thomer M. Gil
------------------------------
Date: Tue, 18 May 1999 18:58:11 -0500
From: rlb@intrinsix.ca (Lee)
Subject: Re: The Vi Lovers Home Page
Message-Id: <B36768C39668309A7@0.0.0.0>
In article <7hspt7$dsu$1@star.cs.vu.nl>,
"Thomer M. Gil" <tmgil@cs.vu.nl> wrote:
>The Vi Lovers Home Page:
>http://www.cs.vu.nl/~tmgil/vi/vi.html
Isn't there a 12-step program for that?
Lee
------------------------------
Date: Wed, 19 May 1999 01:19:07 +0300
From: Gleb Ekker <globus@infonet.ee>
Subject: using gethostbyaddr?
Message-Id: <3741E75B.7F6E41C4@infonet.ee>
Hi,
I use free hosting service where CGI/Perl is allowed but they do not
give $ENV{REMOTE_HOST}, it is empty. I have only $ENV{REMOTE_ADDR} with
numerical address, but I need to have server's name too.
I heared that it is possible to modify it by using gethostbyaddr, to
resolve the host address into a host name. Please give me an example how
I can do this thing.
Thanks and Best Regards,
Gleb. globus@infonet.ee
------------------------------
Date: 19 May 1999 09:55:50 +1000
From: norm@turing.une.edu.au (Norman Gaywood)
Subject: Re: Y2K. localtime(time)
Message-Id: <7hsum6$g74@turing.une.edu.au>
fl_aggie@thepentagon.com (I R A Aggie) writes:
>Perl's localtime gets its information from the underlying system. If
>you really do have a Y2K problem in a perl script, the odds are very
>good that you have a Y2K problem in your OS...
Not quite. It's not hard for idiots to introduce Y2K bugs. Look at
these lines from the popular(!?) perl message board program, wwwboard.pl:
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
OK so far, but after some truly horrible lines of code we get to this
shocker:
$long_date = "$months[$mon] $mday, 19$year at $hour\:$min\:$sec";
So the year 2000 will look like "19100". Smart stuff!
Even better is this one from multi4M.cfg in another message board
perl program, multi4M:
local( $millenium ) = '19';
# Avoid Y2000 problem
if ($year > 70) { $millenium = '20'; }
$today = "$days[$wday], $months[$mon] $mday, $millenium$year";
Can you believe that! This one has code included to make it "Y2K safe",
but in 2000 it will display a date with the year set to 20100.
I still can't believe that people write code like this!
--
Norman Gaywood -- School of Mathematical and Computer Sciences
University of New England, Armidale, NSW 2351, Australia
norm@turing.une.edu.au http://turing.une.edu.au/~norm
Phone: +61 2 6773 2412 Fax: +61 2 6773 3312
--
Norman Gaywood -- School of Mathematical and Computer Sciences
University of New England, Armidale, NSW 2351, Australia
norm@turing.une.edu.au http://turing.une.edu.au/~norm
Phone: +61 2 6773 2412 Fax: +61 2 6773 3312
------------------------------
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 5718
**************************************