[17290] in Perl-Users-Digest
Perl-Users Digest, Issue: 4712 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 24 14:10:44 2000
Date: Tue, 24 Oct 2000 11:10:20 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <972411020-v9-i4712@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 24 Oct 2000 Volume: 9 Number: 4712
Today's topics:
Re: Make me a hot or not script <gellyfish@gellyfish.com>
Re: Make me a hot or not script <uri@sysarch.com>
Re: Make me a hot or not script <godzilla@stomp.stomp.tokyo>
Monitor TCP ports anewcomb@my-deja.com
Re: New to Perl, Need Help ! <lr@hpl.hp.com>
Re: New to Perl, Need Help ! <lr@hpl.hp.com>
Re: newbie : Installing Danise shopping cart <sales@gboworld.com>
Re: newbie questions... viscido@u.washington.edu
Re: OT: Jihad definition (NP)
Re: OT: Jihad definition <lr@hpl.hp.com>
Re: OT: Jihad definition (NP)
Re: Paragraph slurping for reading records from config (Gwyn Judd)
Re: Paragraph slurping for reading records from config xerxes_2k@my-deja.com
Re: parse url nobull@mail.com
Re: Ping via PERL? <jcipale@hotmail.com>
Re: Ping via PERL? (NP)
Re: Ping via PERL? <jcipale@hotmail.com>
Re: please help me! Installing DBI and DBD on WIN98 <jeff@vpservices.com>
Re: Regular expression help <lr@hpl.hp.com>
Re: Regular expression help (Craig Berry)
socket problem <neil@thump.org>
Re: Subroutine reference/undef/redefine anomaly nobull@mail.com
Re: Subroutine reference/undef/redefine anomaly nobull@mail.com
System Calls from Perl Help??? gary.lefko@usafa.af.mil
Re: System Calls from Perl Help??? (John J. Trammell)
Re: System Calls from Perl Help??? nobull@mail.com
Re: System Calls from Perl Help??? gary.lefko@usafa.af.mil
Two Perl-ODBC Problems - Help! <sg@loralskynet.com>
Re: What will the code look like? (Tad McClellan)
Re: What will the code look like? (Tad McClellan)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 24 Oct 2000 15:28:46 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Make me a hot or not script
Message-Id: <OUhJ5.24$ZA5.1350@news.dircon.co.uk>
On Tue, 24 Oct 2000 16:53:19 +0200, Matthijs van Duijvenbode Wrote:
> Hello,
>
>
> I need to find a cgiprogrammer to do a proposal to build a script similar to
> that one can see at www.amihotornot.com.
> (Perl, UNIX) I´m looking for someone who can give me a fixed price.
>
Strange that we were just chatting about making doesmycodesuckornot.com ...
If you want a programmer ask in a jobs group.
/J\
------------------------------
Date: Tue, 24 Oct 2000 16:05:15 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Make me a hot or not script
Message-Id: <x7g0lmns1w.fsf@home.sysarch.com>
>>>>> "MvD" == Matthijs van Duijvenbode <matthijs@vanduijvenbode.com> writes:
MvD> I need to find a cgiprogrammer to do a proposal to build a script
MvD> similar to that one can see at www.amihotornot.com. (Perl, UNIX)
MvD> I´m looking for someone who can give me a fixed price.
$50,000. take it or leave it.
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, 24 Oct 2000 09:15:24 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Make me a hot or not script
Message-Id: <39F5B59C.4C8F1B8B@stomp.stomp.tokyo>
Uri Guttman wrote:
> Matthijs van Duijvenbode wrote:
> > I need to find a cgiprogrammer to do a proposal to build a script
> > similar to that one can see at www.amihotornot.com. (Perl, UNIX)
> > I´m looking for someone who can give me a fixed price.
> $50,000. take it or leave it.
Always figured you are a cheap programmer.
Heh!
What does he have at that site? I didn't bother looking.
Godzilla!
------------------------------
Date: Tue, 24 Oct 2000 15:03:51 GMT
From: anewcomb@my-deja.com
Subject: Monitor TCP ports
Message-Id: <8t48ch$722$1@nnrp1.deja.com>
Can perl passively monitor TCP ports? I would
like to write a script to monitor ports and
output the traffic to a flat text file.
Thanks,
Aaron Newcomb
aaron@newcombnet.com
http://www.newcombnet.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 24 Oct 2000 10:44:10 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: New to Perl, Need Help !
Message-Id: <MPG.145f6a40683d30f898ae60@nntp.hpl.hp.com>
In article <slrn8vah2p.bfl.tjla@thislove.dyndns.org> on Tue, 24 Oct 2000
08:12:18 GMT, Gwyn Judd <tjla@guvfybir.qlaqaf.bet> says...
...
> if (4 != grep { $_ <= 255 && $_ >= 0}
> ($ipoaip =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/))
...
> chomp(my $ethip = <STDIN>);
> if (4 != grep { $_ <= 255 && $_ >= 0}
> ($ipoaip =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/))
The regexes should be anchored on each end. And the second one should
bind to $ethip, obviously.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 24 Oct 2000 10:47:20 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: New to Perl, Need Help !
Message-Id: <MPG.145f6b01a13db74898ae61@nntp.hpl.hp.com>
In article <slrn8vb8it.duj.tjla@thislove.dyndns.org> on Tue, 24 Oct 2000
14:53:25 GMT, Gwyn Judd <tjla@guvfybir.qlaqaf.bet> says...
> I was shocked! How could Arie van Wingerden <a.vanwingerden@pcmuitgevers.nl>
> say such a terrible thing:
...
> > 4. then compare the digit groups of both ip-adressess one by one
> >numerically (using == not eq)
>
> Ick. Why not just compare the string representations of both once, using
> 'eq'?
Are the strings '127.0.0.1' and '127.000.000.001' not equivalent
representations for 'localhost', for example?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 24 Oct 2000 15:31:09 GMT
From: gboworld.com <sales@gboworld.com>
Subject: Re: newbie : Installing Danise shopping cart
Message-Id: <8t49vt$8m6$1@nnrp1.deja.com>
We have designed a frame shopping cart,
and a window shopping cart.
if interested, please visit
http://gboworld.com/index.html
they are easy to be used to design e-commerce store front.
One of our customers has an online ecommerce shop:
http://intercomp.com.au/e-bellingen
It is a nice design for a storefront.
Our shopping carts are easier to use.
In article <rfk9vs4d8moj1qqkrbfft8421jtlr4bt49@4ax.com>,
Landore <me@you.com> wrote:
> Hello,
> Im trying to install denise shopping cart, being more of a graphics
> design background im pretty new to perl/cgi. I have done everything in
> the readme that should be done but I dont understand why when I test
> the script it does'nt respond. I checked the error logs and found it
> says
> Premature end of script headers: /www/cgi-bin/cart.pl
>
> anyone know what this means and how I can fix it
> Im sure all my paths are correct in the vars.dat file
>
> hope someone can help with my question
>
> TIA
>
> Landore
>
--
Thanks,
gboworld.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 24 Oct 2000 08:37:21 -0700
From: viscido@u.washington.edu
Subject: Re: newbie questions...
Message-Id: <m3em16mery.fsf@fiddler.u.washington.edu>
"Brian Reichholf" <brian@reichholf.at> writes:
> Where do i get the perlfaq8 from????
>
> I'm just new to perl and am very interested in it and haven't found any
> really good faq, reference or tutorial on the net,
> pelease help!
> thx in advice
I'm also new to Perl (just started playing with it last week). As good
as the net is, IMO, there's no substitute for a good, physical
manual. I've started with the O'reilly book "Learning Perl", and so
far (I'm about 4 chapters into it) I find it readable, and very
explanatory. I suggested investing the $35 or so it costs to get it.
Steve
--
Steven Viscido [viscido@u.washington.edu]
Department of Zoology, Box 351800 Kincaid Hall
University of Washington
Seattle, WA 98195 Tel: 206-221-6904
------------------------------
Date: Tue, 24 Oct 2000 15:15:17 GMT
From: nvp@spamnothanks.speakeasy.org (NP)
Subject: Re: OT: Jihad definition
Message-Id: <9IhJ5.86149$bI6.3096112@news1.giganews.com>
jeff@vpservices.com wrote:
:
: I have no idea what a MOOP is or what the smiley in that sentence means,
: but in a world where people are murdered every day because of their
MOOP came from a classic episode of "Seinfeld".
: religion or ethnicity, I find nothing funny in your reply nor in the
: original reference to a Jihad as a synonym for terrorism, nor in the
: attempt to make fun of someone's "foreign" sounding name.
I think that you should yell at the original person who posted the
remarks, then. Don't lecture me, as I didn't start this silly
sidetrack, or point your lecture via attribution at the reptile who
started this ASCII diarrhea.
--
Nate II
------------------------------
Date: Tue, 24 Oct 2000 10:07:18 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: OT: Jihad definition
Message-Id: <MPG.145f61a0acfd00a398ae5e@nntp.hpl.hp.com>
In article <9IhJ5.86149$bI6.3096112@news1.giganews.com> on Tue, 24 Oct
2000 15:15:17 GMT, NP <nvp@spamnothanks.speakeasy.org> says...
> jeff@vpservices.com wrote:
> :
> : I have no idea what a MOOP is or what the smiley in that sentence means,
> : but in a world where people are murdered every day because of their
>
> MOOP came from a classic episode of "Seinfeld".
>
> : religion or ethnicity, I find nothing funny in your reply nor in the
> : original reference to a Jihad as a synonym for terrorism, nor in the
> : attempt to make fun of someone's "foreign" sounding name.
>
> I think that you should yell at the original person who posted the
> remarks, then. Don't lecture me, as I didn't start this silly
> sidetrack, or point your lecture via attribution at the reptile who
> started this ASCII diarrhea.
Hitler, Godwin, Hitler, Godwin, Hitler, Godwin, ...
Enough already! There is plenty of animosity here relating to Perl,
without dragging this stuff in here also.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 24 Oct 2000 17:21:02 GMT
From: nvp@spamnothanks.speakeasy.org (NP)
Subject: Re: OT: Jihad definition
Message-Id: <2yjJ5.86507$bI6.3109657@news1.giganews.com>
lr@hpl.hp.com wrote:
:
: Hitler, Godwin, Hitler, Godwin, Hitler, Godwin, ...
To invoke Godwin's Law, one must provide context, although I get your
point.
: Enough already! There is plenty of animosity here relating to Perl,
: without dragging this stuff in here also.
<sarcasm emphasis="high">
But the Perl Community is a benevolent and giving bunch, and never have
I seen an trace of animosity in this beloved forum. Or am I missing
something?
</sarcasm>
--
Nate II
------------------------------
Date: Tue, 24 Oct 2000 15:17:32 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Paragraph slurping for reading records from config files
Message-Id: <slrn8vba04.duj.tjla@thislove.dyndns.org>
I was shocked! How could xerxes_2k@my-deja.com <xerxes_2k@my-deja.com>
say such a terrible thing:
>not sure if this is the main problem but, u are pushing onto an array
>from a split on :. and then pushing a reference (i think) onto another
>array.
You think? The code was pretty obvious to me.
>then foreaching that array.
>but, and heres the important but, u r then tying to use tha element of
>the array as a hash not an array.
That's because it's a hash-of-arrays. Check the documentation:
perldoc perllol
perldoc perlref
perldoc perldsc
>try this;
Why don't you try it? It's common courtesy around here to cut-and-paste
code, not type it in and never to post untested code unless you mark it
as such.
>while(<fh>){
> ($field, $value)=(split /whateverthat was/);
> $fileds{$field}=$value;
> push @array, \%fields;
>}
>
>and the rest should be ok.
Except for the missed fields. And the fact that you forgot to remove the
leading null field. You have taken the part of the code which worked
fine and introduced a bug while ignoring the real problem which was that
the OP had typed it in wrong. It's obvious from a few of your answers
that you are really a beginner. It's good to want to try and help but
when you are just guessing at the solutions it does noone any good.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
If God had meant for us to be naked, we would have been born that way.
------------------------------
Date: Tue, 24 Oct 2000 15:46:44 GMT
From: xerxes_2k@my-deja.com
Subject: Re: Paragraph slurping for reading records from config files
Message-Id: <8t4at1$9d8$1@nnrp1.deja.com>
as opposed to you. u seem to like going round and beeting newbies into
the ground, trying to put them off from even learning perl.
you are more content on ripping peoples code apart rather than, giving
them any help.
sure i am only a begginer, im sure my code nor anyone elses is as good
as yours. but hey you were in the same position as all the begginers out
once.
You obviously are on some kind of power trip. Beating down everyone in
your path.
Your problem is you take perl, and the use of it far too seriously.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 24 Oct 2000 18:04:07 +0100
From: nobull@mail.com
Subject: Re: parse url
Message-Id: <u9itqi6uig.fsf@wcl-l.bham.ac.uk>
"Peter Clarke" <petermclarke@hotmail.com> writes:
> Is there a more efficient way of doing this? I wont to separate the host,
> path and query from a given url. It works but seems long winded.
> (I'm learning perl so using a module to do this wont show me how its
> actually done.)
The vast majority of Perl modules (including URI.pm) are written in
Perl - so directing you to the module _does_ show you how it is done.
That said, URI.pm is a bit complex, and also it parses URLs, which,
despite your subject line, are not the things that you are talking
about.
> sub parse_url {
> if ($url =~ /(.*?)(\/)(.*)/) { #read upto the first slash "/".
> $urlArray{"host"} = $1;
> $withouthost = $3;
> if ($withouthost =~ /(.*?)(\?)(.*)/) {
> $urlArray{"path"} = $1;
> $urlArray{"query"} = $3;
> } else { # no query
> $urlArray{"path"} = $withouthost;
> }
> } else {
> $urlArray{"host"} = $url; #there are no slashes so this must be the host
> and nothing else.
> }
> return %urlArray;
> }
>
> Regular expressions will be the death of me...
You have forgotten to my() all your variables. If you had put "use
strict" at the top of your script Perl would have told you about this.
Using a regex in a list assignment is often simpler than using $1
etc.
It is possible to construct a regex with optional bits so that a
single regex will do for different patterns. Any capturing
subexpressions that are within bits that were not involved in the
match will simply return undef.
You shouldn't pointlessly complicate your regex with subexpressions.
Non-capturing subexpressions are useful.
Your subroutine doesn't pares URLs so calling it parse_url is
misleading.
You should not use shared variables (like $url) in your code to pass
parameter into subroutines unless you have good reason to do so.
When returning a hash from a function it is generally better to do so
by returning a reference to the hash rather than unrolling the hash
into a list.
When naming variables it is a questionable habit to put the data type
"Array", "Hash" or whatever in the name of the variable. It is even
more questionable to put "Array" in the name of a hash.
sub parse_not_a_url {
my ($not_a_url) = @_;
my %components;
@components{'host','path','query'} = $not_a_url =~ /^(.*?)(?:\/(.*?))?(?:\?(.*))?$/;
return \%components;
}
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 24 Oct 2000 08:30:42 -0700
From: "joe cipale" <jcipale@hotmail.com>
Subject: Re: Ping via PERL?
Message-Id: <8t49v3$sjt@news.or.intel.com>
Be careful though. I just went through the same exercise.
Net::Ping works great on Unix based machines. I had problems
when attempting this module on a VAX. (Yes, there are still
some out there)
A method I used that works across the board is this:
$rslt = `ping <host_ip>`
if ($rslt =~ /active/ ) {
<Do what you need to do for an affirmative response here>
}
else {
<Trap response here>
}
Joe Cipale
"Clay Irving" <clay@panix.com> wrote in message
news:slrn8vb8j2.nh0.clay@panix2.panix.com...
> On Tue, 24 Oct 2000 14:10:53 GMT, wuselwesen@my-deja.com
> <wuselwesen@my-deja.com> wrote:
>
> >My Question is: How can i ping someone using a Perl-script?
>
> Get the Net::Ping module.
>
> --
> Clay Irving <clay@panix.com>
> There's nothing remarkable about it. All one has to do is hit the right
> keys at the right time and the instrument plays itself.
> - J. S. Bach
------------------------------
Date: Tue, 24 Oct 2000 15:45:05 GMT
From: nvp@spamnothanks.speakeasy.org (NP)
Subject: Re: Ping via PERL?
Message-Id: <58iJ5.86235$bI6.3099231@news1.giganews.com>
jcipale@hotmail.com wrote:
:
: A method I used that works across the board is this:
: $rslt = `ping <host_ip>`
One thing that occurs to me: with this method (under some platforms)
ping won't behave as you'd expect it to -- in the absence of a host
being available -- your script might hang forever. You should probably
add an alarm() option. Just a suggestion, tho.
--
Nate II
------------------------------
Date: Tue, 24 Oct 2000 09:06:54 -0700
From: "joe cipale" <jcipale@hotmail.com>
Subject: Re: Ping via PERL?
Message-Id: <8t4c2v$16u@news.or.intel.com>
"NP" <nvp@spamnothanks.speakeasy.org> wrote in message
news:58iJ5.86235$bI6.3099231@news1.giganews.com...
> jcipale@hotmail.com wrote:
> :
> : A method I used that works across the board is this:
> : $rslt = `ping <host_ip>`
>
> One thing that occurs to me: with this method (under some platforms)
> ping won't behave as you'd expect it to -- in the absence of a host
> being available -- your script might hang forever. You should probably
> add an alarm() option. Just a suggestion, tho.
>
> --
> Nate II
Not a bad idea. What I use my script for is an online display of
workstations that my company routinely
polls to download test data via our intranet. I have a small list of
workstations that I routinely ping on a
CGI web-page. If the host does not answer, then a red light gif image is
displayed. In the past this has been
sufficient enough, but I realize now that the reason for this was because
although the Net::Ping was not
working properly within the CGI, that there was some answer that was being
returned from the VAX host.
Now, if the host is completely dead, then that is another matter altogether.
Thanks, Nate!
Joe Cipale
------------------------------
Date: Tue, 24 Oct 2000 08:05:11 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: please help me! Installing DBI and DBD on WIN98
Message-Id: <39F5A527.35615552@vpservices.com>
jinlee wrote:
>
> I refered to README in DBI-1.14 but couldn't install that package.
> I tried on command line by "ppm install DBI.ppd" but i've got this message
> "Error installing package 'DBI.ppd': Could not locate a PPM binary of
> 'DBI.ppd' for this platform"
If you have downloaded a file called "DBI.ppd" and are attempting to
install it locally, that is the correct syntax. If, as is more
probable, you are just attempting to install DBI from activeState, you
do not include ".ppd" in the syntax, just:
install DBI
--
Jeff
------------------------------
Date: Tue, 24 Oct 2000 10:19:19 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Regular expression help
Message-Id: <MPG.145f64758cb01d4698ae5f@nntp.hpl.hp.com>
In article <39F59C0B.DE9A09F6@vpservices.com> on Tue, 24 Oct 2000
07:26:19 -0700, Jeff Zucker <jeff@vpservices.com> says...
> Larry Rosler wrote:
> > In article <39F4BB8F.2510ADEC@vpservices.com> on Mon, 23 Oct 2000
> > 15:28:31 -0700, Jeff Zucker <jeff@vpservices.com> says...
> > > jsfinn@my-deja.com wrote:
> > > >
> > > > At least 6 alpha-numeric characters
> > > > there must be at least 1 digit
> > > > there must be at least 1 letter
> > >
> > > /\d/ && /\D/ && /^[a-zA-Z0-9]{6,}$/
> >
> > He said at least 6 alphanumeric characters (which includes '_', but your
> > character class doesn't),
>
> I guess I define alphanumeric literally as composed of alphabetic and
> numeric characters. If you look at perlre, it contains this definition:
>
> \w Match a "word" character (alphanumeric plus "_")
You are right. The C definition of isalnum() is:
isupper() || islower() || isdigit()
The underscore is a punctuation character (ispunct()) and I shouldn't
have included it in the character class. I was conflating isalnum()
with the definition of a 'word' character in Perl, or the allowable
characters in an identifier (in Perl or C) -- isalnum() || '_'.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 24 Oct 2000 17:37:13 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Regular expression help
Message-Id: <svbi695d2ot3b5@corp.supernews.com>
Godzilla! (godzilla@stomp.stomp.tokyo) wrote:
: > 2. Capture the text matched by a subpattern for use in \N or $N constructs
: > later on in the regex or substitution portion of a s/// repectively.
:
: Don't talk about stuff I have never read about or heard about.
:
: \N ???? I will research this.
Sorry, was typing compactly. I meant the backreference variables, where N
is the number of the item captured; like \1 or $1.
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "Quidquid latine dictum sit, altum viditur."
|
------------------------------
Date: Tue, 24 Oct 2000 17:46:00 +0100
From: Neil <neil@thump.org>
Subject: socket problem
Message-Id: <wrn1OUIDfAUiu3UevbHjRjYA4q0q@4ax.com>
my $sock = new IO::Socket::INET (
PeerAddr => $host,
PeerPort => $socket,
Proto => "tcp");
die "client: could not open socket to server: $!\n" unless ($sock);
$host and $socket are correct and not firewalled off etc.
I'm getting !$ as "not owner". CAn't find anyting in dejanews to help. Running
perl 5.004_04 built for alpha-dec_osf on compaq true65 5.0a.
Any help appreciated.
TIA
Neil
------------------------------
Date: 24 Oct 2000 17:48:14 +0100
From: nobull@mail.com
Subject: Re: Subroutine reference/undef/redefine anomaly
Message-Id: <u9lmve6v8x.fsf@wcl-l.bham.ac.uk>
Jim Mauldin <mauldin@netstorm.net> writes:
> nobull@mail.com wrote:
> >
> > Jim Mauldin <mauldin@netstorm.net> writes:
> >
> > > nobull@mail.com wrote:
> > > > Undefining and then redefining a subroutine creates an anomalous state
> > > > in references to the old subroutine.
> >
> > > When you declare:
> > > my $old_foo = \&foo;
> > >
> > > a new Perl reference (with a different reference ID) is created that
> > > contains the same pointer to the sub as the one in the symbol table for
> > > &foo, and the reference count is increased to 2. When you undef &foo,
> > > the reference count of $$old_foo decreases to 1 and the status of both
> > > references are set to undef, even though the code continues to exist.
> >
> > No, undef(THING) causes THING to become undefined, it doesn't
> > disconnect references to THING. Any references to the old thing now
> > refer to the undefined thing.
> >
> Huh? Who's disagreeing?
Me.
> Your question was why a reference saved in a
> scalar continues to point to the code after the subroutine is undefined
> and then redefined, and my answer was that until you destroy all
> references to the referant, perl maintains the underlying pointers.
Your statements in the above paragraph are all true. However your
answer is still not relevant to the question.
undef(THING) (undef(@foo) or undef(%foo) or undef(&foo)) does not alter
the reference count of THING it just makes THING become an undefined
thing. Replacing somthing my assigining to a GLOB dissconnects the
old referant from the GLOB and attaches a new one. It alters the
reference counts of the two referants but does not alter either
referant.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 24 Oct 2000 17:54:54 +0100
From: nobull@mail.com
Subject: Re: Subroutine reference/undef/redefine anomaly
Message-Id: <u9k8ay6uxt.fsf@wcl-l.bham.ac.uk>
Jonathan Stowe <gellyfish@gellyfish.com> writes:
> On 20 Oct 2000 17:23:38 +0100 nobull@mail.com wrote:
> > Undefining and then redefining a subroutine creates an anomalous state
> > in references to the old subroutine.
> >
> > #!/usr/bin/perl -w
> > use strict;
> >
> > sub foo { 2 };
> > my $old_foo = \&foo;
> > undef &foo;
> > *foo = sub { 3 };
> > print 0 + defined &$old_foo;
> > print $old_foo->();
> >
> > This prints '03'. This is of course nonsense. How can I call an
> > undefined function and have it return 3?
> >
>
> Inserting a 'print $old_foo->()' between the undef'ing of foo and its
> redefinition gives some inkling of what is going on.
How does this give any more incling than simply commenting out the
redefinition as I described in my original post? You mean the fact
that the error message knows the name of the function and that somehow
the dereferencing in $old_foo->() is being handled through the symbol
table rather than directly as one would expect for a hard reference?
Yes I'd guessed that bit. I'd even guessed the reason for this: it is
done this way so that the caller stack is more readable. Are you
trying to pretend this isn't a bug?
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 24 Oct 2000 15:34:24 GMT
From: gary.lefko@usafa.af.mil
Subject: System Calls from Perl Help???
Message-Id: <8t4a60$8ob$1@nnrp1.deja.com>
(See code below)
How do you make a system call without the Perl program terminating
after the call? Below is a simple menu, if you select one menu item
and the system call gets executed, the Perl script terminates
(gracefully).
What modification do I need so the menu (and script) stays alive until
5 is entered?
Running this script from the command line.
GAry
---------Code------------
#!/usr/local/bin/perl
while ($choice != 5) {
print <<MENU;
Command Menu
1. Current date
2. Users currently logged in
3. Working directory
4. Contents of working directory
5. Quit
Enter a choice:
MENU
chomp($choice=<>);
if ($choice == 1) {exec 'date';}
if ($choice == 2) {exec 'who';}
if ($choice == 3) {exec 'pwd';}
if ($choice == 4) {exec 'ls';}
}
exit;
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 24 Oct 2000 16:30:14 GMT
From: trammell@nitz.hep.umn.edu (John J. Trammell)
Subject: Re: System Calls from Perl Help???
Message-Id: <slrn8vajuj.l3f.trammell@nitz.hep.umn.edu>
On Tue, 24 Oct 2000 15:34:24 GMT, gary.lefko@usafa.af.mil
<gary.lefko@usafa.af.mil> wrote:
[snip]
>How do you make a system call without the Perl program terminating
>after the call?
[snip]
>if ($choice == 2) {exec 'who';}
[snip]
From the first 5 lines of 'perldoc -f exec':
exec LIST
exec PROGRAM LIST
The `exec' function executes a system command and
never returns-- use `system' instead of `exec' if
you want it to return.
--
John J. Trammell
johntrammell@yahoo.com
------------------------------
Date: 24 Oct 2000 17:42:35 +0100
From: nobull@mail.com
Subject: Re: System Calls from Perl Help???
Message-Id: <u9n1fu6vic.fsf@wcl-l.bham.ac.uk>
gary.lefko@usafa.af.mil writes:
> How do you make a system call without the Perl program terminating
> after the call?
Hey look another self-answering question for the collection!
By "make a system call" he actually means "run an external program".
What I can't understand how anyone could say "make a system call" when
they mean "run an external program" and yet still ask this question.
Gary, if you haven't figured it out yet then here's a fishing lesson.
Look at your code. Figure out from context what function is being
used to call the external programs. Read the manual entry for that
function (at least as far as the second sentence).
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 24 Oct 2000 17:37:29 GMT
From: gary.lefko@usafa.af.mil
Subject: Re: System Calls from Perl Help???
Message-Id: <8t4hco$fs5$1@nnrp1.deja.com>
I just love all the extra commentary (by some users) one gets when
posting a question for help in discussion groups! "Maybe some day I'll
get REAL smart, too!"
Thanks
In article <8t4a60$8ob$1@nnrp1.deja.com>,
gary.lefko@usafa.af.mil wrote:
> (See code below)
> How do you make a system call without the Perl program terminating
> after the call? Below is a simple menu, if you select one menu item
> and the system call gets executed, the Perl script terminates
> (gracefully).
>
> What modification do I need so the menu (and script) stays alive until
> 5 is entered?
>
> Running this script from the command line.
>
> GAry
>
> ---------Code------------
>
> #!/usr/local/bin/perl
>
> while ($choice != 5) {
>
> print <<MENU;
> Command Menu
> 1. Current date
> 2. Users currently logged in
> 3. Working directory
> 4. Contents of working directory
> 5. Quit
> Enter a choice:
> MENU
>
> chomp($choice=<>);
> if ($choice == 1) {exec 'date';}
> if ($choice == 2) {exec 'who';}
> if ($choice == 3) {exec 'pwd';}
> if ($choice == 4) {exec 'ls';}
> }
> exit;
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 24 Oct 2000 13:38:00 -0400
From: Stephan Gross <sg@loralskynet.com>
Subject: Two Perl-ODBC Problems - Help!
Message-Id: <kthbvsgsaasfl9o9h85vgplh2fl5afrkrs@4ax.com>
1) I'm running a SQL query on an Access database that I know has 1060
rows. However, the query only returns about 860. Why the truncation?
I thought it might be the MAXBUFSIZE but I tripled it and still the
same result.
2) Same code as above - I'm querying for the contents of a row which
has 28 fields. I get them all back, then repeat the query using the
values I just obtained. When I print out the SQL Statement, it looks
fine, but when I run it, it gives me ODBC error
Error:[-3100] [1] [0] "[Microsoft][ODBC Microsoft Access Driver]
Syntax error (comma) in query expression
and my SQL statement is truncated.
Any ideas? TIA
================================================================
Stephan Gross Loral Skynet sg@loralskynet.com
Senior Software Engineer 908-470-2388
------------------------------
Date: Tue, 24 Oct 2000 10:23:55 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: What will the code look like?
Message-Id: <slrn8vb6rr.7nv.tadmc@magna.metronet.com>
On Tue, 24 Oct 2000 08:23:59 +0100, The Moriman <themoriman@ntlworld.com> wrote:
>
>Tad McClellan <tadmc@metronet.com> wrote in message
>news:slrn8v9sgf.5oa.tadmc@magna.metronet.com...
>> I don't know who Spike Milligan is, nor what the Goon Show is :-(
>>
>> But Ogden Nash wrote the quoted poem.
>>
>
>Shame for not knowing Spike, but my mistake, it _was_ Ogden Nash who wrote
>the quoted poem
>_but_ it was Spike Milligan who quoted the wrote poem ;-)
Then a correct attribution would have been:
Ogden Nash, as quoted by Spike Milligan
or some such.
>Search "Spike Milligan Goon" and enjoy
I have, of course, already done that :-)
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 24 Oct 2000 10:27:03 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: What will the code look like?
Message-Id: <slrn8vb71n.7nv.tadmc@magna.metronet.com>
On Tue, 24 Oct 2000 07:14:23 GMT, Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote:
>I was shocked! How could Tad McClellan <tadmc@metronet.com>
>say such a terrible thing:
>
>>I don't know who Spike Milligan is, nor what the Goon Show is :-(
>
>I pity you terribly. Goest though to Google and type in 'Spike Milligan'
>and you will get a ton of links to one of the funniest men that ever
>lived.
I have already done that.
I figured anyone who quoted "one of the funniest men that ever lived"
might himself be funny as well.
:-)
[ Ogden Nash is quite delightful. Kinda "Mark Twainish". I am
particulary fond of his "people who work sitting down get
paid more than people who work standing up" quote.
(paraphrased here)
]
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
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 4712
**************************************