[15620] in Perl-Users-Digest
Perl-Users Digest, Issue: 3033 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 12 21:05:36 2000
Date: Fri, 12 May 2000 18:05:13 -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: <958179912-v9-i3033@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 12 May 2000 Volume: 9 Number: 3033
Today's topics:
  - what is it? <paul@partitura.com>
Re:   - what is it? <Jonathan.L.Ericson@jpl.nasa.gov>
Re:   - what is it? <tina@streetmail.com>
Re:   - what is it? <lauren_smith13@hotmail.com>
Re:   - what is it? <lr@hpl.hp.com>
Re: Accidental Creation of Static Variable <mjcarman@home.com>
Re: Available: New Book, Perl Annotated Archives 1999 (Randal L. Schwartz)
Re: BEGIN and use <lr@hpl.hp.com>
Re: CHECKING FORM DATA FOR NUMERIC DATA <steve@corp.airmedia.com>
Re: CHECKING FORM DATA FOR NUMERIC DATA <lr@hpl.hp.com>
Re: Checking if Child Process is still Alive (Kenneth Herron)
Re: directory contents showing up ?!? (Abigail)
Re: directory contents showing up ?!? (David Efflandt)
Formulaire et fichier attache <fabien@fabien.com>
Re: Formulaire et fichier attache <jeff@vpservices.com>
Gtk and Pixmaps <s2mdalle@titan.vcu.edu>
Re: Guess what? the largest online book store Amazon.co <InBasket@splendent.com>
Re: Is this new language possible in perl? <s2mdalle@titan.vcu.edu>
Re: Iteration <andy@u2me3.com>
Re: Iteration <andrew.mcguire@walgreens.com>
Re: Iteration <lr@hpl.hp.com>
Re: Iteration <andrew.mcguire@walgreens.com>
NT ORACLE PERL DBD DBI->connect format mozarty@my-deja.com
pass data from WML to perl <pirod@webdifusao.com>
Re: Perl question <s2mdalle@titan.vcu.edu>
Re: Perl question <lr@hpl.hp.com>
Re: Perl question <andrew.mcguire@walgreens.com>
Re: Randomised function (Abigail)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 12 May 2000 17:24:22 -0500
From: Paul Phillips <paul@partitura.com>
Subject:   - what is it?
Message-Id: <15F82521AF5D18AC.ECEC2093AACED09A.D67F8BB484DE18E5@lp.airnews.net>
I am a Perl novice. In looking at some Perl programs I have seen this
construct:
 
