[8978] in Perl-Users-Digest
Perl-Users Digest, Issue: 2596 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 14 14:07:29 1998
Date: Thu, 14 May 98 11:00:31 -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 Thu, 14 May 1998 Volume: 8 Number: 2596
Today's topics:
Re: Accessing Oracle tables from Perl <ajh@rtk.com>
Re: bug in win95 read/sysread? (Tye McQueen)
Calling perl subroutine from c program sonigopi@hotmail.com
Re: Code fragment not working (Help!?!) (Jeff Henry)
Re: creating some sort of deamon <rootbeer@teleport.com>
Digit matching regex (A.H. Roberts)
Re: Digit matching regex (Mike Stok)
Re: Digit matching regex (brian d foy)
Re: Digit matching regex <tchrist@mox.perl.com>
Re: Does Perl have a IDE?I don't like command line. <upsetter@shore.net>
Re: Does Perl have a IDE?I don't like command line. fsg@gallo.ultranet.com
Re: Does Perl have a IDE?I don't like command line. fsg@gallo.ultranet.com
Re: Does Perl have a IDE?I don't like command line. fsg@gallo.ultranet.com
Re: Does Perl have a IDE?I don't like command line. fsg@gallo.ultranet.com
Re: Does Perl have a IDE?I don't like command line. <tchrist@mox.perl.com>
Re: Does Perl have a IDE?I don't like command line. (Marek Jedlinski)
Re: gethostbyaddr not working in perl5.00401? <rootbeer@teleport.com>
How can I overwrite characters? (Michael E. Hagin)
Re: How can I overwrite characters? <tchrist@mox.perl.com>
Re: How can you break out of a 'while... ' loop in a fu (Stuart Wright)
Re: How can you break out of a 'while... ' loop in a fu <angst@scrye.com>
Re: Is if ($a="something") a bad style? <angst@scrye.com>
Re: localized ctime? <rootbeer@teleport.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 14 May 1998 10:16:01 -0700
From: "Aaron Harsh" <ajh@rtk.com>
Subject: Re: Accessing Oracle tables from Perl
Message-Id: <6jf8t5$unt$1@brokaw.wa.com>
brian d foy wrote in message ...
>In article <6jebok$9af$1@nnrp4.snfc21.pbi.net>, "ryant" <ryant@pacbell.net>
posted:
>
>>write some Perl code to access an Oracle database. My question here is
how
>>difficult would this be to perform straight from the script vs. writing
>>persistent object layers to perform the same tasks?
>
>some one has already doen the work of creating an abstract interface.
>see the DBI package at CPAN.
I think Brian's advice is good if all you're after is an SQL based interface
to Oracle.
If you're actually after a persistent object connection, though, you might
want to check out the panther book (Advanced Perl Programming, by Sriram
Srinivasan, O'Reilly). It has a couple chapters that go over a persistence
layer that works with DBI.
--
Aaron Harsh
ajh@rtk.com
------------------------------
Date: 14 May 1998 11:53:22 -0500
From: tye@fohnix.metronet.com (Tye McQueen)
Subject: Re: bug in win95 read/sysread?
Message-Id: <6jf7i2$srb@fohnix.metronet.com>
"Creede Lambard" <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print> writes:
) Well, you wouldn't want to be in binmode on a Mac or Unix machine, for
) instance.
Sure you would. Especially on a Mac. binmode() on Unix machines
is (almost always) a no-op which does no harm and does document
that you are writing a stream of bytes and not lines of text.
See the "b" option in your favorite fopen() documentation.
) Binmode is a hack,
Wrong. How to deal with "records" in files (called "lines" when
you have a "text" file) is a problem that has been solved a ton
of different ways on different systems. C and Unix chose one
particular solution for lines of text and decided to skip the
whole "records" problem and let anyone who wanted records invent
their own implementation.
The C/Unix solution of single newlines (ASCII 10) as line
terminators is one of the simplest in many ways, but it also
requires that the operating system be more complicated in other
ways to compensate. That is why you have so many newline-related
options to the stty command and why talking to a postscript
printer requires special settings, etc.
) essentially for MSDOS-derived machines that can react
) badly to files containing embedded \01A characters (as many binary files
) do).
Ah, at least you pinned that bit of brain damage correctly.
The main purpose of binmode() is to disable translation between
single ASCII newlines and the local concept of a text record, but
it also, on MS-DOS-derived systems, disables the silly CTRL-Z as
end-of-file treatment.
) Mac, Unix and most other operating systems that are smart enough to
) handle Perl don't have that problem, so they don't need binmode.
If you are writing non-text files that contain \n or \r on a Mac,
then you *need* to use binmode().
[Although, in MacPerl binmode() might be the default so you won't
have to ask for it in order to get it. If so, then MacPerl must
deal with the newline issues in other, less standard ways -- perhaps
part of why chomp() was created. I've read that the meaning of \r
and \n in MacPerl is/was reversed and that Macs want two-byte text
line terminators, but I don't have a Mac and I'm not sure what
MacPerl does in this area. Do I hear a flame coming?]
) I suppose you could binmode() a Unix file, but it would certainly cause
) you to have to deal with more overhead (not to mention possible
) unforeseen side effects).
Wrong and wrong. No overhead and no side effects.
) Maybe when the distributions are merged for 5.005 opening a file will
) assume binmode() but will allow it for backward compatibility. Maybe.
) But don't count on it. :D
You don't want to assume binmode() or writing text files with Perl
could cause some text file processors to not understand your line
breaks.
Use binmode() for binary files on all system and don't use it for
text files on any systems. That is why it is called "binmode".
--
Tye McQueen Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
------------------------------
Date: Thu, 14 May 1998 15:59:43 GMT
From: sonigopi@hotmail.com
Subject: Calling perl subroutine from c program
Message-Id: <6jf4df$gd0$1@nnrp1.dejanews.com>
I am trying to call a perl subroutine from perl package but have no
idea how to go about it. I need to pass 2 parameters to perl subroutine
which in turn returns integer back to c. Are there any headers I need to
include in c program. Any Help would be greatly appreciated.
Thanks
Soni
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Thu, 14 May 1998 16:53:40 GMT
From: jdhenry.NOSPAM@ismi.net (Jeff Henry)
Subject: Re: Code fragment not working (Help!?!)
Message-Id: <355b062e.11172821@news.ismi.net>
On Wed, 13 May 1998 19:40:04 GMT, phounsh@ucdavis.edu (Paul Hounshell)
wrote:
>OK, I really do not get this. My If statement does not seem to be
>working.
Right. "==" is numeric equality; I think you want "eq", stringwise
equality. (Well, I _know_ you want eq, because I tried it, and it
works.)
>Line numbers are for reference and the Font used was MS Sans
>Serif (8Pt) in case it doesn't display right.
Useless information for the millions of people not running a
windows-based newsreader.
>
>
>Script Fragment
>-------------------------
>
>1 open(CREDIT_LIST_IN, "Credits.dat");
Always check to make sure your open worked.
> while (eof(CREDIT_LIST_IN) != 1)
> {
> $record1 = "";
>5 $NextChar = getc(CREDIT_LIST_IN);
> while ($NextChar != ">")
> {
> $record1 = "$record1$NextChar";
> $NextChar = getc(CREDIT_LIST_IN);
>10 }
> print "\nRecord1 = $record1\n";
>
> $NextChar = getc(CREDIT_LIST_IN);
> if ($NextChar == "G")
eq
Here's your real problem.
[snip, snip, code, comments, data, output deleted]
>
>From what I've been able to understand, lines 19-23 do not ever run.
>When "X" is found (and it is found), it runs through the section for
>"G" (lines14-18). If anyone knows something that I am forgetting,
>please let me know as I am stumped. If it matters, I am running Perl
>5 on a Win95 machine.
>
>Thank you very much,
>
> -Paul Hounshell
> phounsh
For what it's worth, your lengthy code can be shortend as shown below.
The more perlish way to do this is to read your data a line at a time,
and break it up with split or, in this case a regexp. Of course you
may have a perfectly good reason for using getc. Just a guess, are you
a "recovering" c programmer?
#!/usr/bin/perl -w
open(CREDIT_LIST_IN, "Credits.dat") or die "$!";
while (<CREDIT_LIST_IN>) {
my ($record1, $record2) = /^(.*)>(.*)<.*$/ ;
print "\nRecord1 = $record1\n";
$record2 = -1 if ($record2 eq "G");
$record2 = -2 if ($record2 eq "X");
print "\nRecord2 = $record2\n";
}
close(CREDIT_LIST_IN);
Hope this has helped.
--
Jeff Henry, Compuware Corp. | This sig under construction
standard opinions/employer disclamer | Some cute ASCII art here, or
"A witty quote" - by someone famous | maybe my name in big block
http://url.to.some.cool.site | letters, so I look important
------------------------------
Date: Thu, 14 May 1998 16:39:31 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Mathijs Oosterom <thijs@esense.nl>
Subject: Re: creating some sort of deamon
Message-Id: <Pine.GSO.3.96.980514093834.21974Y-100000@user2.teleport.com>
On 14 May 1998, Mathijs Oosterom wrote:
> This script must be activated only once a day,
Sounds like a cron task, or your local equivalent. Ask your system
administrator whether you may use cron or another task scheduler. Good
luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 14 May 1998 17:26:20 +0100 (BST)
From: CBS5AHR@leeds.ac.uk (A.H. Roberts)
Subject: Digit matching regex
Message-Id: <6jf607$eek_001@leeds.ac.uk>
I am trying to write a condition that matches ONLY digits.
/\d+/ recognizes any string with at least one digit, so e.g. 3llama is
matched.
/[^a-zA-Z]+/ does exactly the same thing.
What should the regex be?
Thanks,
Adam
------------------------------
Date: 14 May 1998 16:58:34 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Digit matching regex
Message-Id: <6jf7rq$p00@news-central.tiac.net>
In article <6jf607$eek_001@leeds.ac.uk>,
A.H. Roberts <CBS5AHR@leeds.ac.uk> wrote:
>I am trying to write a condition that matches ONLY digits.
>
>/\d+/ recognizes any string with at least one digit, so e.g. 3llama is
>matched.
>
>/[^a-zA-Z]+/ does exactly the same thing.
\d+ does match against one or more digits. If you mean that you want a
regex which matches only against strings which are composed entirely of
digits then you might want to look at the ^ and $ anchors described in the
perlre man page
man perlre
or
perldoc perlre
on an up to date perl installation should get you the documentation.
One thing to try might be /^\d+$/.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: Thu, 14 May 1998 13:13:37 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Digit matching regex
Message-Id: <comdog-ya02408000R1405981313370001@news.panix.com>
Keywords: from just another new york perl hacker
In article <6jf607$eek_001@leeds.ac.uk>, CBS5AHR@leeds.ac.uk (A.H. Roberts) posted:
>I am trying to write a condition that matches ONLY digits.
>
>/\d+/ recognizes any string with at least one digit, so e.g. 3llama is
>matched.
well, this one matches digits. do want a regex that matches a string
with only digits?
/^\d+(?!\n)$/
see the perlre man page for details.
>/[^a-zA-Z]+/ does exactly the same thing.
no it doesn't. it matches anything that isn't a-z or A-Z, which is a
lot more than 0-9.
good luck :)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>
------------------------------
Date: 14 May 1998 17:26:55 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Digit matching regex
Message-Id: <6jf9gv$4oh$3@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
CBS5AHR@leeds.ac.uk (A.H. Roberts) writes:
:/\d+/ recognizes any string with at least one digit, so e.g. 3llama is
:matched.
:/[^a-zA-Z]+/ does exactly the same thing.
No it doesn't.
$status_1 = " " =~ /\d+/;
$status_2 = " " =~ /[^a-zA-Z]+/;
And you just mean /^\d+$/, just as perldata shows.
warn "has nondigits" if /\D/;
warn "not a whole number" unless /^\d+$/;
warn "not an integer" unless /^[+-]?\d+$/
warn "not a decimal number" unless /^[+-]?\d+\.?\d*$/
warn "not a C float"
unless /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/;
I also wish people would stop using [a-zA-Z] when they need
to use [^\W\d_] instead.
--tom
--
If you want your program to be readable, consider supplying the argument.
--Larry Wall in the perl man page
------------------------------
Date: 14 May 1998 16:11:56 GMT
From: Art Cohen <upsetter@shore.net>
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6jf54c$scf@fridge.shore.net>
Greg Bacon <gbacon@cs.uah.edu> wrote:
: In article <6je3d3$o7q@news.nl.compuware.com>,
: koos@stag (Koos Pol) writes:
: : Flipping pages is
: : better that flipping manpages after all...
: I'm not sure who said it first (I suspect Tom C.), but you can't grep
: dead trees.
That's why books have indexes. (Or indices, if you're anal retentive).
And you can't take manpages into the bathroom...
--Art
National Ska/Reggae Calendar: www.ziplink.net/~upsetter/ska/calendar.html
Boston Ska Home Page: www.ziplink.net/~upsetter/ska/index.html
------------------------------
Date: 14 May 1998 12:31:36 -0400
From: fsg@gallo.ultranet.com
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6jf698$1ca$1@gallo.ultranet.com>
gbacon@cs.uah.edu (Greg Bacon) writes:
>dont_use_this_ey@hotmail.com (Frank) writes:
>: Using Perl _is_ dumbing down programming. Perl is full of constructs
>: which behave strange (I think it is called special variables,MAGIC,
>: context).
>You exhibit a fundamental failure to understand what Perl is all about.
Tell us, wise gbacon@cs.uah.edu, what Perl is all about.
>The difference between Perl and Visual Doomaflotchy 9000 is that Perl
>decreases the pulled hair volume of programmers as opposed to leading
>nonprogrammers to believe that they can program too.
False. Perl is a great language for nonprogrammers and programmers
alike. Like any language, it has features for both ease of use and
hardcore coding. The fact that it's implemented both ends of the
equation so well at the same time is what's tripping you up.
For someone who screams so loudly, obnoxiously, and vituperatively
about how great it is to know Perl and how much it sucks to be just
another stupid user, you sure do seem to be reading a lot of news
articles that raise your blood pressure. Masochism, stupidity,
or rank hypocrisy?
Whatever your particular problem is, you're missing two other fundamental
points, both of which make you look foolish.
1. Perl is designed as a glue language to help people. It's a positivist
thing that makes everyone's work easier. It is not designed as a negative
thing that fights against people. Part of the community of Perl involves
giving selflessly.
2. You're posting your ranting diatribe to millions of people, most of
whom will likely think that you are an egotistical prat who has great
difficulty putting together coherent, logical thoughts. It would be much
better for all concerned if, when you became angry at the thought of
other people learning how to program by using a helpful tool, you simply
went home and punched a pillow, or talked it over with a friend.
Felix
------------------------------
Date: 14 May 1998 12:43:57 -0400
From: fsg@gallo.ultranet.com
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6jf70d$1dd$1@gallo.ultranet.com>
gbacon@cs.uah.edu (Greg Bacon) writes:
>The very act of exposing Perl's pristine beauty to the unappreciative,
>unthinking, and, hence, unworthy clueless droves of lose32 users is
>dumbing down the language.
When you get out of school, you will realize that the world is composed
of many different kinds of people. For instance, there is a large
segment of people for whom using computers is not the overriding life goal.
These people would like to use computers, perhaps, to help make their
lives easier; but realistically, they don't want to know about backtracking.
Like programmers with "make", they are pleased just that it works, without
knowing the details of how.
Another thing you will learn, I hope before you get out of school, is how
to have a coherent and logical thought. When you say that the 'act of
exposing Perl's ... beauty to the ... droves of ... users is dumbing
down the language', you are obviously confused or mistyping. The act
of exposing Perl's beauty has no effect on the language whatsoever. Perl5
is Perl5, whether or not it resides on an OS/2, Unix, or Windows operating
system.
Perhaps you meant to say, "There are unappreciative, unthinking, and, hence,
unworthy clueless droves of lose32 users who ask lots of questions in
comp.lang.perl.misc, and that frustrates and confuses me." This is more
comprehensible than your prior argument. If that's what you really meant,
then I recommend that you study up on some of the more interesting features
of the Perl language -- for instance, the ones that let you analyze blocks
of text for patterns.
It would certainly be helpful for Perl-as-a-community if the arrogant
and illogical posters among us who appear to get extremely anxious at
the concept of someone they don't approve of learning the Perl language
would follow suit and use the Perl language to avoid getting themselves
so riled up that they post embarrassingly incoherent and unpleasant
attacks that lower the signal to noise ratio of the main perl newsgroup.
Felix
------------------------------
Date: 14 May 1998 12:58:31 -0400
From: fsg@gallo.ultranet.com
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6jf7rn$1f9$1@gallo.ultranet.com>
mwmaurer@mtu.edu (Mark Maurer) writes:
>Frank (dont_use_this_ey@hotmail.com) wrote:
>: Tom Christiansen <tchrist@mox.perl.com> writes:
>: > See http://www.salon1999.com/21st/feature/ for more on this.
>A VERY good site, I thought...
>: This whole discussion makes me sick.
>???
What's to question? It makes me sick, too. The Salon article is vapid.
>: Using Perl _is_ dumbing down programming. Perl is full of constructs
>: which behave strange (I think it is called special variables,MAGIC,
>: context).
>Uhh, no. All useful (and many nonuseful) programming languages contain
>ideosyncracies. Having the special variables, such as $_, $|, etc does NOT
>make dumbed-down programming.
How about regular expressions? Dumbed down state machines (you can't
even get at the internal state nodes). How about the <> operator? Dumbed
down file operation -- you can't get at the inode directly.
Let's face it -- the idea of 'dumbed down' is preposterous. The entire
reason why we are writing in Perl is because it does so much for us
behind the scenes. When we talk of the fact that writing Perl programs
takes a fraction of the time of writing equivalent C programs, the
simplification and encapsulation process erroneously tagged 'dumbing down'
is the responsible entity.
>: Perl is full of wizards (in this context called MODULES) which allow me
>: to tackle tasks which I should better have avoided. The usage of these
>: Modules/Wizards will backfire at some point of time.
>Well, they already have for some people. A LOT of people flat out do not use
>them.
If you're claiming that's because they're clinging to a frontier concept of
programming and don't want to be namby pamby, I would have to disagree.
I haven't met a programmer yet who doesn't use them whenever available.
>: To give new names to these things does not make them better.
>Well, perl is not just giving these things a new name, they are rather
>differeint, IMO...
Your opinion is erroneous. Despite the name, there is nothing 'magical'
about a 'wizard' under win32. 'Wizards' just perform a certain templated
function with a pretty interface on front. The thing that's probably
closest to 'Wizards' in Perl is makemaker, the tool that lets you type
'perl Makefile.PL; make; make install' for all of the Perl modules on CPAN.
>: - Perl is one of many ways to do things.
>In my estimation, usually one of the better ways...
Here we agree. But don't let religion get in the way of clear thinking.
Felix
------------------------------
Date: 14 May 1998 12:50:26 -0400
From: fsg@gallo.ultranet.com
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6jf7ci$1eb$1@gallo.ultranet.com>
gbacon@cs.uah.edu (Greg Bacon) writes:
> [...]
>You're putting words in my mouth. IDEs are crutches. IDEs are evil
>implements for locking users into a specific software line from a
>specific vendor. I don't usually find software that impedes my freedom
>useful.
You're confusing objective reality with that-which-you-believe. This
is pretty common in smart CS college students.
IDEs are tools that perform a certain function. They have no inbuilt
intent. Many people's needs are completely filled by IDEs. The fact
that this frustrates and angers and disappoints you is in no way contrary
to that reality.
>: Apparently, you now agree with me.
>I certainly don't. However, who am I to tell anyone how they should
>invest their time and talents?
It's ironic that you ask that question after filling up the newsgroup
with endless posts about how IDEs suck, lose32 users suck, and so on.
I suppose I shouldn't make fun of you, but honestly, you're right --
you really aren't qualified to tell people how they invest their time
and talents, and you really ought to stop embarrassing Perl by simultaneously
holding yourself out as a spokesman for Perl and denigrating the largest
segment of its userbase.
Felix
------------------------------
Date: 14 May 1998 16:39:54 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6jf6oq$r7j$4@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Art Cohen <upsetter@shore.net> writes:
:That's why books have indexes. (Or indices, if you're anal retentive).
I've always liked the practice that books had indexes,
but that arrays had indices.
--tom
--
: The ksh scripts do not have a problem with it.
That's because ksh doesn't much mind opening up security holes. The
absence of taint checks is not exactly a feature.
Larry Wall in <1994Dec15.013044.16127@netlabs.com>
------------------------------
Date: Thu, 14 May 1998 16:15:34 GMT
From: cicho@polbox.com (Marek Jedlinski)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <355b10d0.2798038@news.nask.org.pl>
Keywords: If you're happy and you know it, clunk your chains.
murrayb@vansel.alcatel.com (Brad Murray) wrote:
<<snip>>
>Consequently, my 'IDE' on any given system consists solely of ensuring
>that a minimum subset of the text manipulation tools I need to work
>exist for my platform. Fortunately, they always seem to if I dig hard
>enough and am prepared to overlook some inconsistencies. For me, that
>means I have versions of emacs, vi, grep, awk, and a bunch of other GNU
If your emacs setup has hooks for running perl, accessing docs without
leaving the editor, viewing program output (both STDIN and STDERR) without
leaving the editor, etc., then I humbly submit you are, effectively, using
a (home-grown instance of an) IDE.
>No IDE would let me be as productive as a good editor,
Yet an IDE *is* a good text editor, basically. Good enough so it can
accommodate tasks like those I mentioned above. Whether this is achieved
via macros of one's own design or features built into the editor's 'core'
seems irrelevant to me.
Of course you have to be fairly proficient with all things unix (and
LISPish) to customize your emacs, while a robust, perl-specific IDE with
all the hooks *that you need and use* pre-installed would simply be a great
assistance and relief to less experienced folks. (I am sure *some* readers
here will understand what I mean when I say that one of the obstacles to
becoming "good at perl" is not knowing much C. Or Lisp :)
>a command line
>that lets me pipe, and some good filters to pipe through.
Naturally. Perhaps a well-designed IDE would let you do this without
exiting it or switching to another terminal screen.
>With these
>I can create solutions rather than whine about my interface. I like
>never telling a client 'it cannot be done', and I would never say that
>just because I couldn't find the button I need to push because the IDE
>designer did not envision my current needs.
What's the *principle* that prevents an IDE from being as open-ended,
customizable and flexible as a good text editor can be?
What's wrong with an editor that will, when you place the cursor on a
keyword and hit a key, pop up syntax help for that keyword? Or an editor
that would open a file referenced in "use" or "require" without you having
to type the full name of that file? That's part of what IDEs are for.
>In short, if you like IDEs, use Visual Basic. Perl is not for you.
>Perl is for finding solutions, constrained only by your capacity to
>implement them.
No offense, but you seem to define an IDE as a
brain-dead-editor-with-buggy-syntax-coloring. That's wrong, IMO.
I can use a plain text editor to do the typing, then exit the editor and
type
perl my_latest_foo.pl
or perhaps
perl my_latest_foo.pl > see_what_happened.txt
Then load the editor again (or switch back to it)... etc.
Or, I can use an IDE and achieve the above with a single keypress. What's
wrong with it as long as I control the keypress? Of course, the single
keypress will do more than that: it will let me keep and reuse the program
output "window" (however that "window" might be implemented in an IDE of
your choice), it will also intercept STDERR output, which the simple
command-line redirection won't, and perhaps it will even parse the compiler
error messages and jump to the first line flagged for an error. Exactly
what kind of a problem do you have with an application that will do that?
.marek
--
After things go from bad to worse, the cycle will repeat itself.
http://come.to/fnord/
------------------------------
Date: Thu, 14 May 1998 15:57:39 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: tdj@mail.com
Subject: Re: gethostbyaddr not working in perl5.00401?
Message-Id: <Pine.GSO.3.96.980514085422.21974W-100000@user2.teleport.com>
On Thu, 14 May 1998 tdj@mail.com wrote:
> I found that the following function
>
> gethostbyaddr
>
> works fine if I use the perl version:
> #!/usr/bin/perl
>
> however it return empty results if I use the perl version:
> #!/usr/bin/perl5.00401
>
> Any idea what the problem is?
Almost certainly, the second perl binary is mis-compiled. I'd guess that
it's not properly configured to use your system's resolver. Build it
again, being sure to test that function before installing. Hope this
helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 14 May 1998 16:34:04 GMT
From: michael.e.hagin@boeing.com (Michael E. Hagin)
Subject: How can I overwrite characters?
Message-Id: <EsyGos.Gx5@news.boeing.com>
Hello,
I would like to use printf to overwrite characters written to
STDOUT. I can suppress the newline by not including "\n" but how
can I suppress the line feed?
Thanks,
--
Mike Hagin Voice:770-497-5426
System Administrator Fax :770-497-5555
Boeing Autonetics Email:Michael.E.Hagin@Boeing.com
------------------------------
Date: 14 May 1998 17:29:59 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: How can I overwrite characters?
Message-Id: <6jf9mn$4oh$4@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
michael.e.hagin@boeing.com writes:
:Hello,
:
: I would like to use printf to overwrite characters written to
:STDOUT. I can suppress the newline by not including "\n" but how
:can I suppress the line feed?
I think you mean doing something like:
$| = 1;
printf "%8d\r", $i++ while 1;
--tom
--
Thou shalt run lint frequently and study its pronouncements with care, for
verily its perception and judgement oft exceed thine.
--1st commandment for C programmers
------------------------------
Date: Thu, 14 May 1998 16:21:23 GMT
From: stu-w@usa.net.remove.everything.after.net (Stuart Wright)
Subject: Re: How can you break out of a 'while... ' loop in a function?
Message-Id: <355b19e5.5872263@news.demon.co.uk>
On Thu, 14 May 1998 14:53:14 GMT, jdporter@min.net (John Porter) wrote:
>
>Of course, it might be nice to put this into a subroutine:
>
>sub lookup_member {
> my( $member, $file ) = @_;
> open(MF, "< $file") || die "open $file: \n";
> while (<MF>) {
> my @a = split( /%/, $_ ); # split $_, not $line
> my $mem = shift @a;
> return @a if $mem eq $member;
> }
> (); # member not found in file
>}
>
>( $a1, $a2, $a3, $a4, $a5, $pc, $dateob )
> = lookup_member( $member, $memberfile );
>
>hth,
>John Porter
>
Very neat - I've learned a buch but I have a bunch more to learn !
Thanks
------------------------------
Date: 14 May 1998 16:51:54 GMT
From: angst <angst@scrye.com>
Subject: Re: How can you break out of a 'while... ' loop in a function?
Message-Id: <6jf7fa$ffc$1@jelerak.scrye.com>
Tina Marie Holmboe <tina@scandinaviaonline.se> wrote:
: I think the egg is on my face for not explaining myself sufficiently. Let
: me see if I cannot use the *right* words this time...
Let's see if I understand you better this time...
: Firstly, I am *not* saying that next()/last() == goto(). Had I done that
: I would be due for some padded room.
I agree with you, at least, on this point.
: What I *am* saying is that in concept both next() and last() do the same
: thing to a loop that a goto() does - it interrupts the flow; it "breaks out"
: of it. next() is by far the least 'harmful' - and note the 's there - of
: the two, as it merely skips to the next iteration.
I think you're oversimplifying things. Yes, they interrupt the flow, but
they interrupt it in a much different manner.
: From a maintenance-perspective, this is a fairly easy construct to work
: with. Everything you need is in that first line. Consider, next, this:
No, everything you need is in the two lines. The first line says nothing
about what you're doing with the keys. From a maintenance perspective, if
you wanted to do something different with each key, you need to know what
the whole construct does, not just the iteration part.
: ITR: foreach $key ( sort ( keys ( %hash ) ) ) {
: if ( $key eq 'lwall' ) { last(ITR) ; }
: print "$key\n" ;
: }
: "Iterate over the sorted keys from the associative array 'hash'" and
: "Print the key... unless it is equal to 'lwall', then stop"
I think you misworded this in a rather important way...more accurately
it's "iterate over the sorted keys from the hash...if you come to a key
called 'lwall', stop the iteration. Otherwise, print the key".
The difference does a lot to discredit your argument, IMO.
: Now add - left as an exercise :) - more tests for special cases inside the
: block. The number of exits are then N>1. and the loop - again in my humble
: opinion - has become much harder to maintain and debug.
Perhaps, but if the thing has only one exit point, you're limiting yourself
greatly. consider something like this:
# find the key called "foo" in a very large hash.
%hash = {
# insert 100,000 key-value pairs here
}
foreach $key ( sort (keys (%hash))){
$val = $key if $key eq 'foo';
}
print "foo is $val\n";
There's a loop with one exit point...very simple to maintain and debug
by your definition, but horribly inefficient, particularly if 'foo' is
found very early in the hash. Consider this loop instead:
foreach $key (sort keys %hash){
if($key eq 'foo'){ $val = $key; last; }
}
This is significantly more efficient, because you don't have to iterate over
every single value in the hash unless the key you want is the last value,
which is rather unlikely, particularly in a very large hash.
: Secondly, I am *not* saying that next() and last() doesn't have their
: rightful place among the tools-of-the-trade, but I am trying to point out that
: from a structure and maintenance perspective one should really consider
: (twice) whether
: a) next()/last() is a good solution, or
: b) the loop itself needs re-working.
Okay, from a maintenance perspective, your argument might have some merit, but
not much. From an initial creation and efficiency perspective, however, it's
a load of crap (so to speak). Yes, I could go through all of my loops and
spend two weeks rewriting them all to have one exit point, with the end
result that a.) i would have wasted a lot of time and b.) they would be
less efficient, and the program would take longer to run. If you
can't figure out how to use control structures properly, perhaps you
should work on increasing your understanding of the language rather than
trying to write code with as few actual unique commands (gasp) in it as
possible.
: These words make more sense ?
I can only hope I'm still misunderstanding you, because if not, what you're
advocating is extraordinarily bad programming practice.
--
Erik Nielsen <eln@rmci.net>
mail to above (rather than header address) is answered significantly faster.
this post != views of anyone at all, really
"You are like...unix GOD" -- local tech support
------------------------------
Date: 14 May 1998 17:06:17 GMT
From: angst <angst@scrye.com>
Subject: Re: Is if ($a="something") a bad style?
Message-Id: <6jf8a9$ffc$2@jelerak.scrye.com>
Shaun Sides <arch@abts.net> wrote:
: I believe that undef is defined (no pun intended) as anything which
: evaluates to 0, "0", or "".
You are under a misconception. undef is anything that has _no_ value
(is undefined). 0, "0", and "" all have defined values...those values
evaluate to false, but they're still defined.
Think of it like this...
#!/usr/local/bin/perl
# here $x is not defined
$x = "";
# here $x has been defined with an empty string.
So, you have defined $x with a value, even if that value is empty.
Let's say we made a reference to $x (like a pointer in C).
Before $x is defined, the pointer just points to some random spot in
memory (although i'm not even sure if pointing to an uninitialized variable
is even legel). After $x is defined, the pointer points to a spot in memory
that has a specific value. If $x is stored in, say, memory location
12345, memory location 12345 before the assignment statement holds
random garbage (it is not "defined" to be anything in particular).
After the assignment statement, memory location 12345 holds a definite
value (which is ""). The string "" is not the same as "random undefined
garbage", hence it is not the same as undefined.
Basically, a variable (and hence its value) is "defined" once you've set
it to something particular, including 0, "0", or "", and remains defined
until it is explicitly undefined (or control passes out of its scope).
so if($x) is not the same as if(defined $x).
--
Erik Nielsen <eln@rmci.net>
mail to above (rather than header address) is answered significantly faster.
this post != views of anyone at all, really
"You are like...unix GOD" -- local tech support
------------------------------
Date: Thu, 14 May 1998 16:46:37 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Meelis Roos <mroos@ut.ee>
Subject: Re: localized ctime?
Message-Id: <Pine.GSO.3.96.980514094611.21974a-100000@user2.teleport.com>
On 14 May 1998, Meelis Roos wrote:
> Can anybody tell me where can I find a ctime() that uses my locale
> settings?
If there's a module which does what you want, it should be listed in
the module list on CPAN. If you don't find one to your liking, you're
welcome and encouraged to submit one! :-) Hope this helps!
http://www.perl.org/CPAN/
http://www.perl.com/CPAN/
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 2596
**************************************