I've looked in my llama and camel books and do not find a reference to
it.
Can someone tell me what it does?
Thanks
Paul Phillips
------------------------------
Date: Fri, 12 May 2000 15:34:24 -0700
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re:   - what is it?
Message-Id: <391C86F0.E1B75304@jpl.nasa.gov>
Paul Phillips wrote:
> I am a Perl novice. In looking at some Perl programs I have seen this
> construct:
>
>  
In perl context, &foo is a function call (see perldoc -q '&'). But I
wonder if you are seeing this in HTML context, in which case is
the escape sequence for a space character that will be displayed in the
browser.
Jon
--
Knowledge is that which remains when what is
learned is forgotten. - Mr. King
------------------------------
Date: Fri, 12 May 2000 19:04:20 -0400
From: Tina Mueller <tina@streetmail.com>
Subject: Re:   - what is it?
Message-Id: <8fi2l6$aoo0c$1@fu-berlin.de>
hi,
Paul Phillips wrote:
> I am a Perl novice. In looking at some Perl programs I have seen this
> construct:
>
>  
i guess you saw it in a string for putting out
HTML-code...
in this case it has got nothing to do wit hperl, it's HTML:
puts out a " ".
normal whitespaces are ignored in HTML and put
together to one, but these whitespaces are not ignored.
try it out, you'll see...
hm, clear enough?
tina
--
--- ICQ #73179850 --- | _ enter the
http://user.berlin.de/~tina.mueller | __| |___ ___ _ _ ___
---- tina's moviedatabase ----| / _` / _ \/ _ \ '_(_-< of
--search & add comments or reviews--| \__,_\___/\___/_| /__/ perception
------------------------------
Date: Fri, 12 May 2000 16:03:00 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re:   - what is it?
Message-Id: <8fi2ja$6qe$1@brokaw.wa.com>
Paul Phillips <paul@partitura.com> wrote in message
news:15F82521AF5D18AC.ECEC2093AACED09A.D67F8BB484DE18E5@lp.airnews.net...
> I am a Perl novice. In looking at some Perl programs I have seen this
> construct:
>
>  
>
> I've looked in my llama and camel books and do not find a reference to
> it.
:-) I'm not surprised.
Unless someone's written a subroutine called 'nbsp', I doubt this has
anything to do with Perl.
Try looking it up in an HTML book.
Lauren
------------------------------
Date: Fri, 12 May 2000 16:20:07 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re:   - what is it?
Message-Id: <MPG.13863182950094f998aa6d@nntp.hpl.hp.com>
In article
<15F82521AF5D18AC.ECEC2093AACED09A.D67F8BB484DE18E5@lp.airnews.net> on
Fri, 12 May 2000 17:24:22 -0500, Paul Phillips <paul@partitura.com>
says...
> I am a Perl novice. In looking at some Perl programs I have seen this
> construct:
>
>  
>
> I've looked in my llama and camel books and do not find a reference to
> it.
>
> Can someone tell me what it does?
That isn't Perl. It is incorrect HTML.
In an HTML file, the string is an entity that specifies a 'Non-
Breaking SPace'. For more about that, consult an HTML or web-authoring
newsgroup.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 12 May 2000 18:28:39 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Accidental Creation of Static Variable
Message-Id: <391C93A7.6D10F124@home.com>
Abigail wrote:
>
> So, you are saying that 'my $foo;' should not have any runtime
> effects? Or that 'EXPR if COND' should execute EXPR, even if COND
> is false? Or should Perl analyze EXPR and say "well, I know you
> made this expression conditional, and I know the condition is false,
> but for this kind of expression, I'm going to execute it anyway"?
And hence the problem: mixing compile time effects (variable
declaration) with runtime events (condition evaluation). Perhaps the
cleanest solution would be to disallow such conditional declaration of
variables. Of course, the declaration isn't really conditional.
I tried reversing the order of the sub calls from the original post,
just out of curiosity. Perl seemed to treat it as 'undef', although
(theoretically) that should have accessed random unitialized memory as
well.
> What should then happen with:
>
> my $foo = print "bar\n" if 0;
Assuming the latter DWIM interpretation, it would behave the same way:
my foo;
$foo = print "bar\n" if 0;
This may or may not be the right thing to do, but would seem the most
intuitive if the syntax is allowed. The other alternative would be that
the compile time effect of the my() would have to be somehow negated,
making $foo an undeclared variable (assuming use strict) within that
block. I am not advocating that as a 'fix' -- Blech! -- just trying to
illustrate the kind of mess you end up with when applying a condition to
an expression with both compile and runtime effects.
> ++ But the documentation states that my() variables are initialized at
> ++ runtime. As no initialization takes place under these conditions,
> ++ something (be it code or docs) is awry.
>
> So, the documentation is also `awry' because it says + does addition
> but no addition is do with:
>
> $a = 3 + 7 if 0;
Hmm. A slight stretch, IMHO, but point taken.
> Does the documentation really have to spell out every possible
> combination of operators, keywords and control structures before
> it's no longer `awry'?
Naw, then we'd have nothing to bicker about. =)
> ++ Assuming no references to $foo external to its enclosing block, its
> ++ memory will be returned to the pool after it goes out of scope. If
> ++ we go off and do other things for a while, then come back into the
> ++ block, it is quite possible that something else will have used the
> ++ chunk of memory that held $foo before. $foo will be allocated
> ++ someplace else and (being completely unitialized) could contain
> ++ anything at all.
> ++
> ++ I made a couple of half-hearted attempts at causing this, without
> ++ success, but know of no reason to think that it could not happen.
>
> Well, it doesn't seem to be happening.... ;-)
Yipes! That's an encouraging argument. :)
I think that's the real danger in this, and would like to know if anyone
is able to get it to happen. I don't know enough about Perl's guts to
force it to reuse a deallocated chunk of memory for something else.
I suppose we could argue that even if this does happen, we just have a
variable with an undefined value (truly undefined, not necessarily
'undef') so Good Practice requires that we initialize it before use.
However, this runs contrary to common coding like this:
my $n;
$n++; # $n is now 1
> Too bad hardly anyone of the Perl core hackers read this group.
Agreed. I'd be interested to know if this situation was ever considered,
or is just another s///ee type of behavior.
-mjc
------------------------------
Date: 12 May 2000 17:10:46 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Available: New Book, Perl Annotated Archives 1999
Message-Id: <m13dnnxqbd.fsf@halfdome.holdit.com>
>>>>> "JDK" == JDK <jdkahn@megsinet.net> writes:
JDK> Tons of Perl and integrating it into other technologies
JDK> See link for details:
JDK> http://cgi.ebay.com/aw-cgi/[deleted]
[Here's what I just posted a few days ago on a similar posting...]
And you're willing to spend approximately $1400 of the collective disk
storage, transmission time, and labor cost of reading (or ignoring)
your article, just so that you can get $20. $1400 that won't come out
of your pocket.
Geez man, get a sense of the economics. You just spent my money to
sell something to me.
That's why the Usenet technical groups are deliberately, decidely,
agreeably, enforcably non-commercial. We all know that we're leaning
on other people here to carry our message, at their choice, at no cost
to us.
So if we're in it to make a buck, we've just called them collect. You
expect people to respect you after that? <sigh>
Just another old time Usenetter (since 1980 when it all started, and
on whose back you are now walking),
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Fri, 12 May 2000 15:56:12 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: BEGIN and use
Message-Id: <MPG.13862be914ddcad998aa6a@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <8fhr16$oea$1@charm.magnus.acs.ohio-state.edu> on 12 May 2000
20:53:58 GMT, Ilya Zakharevich <ilya@math.ohio-state.edu> says...
+ [A complimentary Cc of this posting was sent to Larry Rosler
+ <lr@hpl.hp.com>],
+ who wrote in article <MPG.1385feb594c7876898aa67@nntp.hpl.hp.com>:
+ > > > Well, as we now know, a semicolon is a statement separator, not
+ > > > a statement terminator. So there is a null statement after the
+ > > > second semicolon and before the closing brace.
+ > >
+ > > I do not think this approach is entirely laudable. Observe:
+ > >
+ > > perl -wle 'sub a { 23 ; } print a'
+ > > 23
+ > >
+ > > With your approach a() would return an empty list. ;-)
+ >
+ > Well, if you generalize this to:
+ >
+ > perl -wle 'sub a { 23 ; ; ; ; ; } print a'
+ > 23
+
+ Good catch.
+
+ > In perlsub, we find "The return value of a subroutine is the value
+ > of the last expression evaluated." A null statement seems to have
+ > *no* expression to evaluate, not a *null* expression, which would
+ > evaluate to "" or () depending on context.
+
+ But if you take this at the face value, then
+
+ sub a {}
+
+ would "return nothing", but it returns an empty list (or undef)
+ instead. ;-)
Well, that is, obviously, identical to:
sub a { return }
or anything else like it, even with conditional return:
sub a { return; "Not reached" }
So then perlsub should read:
"The value returned by a subroutine on reaching the end of the defining
block is the value of the last expression evaluated, if any; the value
returned by a subroutine on executing a 'return' is the value of the
following expression, if any. In either case, if no expression has been
evaluated, the value returned is undef or () depending on context."
Is this worth a documentation patch?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 12 May 2000 18:37:08 -0400
From: "Steve Protopapas" <steve@corp.airmedia.com>
Subject: Re: CHECKING FORM DATA FOR NUMERIC DATA
Message-Id: <8fi0k1$b6e$1@nnrp03.primenet.com>
"Ilmari Karonen" <iltzu@sci.invalid> wrote in message
news:957723706.27411@itz.pp.sci.fi...
> In article <8evbso$ob6$1@nnrp1.deja.com>, linux4all@yahoo.com wrote:
> >With Perl, how can I check a string from a form submission to make sure
> >that the string contains *only* digits and zero or one period (decimal
> >point). I tried using the following, but it doesn't seem to work quite
> >right:
> >
> >if ($present_value !~ /\d*\.?\d*/)
>
> Others have already pointed you to a FAQ entry about what you _want_
> to do, so I'll just mention how to do what you're _trying_ to do.
>
> unless ($present_value =~ /^\d*\.?\d*$/)
>
> The ^ and $ anchor the match. Type "perldoc perlre" at your shell
> prompt for more information.
I think that is still incomplete because '.' matches the pattern.
Steve
------------------------------
Date: Fri, 12 May 2000 16:23:27 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: CHECKING FORM DATA FOR NUMERIC DATA
Message-Id: <MPG.138632459d39471498aa6e@nntp.hpl.hp.com>
In article <8fi0k1$b6e$1@nnrp03.primenet.com> on Fri, 12 May 2000
18:37:08 -0400, Steve Protopapas <steve@corp.airmedia.com> says...
> "Ilmari Karonen" <iltzu@sci.invalid> wrote in message
> news:957723706.27411@itz.pp.sci.fi...
> > In article <8evbso$ob6$1@nnrp1.deja.com>, linux4all@yahoo.com wrote:
> > >With Perl, how can I check a string from a form submission to make sure
> > >that the string contains *only* digits and zero or one period (decimal
> > >point). I tried using the following, but it doesn't seem to work quite
> > >right:
> > >
> > >if ($present_value !~ /\d*\.?\d*/)
> >
> > Others have already pointed you to a FAQ entry about what you _want_
> > to do, so I'll just mention how to do what you're _trying_ to do.
> >
> > unless ($present_value =~ /^\d*\.?\d*$/)
> >
> > The ^ and $ anchor the match. Type "perldoc perlre" at your shell
> > prompt for more information.
>
> I think that is still incomplete because '.' matches the pattern.
What is wrong with the regex in the FAQ, adjusted for unsigned numbers
only:
if (/^(?:\d+(?:\.\d*)?|\.\d+)$/) { print "is a decimal number" }
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 12 May 2000 21:50:45 GMT
From: kherron@sgum.mci.com (Kenneth Herron)
Subject: Re: Checking if Child Process is still Alive
Message-Id: <8fhubl0dsb@enews4.newsguy.com>
Disclaimer: all of my experience is on unix.
It's valid to send signals to zombie processes. It doesn't do anything
to them, but the OS won't treat the attempt as an error just because the
process is dead. So kill(0,...) won't tell you that the process you're
signaling is a zombie.
Aside from waitpid() that someone else noted, there are two things you
can do to get rid of the child without blocking:
1) Install a signal handler for SIGCHLD. Your process will receive a
SIGCHLD every time one of its children exit. Don't call wait() until
you've received a SIGCHLD:
my($sigchld);
sub sigchld { $sigchld = 1; }
$SIG{'CHLD'} = \&sigchld;
...
$sigchld = 0;
do_something_that_forks;
seti_at_home until ($sigchld);
wait();
2) Explicitly ignore SIGCHLD. Your dead children will disappear on their
own without you wait()ing on them:
$SIG{'CHLD'} = 'IGNORE';
Of course this way you can't track your children; maybe that's okay
and maybe it isn't.
Disclaimer: Ignoring sigchld has worked on every system I've tried it
on, but I've only seen it documented once; I'm not sure what if any
standard requires this behavior.
--
Kenneth Herron -- kherron@sgum.mci.com
"Netscape pollution must be eradicated."
-- Jeff Raikes, Vice president, Microsoft
------------------------------
Date: 12 May 2000 22:46:03 GMT
From: abigail@foad.org (Abigail)
Subject: Re: directory contents showing up ?!?
Message-Id: <slrn8hp2db.bgd.abigail@ucan.foad.org>
On Fri, 12 May 2000 21:43:55 GMT, Daniel van den Oord <danielxx@bart.nl> wrote:
++ Wel actually haven't started yet because I don't know yet hoe to start.. I
++ had not time the last few days to look into the perlhelpfile included with
++ active perl.. So I think I'm gona do that somewhere in the next 2 days...
++ But anybody who knows how to start especially how to let CGI read the
++ filenames and display them into a list and I can go from there... (Why think
++ of something that has allready been made right ?!?)
Perhaps you start with learning Perl then.
And don't post in Jeopardy style.
Abigail
------------------------------
Date: 13 May 2000 00:10:59 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: directory contents showing up ?!?
Message-Id: <slrn8hp7ci.pq.efflandt@efflandt.xnet.com>
On Fri, 12 May 2000 21:43:55 GMT, Daniel van den Oord <danielxx@bart.nl> wrote:
>Wel actually haven't started yet because I don't know yet hoe to start.. I
>had not time the last few days to look into the perlhelpfile included with
>active perl.. So I think I'm gona do that somewhere in the next 2 days...
>But anybody who knows how to start especially how to let CGI read the
>filenames and display them into a list and I can go from there... (Why think
>of something that has allready been made right ?!?)
>
>Daniel
For a starting point tack a pub/ onto one of the last two URL's in my sig
and look for dirindex.txt. A copy of that script (renamed index.cgi with
that added to the DirectoryIndex list) is used to create an ftp like file
list with links to the files, like the webserver would if that feature was
not disabled at those sites. It is up to you to modify it to your
liking.
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/ http://cgi-help.virtualave.net/
------------------------------
Date: Sat, 13 May 2000 00:46:23 +0200
From: "Fabien Quesnel" <fabien@fabien.com>
Subject: Formulaire et fichier attache
Message-Id: <8fi1c7$15p$1@news2.isdnet.net>
Voila mon problème :
J'ai besoin d'offrir à mes visiteurs la possibilité d'envoyer par mail leur
CV en .doc.
J'ai un champ Input="FILE" dans mon formulaire. Je fait "parcourir," je
choisi mon fichier, j'obtient donc (par ex) :
c:\mesdocs\toto.doc dans le champ du formulaire.
Or, à la réception de mon mail, j'obtient cette ligne, mais pas le fichier
attaché !
J'ai essayé des tas de scripts PERL, mais aucun ne prend en compte ce type
de champ si particulier !! Pourtant, les formulaires des services Yahoo ou
Hotmail par ex, permettent d'envoyer des fichiers attachés par mail !! Alors
?
Cela fait 2 jours que je cherche, PLEAAAASSSEEE !!!!
------------------------------
Date: Fri, 12 May 2000 15:57:23 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Formulaire et fichier attache
Message-Id: <391C8C53.AEFD67CF@vpservices.com>
Fabien Quesnel wrote:
>
> Voila mon problème :
> J'ai besoin d'offrir à mes visiteurs la possibilité d'envoyer par mail leur
> CV en .doc.
>
> J'ai un champ Input="FILE" dans mon formulaire. Je fait "parcourir," je
> choisi mon fichier, j'obtient donc (par ex) :
> c:\mesdocs\toto.doc dans le champ du formulaire.
>
> Or, à la réception de mon mail, j'obtient cette ligne, mais pas le fichier
> attaché !
>
> J'ai essayé des tas de scripts PERL, mais aucun ne prend en compte ce type
> de champ si particulier !! Pourtant, les formulaires des services Yahoo ou
> Hotmail par ex, permettent d'envoyer des fichiers attachés par mail !! Alors
> ?
>
> Cela fait 2 jours que je cherche, PLEAAAASSSEEE !!!!
Il faut utilizer CGI.pm pour ecririe le formulaire et le champ du type
"FILE" et en suivant pour obtenir les resultats du formulaire au
serveur. En suit il faut utilizer des modules MIME-tools pour attacher
les fichiers au email et des modules Mail-tools pour les envoyer.
--
Jeff
------------------------------
Date: Fri, 12 May 2000 17:37:24 -0500
From: "David Allen" <s2mdalle@titan.vcu.edu>
Subject: Gtk and Pixmaps
Message-Id: <8fi16i$92g$1@bob.news.rcn.net>
Hello,
I'm looking for some sample code for using pixmaps (just generic XPM images)
in perl code using the Gtk module. I wrote something like this:
sub xpm_to_widget {
my($filename, $win) = @_;
$win->realize();
my($gdk_pixmap, $gdk_mask) =
Gtk::Gdk::Pixmap->create_from_xpm($win->window(),
$win->style->white(),
$filename);
my $pixmap = Gtk::Pixmap->new($gdk_pixmap, $gdk_mask);
$pixmap->show() if(defined($pixmap) && $pixmap);
return($pixmap);
} # End xpm_to_widget
which I've seen in other code that worked, but here, it bombs.
In particular, $gdk_pixmap and $gdk_mask end up being
undefined after calling create_from_xpm.
There is another way to call create_from_xpm as a method
hanging off of an object, but it requires you to know the
height, width, and bit depth of the image, which would be a
royal pain in the ass.
All I'm looking for is a function that takes a filename as an
argument, (with possibly its parent window if needed) and
returns a GtkWidget representation of that pixmap which can
be packed into boxes, etc.
Any help would be appreciated.
--
David Allen
http://opop.nols.com/
----------------------------------------
Firearms are second only to the Constitution in importance; they are the
peoples' liberty's teeth.
-- George Washington
------------------------------
Date: Fri, 12 May 2000 15:26:44 -0700
From: John Purnell <InBasket@splendent.com>
Subject: Re: Guess what? the largest online book store Amazon.com
Message-Id: <391C8524.57B7E233@splendent.com>
Gee Steve! these days, the net IS my local community. :-)
Steve wrote:
>
> Get off your fat arse and walk to a real book shop, it's a much
> better experience than ordering on line and it supports your local
> community.
>
> --
> Cheers
> Steve email mailto:sjlen@ndirect.co.uk
>
------------------------------
Date: Fri, 12 May 2000 17:32:30 -0500
From: "David Allen" <s2mdalle@titan.vcu.edu>
Subject: Re: Is this new language possible in perl?
Message-Id: <8fi0tc$7qc$1@bob.news.rcn.net>
> Yes. Perl is Turing complete.
Heh. Quite a long time ago, I wrote a small turing machine program
in perl to take "tape" files and instruction sets in and execute them
just like a turing machine does.
It's at http://opop.nols.com/proggie/turing_machine.pl - there's an
instructions file at http://opop.nols.com/proggie/instructions.anbncn
and a tape file at http://opop.nols.com/proggie/tape.anbncn The problem
it's simulating is seeing whether or not a given string is accepted in
the language
a^n b^n c^n
with an input tape of
... lambda lambda lambda a a a a b b b b c c c c lambda lambda lambda ...
--
David Allen
http://opop.nols.com/
----------------------------------------
Firearms are second only to the Constitution in importance; they are the
peoples' liberty's teeth.
-- George Washington
------------------------------
Date: Fri, 12 May 2000 23:42:09 +0100
From: "Andy Chantrill" <andy@u2me3.com>
Subject: Re: Iteration
Message-Id: <8fi1g2$e0f$1@plutonium.btinternet.com>
Hey,
Yeah - but it's a HoL ... so that won't work, because the value is an array,
and for some reason I can't get it 'werkin right:
--
${$hash{'one'}}[0] = 'first';
${$hash{'one'}}[1] = 'second';
${$hash{'two'}}[0] = 'first';
${$hash{'two'}}[1] = 'second';
while (my ($key, @val) = each %hash) {
$val = join("\t", @val);
print "$key\t$val\n";
}
--
Thanks, Andy.
andy@u2me3.com
------------------------------
Date: Fri, 12 May 2000 17:54:20 -0500
From: "Andrew N. McGuire" <andrew.mcguire@walgreens.com>
Subject: Re: Iteration
Message-Id: <391C8B9C.9E426D08@walgreens.com>
Andy Chantrill wrote:
>
> Hey,
>
> Yeah - but it's a HoL ... so that won't work, because the value is an array,
> and for some reason I can't get it 'werkin right:
>
> --
> ${$hash{'one'}}[0] = 'first';
> ${$hash{'one'}}[1] = 'second';
> ${$hash{'two'}}[0] = 'first';
> ${$hash{'two'}}[1] = 'second';
>
> while (my ($key, @val) = each %hash) {
> $val = join("\t", @val);
> print "$key\t$val\n";
> }
> --
Did you read my previous reply? Is that what you want?
If it is, then:
#!/usr/bin/perl -w
use strict;
my %hash;
${$hash{'one'}}[0] = 'first';
${$hash{'one'}}[1] = 'second';
${$hash{'two'}}[0] = 'first';
${$hash{'two'}}[1] = 'second';
# Print first element of each list.
print $hash{$_}->[0] for sort keys %hash;
# Print entire list.
print @{$hash{$_}} for sort keys %hash;
__END__
Should do what you want..
Cheers,
anm
--
Andrew N. McGuire
andrew.mcguire@walgreens.com
------------------------------
Date: Fri, 12 May 2000 16:01:04 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Iteration
Message-Id: <MPG.13862d08668caade98aa6b@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <8fi1g2$e0f$1@plutonium.btinternet.com> on Fri, 12 May 2000
23:42:09 +0100, Andy Chantrill <andy@u2me3.com> says...
> Yeah - but it's a HoL ... so that won't work, because the value is an array,
> and for some reason I can't get it 'werkin right:
No, the value isn't an array. It is a reference to an array, which is a
scalar. (All hash values are scalaers.)
> --
> ${$hash{'one'}}[0] = 'first';
> ${$hash{'one'}}[1] = 'second';
> ${$hash{'two'}}[0] = 'first';
> ${$hash{'two'}}[1] = 'second';
>
> while (my ($key, @val) = each %hash) {
> $val = join("\t", @val);
> print "$key\t$val\n";
> }
while (my ($key, $val) = each %hash) {
$val = join("\t", @$val);
print "$key\t$val\n";
}
Or, equivalently but smoothly:
{ local $" = "\t";
while (my ($key, $val) = each %hash) {
print "$key\t@$val\n";
} }
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 12 May 2000 18:10:23 -0500
From: "Andrew N. McGuire" <andrew.mcguire@walgreens.com>
Subject: Re: Iteration
Message-Id: <391C8F5F.9C75F122@walgreens.com>
Andy Chantrill wrote:
>
> Hey,
>
> Yeah - but it's a HoL ... so that won't work, because the value is an array,
> and for some reason I can't get it 'werkin right:
>
> --
> ${$hash{'one'}}[0] = 'first';
> ${$hash{'one'}}[1] = 'second';
> ${$hash{'two'}}[0] = 'first';
> ${$hash{'two'}}[1] = 'second';
>
> while (my ($key, @val) = each %hash) {
> $val = join("\t", @val);
> print "$key\t$val\n";
> }
Here is a method using while:
while (my ($key, $val) = each %hash) {
$val = join("\t", @{$val});
print "$key\t$val\n";
}
Sorry about the multiple postings, I should have included
this in my last message. I think this is actually what
you are looking for, after more carefully reviewing your post.
Still give 'perldoc perldsc' another look-over.
Cheers,
anm
--
Andrew N. McGuire
andrew.mcguire@walgreens.com
------------------------------
Date: Fri, 12 May 2000 21:58:35 GMT
From: mozarty@my-deja.com
Subject: NT ORACLE PERL DBD DBI->connect format
Message-Id: <8fhuq4$u52$1@nnrp1.deja.com>
Hi,
I installed Perl 5.6.0 and DBI on my NT 4.0 Sevice pack 5
With DBD::ODBC it works fine with ORACLE 8i 8.1.5 databse
Then I installed DBD::Oracle and I have problem trying to connect
database
I tried two formats:
my $dbh = DBI->connect('DBI:Oracle:host=$dbserver ,sid=$dbname', $user,
$pass, 'Oracle');
and
$dbh = DBI->connect
('dbi:Oracle:G21DEV', 'USERNAME', 'PASSWORD', 'Oracle')
I have error message:
Database connection not made: ORA-00000: normal, successful completion
(DBD: log
in failed, check ORACLE_HOME/bin is on your PATH) at test5.pl line 36.
On my NT ORACLE_HOME\bin is on PATH
For my $dbh = DBI->connect('DBI:Oracle:host=$dbserver ,sid=$dbname',
$user, $pass, 'Oracle');
I am not sure what means $dbname in for 8.1.5.
Is it connect string ? Or SERVICE_NAME ? Or database name ?
In $dbserver I used the name of my computer in LAN
For $dbh = DBI->connect
('dbi:Oracle:G21DEV', 'USERNAME', 'PASSWORD', 'Oracle')
I am not sure what is G21DEV for 8.1.5.
Is it connect string ? Or SERVICE_NAME ? Or database name ?
I’d appreciate any help
Yakov
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 13 May 2000 01:07:05 +0000
From: Pierre Rodrigues <pirod@webdifusao.com>
Subject: pass data from WML to perl
Message-Id: <391CAAB9.CA32C21@webdifusao.com>
Hi,
I am trying to pass data from a form in WML (for a WAP application) to a
perl script. But it does not seem to work as in HTML...
I wrote:
<do type="accept" label="Do!">
<go method="post" href="http://$scripturl">
<postfield name="ALIAS" value="$ALIAS"/>
<postfield name="PASSWORD" value="$PASSWORD"/>
</go>
</do>
<p>
<br/>
Licitação pretendida:
<br/>
<input title="First Name" size="10" name="ALIAS"/>
<input title="Last Name" size="10" name="PASSWORD"/>
</p>
.....
But the script does not recover the passed data after classic perl
commands like:
$ALIAS=$q->param("ALIAS");
Can anyone help me?
thanks
Pierre
------------------------------
Date: Fri, 12 May 2000 17:17:42 -0500
From: "David Allen" <s2mdalle@titan.vcu.edu>
Subject: Re: Perl question
Message-Id: <8fi01k$347$1@bob.news.rcn.net>
> Line 4: my($j) = 0; Line 5: while($j <= $#data){ $s .= @data[$j++]." ";
There's your problem.
If you have an array @foobar and you want to get at the 6th
element, (or in your case, the jth element) the syntax is:
$foobar[$j] NOT @foobar[$j]
--
David Allen
http://opop.nols.com/
----------------------------------------
Firearms are second only to the Constitution in importance; they are the
peoples' liberty's teeth.
-- George Washington
------------------------------
Date: Fri, 12 May 2000 15:35:21 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Perl question
Message-Id: <MPG.1386270613a132cf98aa68@nntp.hpl.hp.com>
In article <7au2g37gaw.fsf@Merlin.i-did-not-set--mail-host-address--so-
shoot-me> on Fri, 12 May 2000 18:51:33 GMT, Ala Qumsieh
<aqumsieh@hyperchip.com> says...
>
> Haifeng <chj005@email.mot.com> writes:
>
...
> > Line 4: my($j) = 0;
> > Line 5: while($j <= $#data){ $s .= @data[$j++]." "; }
>
> You are assigning an array to a scalar.
Nope. It is assigning an array slice, which is a list, not an array.
> Anything that starts with a '$'
> is a scalar. Period.
Yep.
> Anything that starts with a '@' is an
> array. Period.
Nope. This is an array slice, which is a list, not an array.
> An array in scalar context returns the number of elements
> in the array.
Yep. But this returns the value of the last element in the list.
> You should change the above to:
>
> while ($j <= $#data) { $s .= $data[$j++] . " " }
Yep. Or use join, as suggested elsewhere.
> checkout perlfaq4:
>
> What is the difference between $array[1] and @array[1]?
Yep.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 12 May 2000 17:42:00 -0500
From: "Andrew N. McGuire" <andrew.mcguire@walgreens.com>
Subject: Re: Perl question
Message-Id: <391C88B8.874CBAF1@walgreens.com>
[ posted and mailed ]
Haifeng wrote:
>
> Hi there,
>
> I am new to Perl language and have the following question. I'd
> appreciate if anyone could help me.
>
> I am reading from a file, setting the contents in a structure and
> calling a function with the structure as parameter. Here's the code:
> Line 1: open(FH, "/usr/users/haifeng/f1.txt");
You probably want to use some diagnostics here:
open FH, '/usr/users/haifeng/f1.txt'
or die "Can't open /usr/users/haifeng/f1.txt: $!.\n";
is an example. You may also want to run under '-w' and
'use strict;'.
> Line 2: @data = <FH>;
> Line 3: close(FH);
>
> Line 4: my($j) = 0;
If you are not my()'ing a list, you can leave off the
parens, they are uncessary.
my $j = 0;
> Line 5: while($j <= $#data){ $s .= @data[$j++]." "; }
my $s;
$s .= "$_ " for @data; # An easier way.
would do the trick, if I understand correctly.
So would:
my $s = "@data "; # The easiest way.
I don't think the white space on the end is necessary, so
you could omit it. Then again I could be wrong.
> Line 6: print (s);
This is supposed to be 'print $s;' I think.
[ snip ]
Cheers,
anm
--
Andrew N. McGuire
andrew.mcguire@walgreens.com
------------------------------
Date: 12 May 2000 23:39:46 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Randomised function
Message-Id: <slrn8hp5i1.bgd.abigail@ucan.foad.org>
On Fri, 12 May 2000 15:18:54 +0100, Mike Moose <mike_moose@yahoo.com> wrote:
++ Hi, I'm trying to write a perl function which will generate a random
++ password of 8 character, numbers/characters ... in C there is rand()
++ which generates a random number synched with the time, is there a
++ function similar to this in Perl...
Yeah, but the name of that function is a strictly kept secret, one you
cannot even find in the manual, let alone guess!
Abigail
------------------------------
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 3033
**************************************