[8742] in Perl-Users-Digest
Perl-Users Digest, Issue: 2359 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Apr 18 12:07:14 1998
Date: Sat, 18 Apr 98 09:00:25 -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 Sat, 18 Apr 1998 Volume: 8 Number: 2359
Today's topics:
Re: Array / List question <jdf@pobox.com>
Re: Array / List question <jdporter@min.net>
Re: cgi using perl <sowmaster@juicepigs.com>
Re: DATA filehandle (Jonathan Stowe)
Re: Excel via cgi (Jonathan Stowe)
Re: Fork in perl/NT ? (Jonathan Stowe)
Re: how to remove blanks? (Mike Heins)
Re: How to skip HTML codes? (Jonathan Stowe)
Re: Implementation of map. <merlyn@stonehenge.com>
Re: Informix (Jonathan Stowe)
Re: IS THERE SUCH A THING AS MULTI TASKING? (Jonathan Stowe)
Re: Neutering exit in eval (Mark-Jason Dominus)
Re: order of declaration - my, local, anonymous sub (M.J.T. Guy)
Re: Perl, MySQL on my home PC (Jonathan Stowe)
Re: Perl/Tcl (Jonathan Stowe)
Re: perl_eval_pv: how to catch errors? (M.J.T. Guy)
Re: Question? (Jeff Workman)
Re: recursive fuctions (M.J.T. Guy)
Re: recursive fuctions (Andrew M. Langmead)
Re: Retrieve HTML FORM POST info within CGI Perl Progra <merlyn@stonehenge.com>
Re: Retrieve HTML FORM POST info within CGI Perl Progra (Jonathan Stowe)
Re: unpacking multiple binary shorts (WORDS) (Bbirthisel)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 18 Apr 1998 10:44:43 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Array / List question
Message-Id: <ra2v6sno.fsf@mailhost.panix.com>
"A.P." <road@apdo.com> writes:
> Anyway it was a bit silly, I should have written @j=@i**2 for the sake of
> clearity.
No! If you want to store the square of the size of an array, and
you're seeking clarity,
$j = scalar @i ** 2;
Notice $j and not @j. It's a scalar value, so put it into a scalar
variable. Notice also the programmer-friendly use of the "scalar"
operator, which makes explicit your intention to refer to the size of
the array.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Sat, 18 Apr 1998 14:42:56 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Array / List question
Message-Id: <3538BD4C.1B60@min.net>
A.P. wrote:
>
> I really didn't see a difference between an array an a
> list. Now I can see they are different. Anyway, I've been scanning through
> the documentation and I've been unable to find a reference to the behaviour
> of a list in an scalar context.
You mean besides "there is no general rule for converting a list to
a scalar", which is probably the most repeated phrase is clpm besides
"there's more than one way to do it"?
Always remember that what sometimes looks like a list is not a list,
if the context is scalar. You know that in this expression:
$n = ( 4, 5, 6 );
this is not a list, but a C-style comma operator. It evaluates to
the value of the expression after the last comma.
Other operators which return lists in a list context are also defined
to return the "last value" in a scalar context.
This includes array slices.
> I knew I was doing some silly questions, obviously I knew that
>
> @j=@i[@i]**2; #really the same IN THIS CASE as @j=@i**2
But they're NOT the same.
@i is an array variable, and in a scalar context (as in @i**2), it
evaluates to the number of elements.
@i[@i] is an array slice; it is defined to return its last value
in a scalar context. And as I said before, if any element of
@i are not in the range (0..$#i), then you'll get undef values in
the result. But you knew that.
Note also that because of the scalar nature of the exponentiation
operator, @j can only ever get one element. Using an array variable
to receive the result only adds confusion.
> wouldn't square all the elements of the array, it was just an example.
> Anyway it was a bit silly, I should have written @j=@i**2 for the sake of
> clearity.
I don't mean to be a downer, but you're still a little cloudy on
this subject.
The exponentiation operator provides a SCALAR context to its left
operand. @i in a scalar context gives the number of elements in
the array. You're going to square the number of elements in the
array?
This is what you should have said:
@j = map { $_ ** 2 } @i;
hth,
John Porter
------------------------------
Date: Sat, 18 Apr 1998 11:45:05 -0400
From: Bob Trieger <sowmaster@juicepigs.com>
To: gurun@acc.umu.se
Subject: Re: cgi using perl
Message-Id: <3538CA81.4AA9@juicepigs.com>
N i c l a s O l o f s s o n wrote:
>
> Abigail wrote:
> > There's no Perl specific aspect in your question.
> [snip]
> > Ask in the CGI group. Or better, read the FAQ.
>
> Perl FAQ really got to be something. Every answer beginning with "no
> Perl specific" seem to refer to the FAQ. I'll bet it's a very fine FAQ,
> since it seem to answer all Q possible, Perl specific or not. Maybe
> that's why you never tell people where it is?
Is this an admission that you haven't read the FAQ? When you first post
here a minifaq with the details is mailed to you with plenty of info on
where to locate perl resources. If you ignored it, then that is your
problem.
The perlfaqs actually make good reading if you want to learn. But I can
see where they would be a waste of time if you want to be hand fed.
> > I'm pretty sure your question is answered there.
>
> "Pretty sure"? Don't you know? RTFM until you know then ;)
Why should she do your leg work? You gonna pay?
--
Bob Trieger | Titanic: big boat, bigger
sowmaster@juicepigs.com | iceberg, big deal
------------------------------
Date: Thu, 16 Apr 1998 20:28:38 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: DATA filehandle
Message-Id: <353665b2.11793605@news.btinternet.com>
On Fri, 17 Apr 1998 17:39:30 -0500, Paul Holser <pholser@nortel.com>
wrote:
>
>-----------------------------
>#!/usr/bin/perl
>
>use Pod::Text;
>use strict;
>
>pod2text( '<&=' . fileno \*DATA );
>#pod2text( '<&DATA' );
>
So whats wrong with :
pod2text($0);
!
perldoc Pod::Text
SYNOPSIS
use Pod::Text;
pod2text("perlfunc.pod");
Just wondered.
/J\
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm
------------------------------
Date: Thu, 16 Apr 1998 20:28:25 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Excel via cgi
Message-Id: <3536412d.2876641@news.btinternet.com>
On Fri, 17 Apr 1998 17:42:27 -0400, Peter Tapolyai <peter###@uhu.com>
wrote:
>I have to query an MS Excel Spreadsheet across the web.
>I have the simplified core of the cgi below. However, this
>query does not return the very first 'records' (or cell values)
Whilst, this might be somewhat of an "Anti-Answer" you might instead
alter your approach to use Win32::OLE instead wherein you can use the
reasonably well documented Excel methods for accessing the data in you
spreadsheet (IE you can specify indicidual cells etc) rather than
having this shrouded beneath the ODBC interface. Of course if you
were using ODBC with a view to switching your data storage method
later then that would be a bad suggestion.
On Mon, 13 Apr 1998 23:36:24 -0400, Pat Kane <Pat_kane@compuserve.com>
wrote:
> Whenever I have used a hash I have put
>the key in single quotes. I would therefore make the following change.
> print " <li>", $in{'F1'}, " ", $in{'F2'}, "\n";
>
This shouldnt be a problem as hash keys are one of places that
barewords are considered less amibiguous.
/J\
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm
------------------------------
Date: Thu, 16 Apr 1998 20:28:23 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Fork in perl/NT ?
Message-Id: <35363959.1363293@news.btinternet.com>
On 17 Apr 1998 19:27:28 -0500, Jonathan Feinberg <jdf@pobox.com>
wrote:
>Gellyfish@btinternet.com (Jonathan Stowe) writes:
>
>> As I understand it the standard distribution when compiled with
>> cygwin32 does have have a fork() that is implemented by some chicanery
>> with white chickens, black candles etc by the cygnus library.
>
>Do you remember those inexplicable stabbing pains a few nights back?
>That was me, running a fork-heavy perl script in cygwin-land.
>
And I thought it was all to do with the surfeit of coffee...
(Hmm TV footage of Pol Pot's cremation on right now - I feel a game
coming on.)
/J\
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm
------------------------------
Date: 18 Apr 98 14:28:35 GMT
From: mikeh@minivend.com (Mike Heins)
Subject: Re: how to remove blanks?
Message-Id: <3538b893.0@news.one.net>
Zenin <zenin@archive.rhps.org> wrote:
> [ posted & mailed ]
> Mike Heins <mikeh@minivend.com> wrote:
> : I think we should care, for your test code does nothing except create a
> : subroutine reference thousands of times,
> You'll *really* need to explain what you meen, as my test code
> does no such thing that I can see. If you refer to the use of
> code refs instead of code strings, this is both a supported
> and clearly documented feature of the Benchmark interface.
> If you refer to anything else, please explain.
> : and one has a syntax error.
> Ah yes, so it does at that. However, do you know that you made the
> exact *same* syntax error in *your* test code?!? I wouldn't normally
> jump on anyone that hard for such an error as it's an easy typo to
> make, however when you call someone on an error and then within the same
> message commit the exact same error...well, you get the idea. :-)
> You use code strings, I use code references. No meaningful difference.
> Actually, if you check Benchmark::runloop() you'll see that the only
> difference is that code refs have one extra stack layer as they need
> to be called. I'd call this a bug myself, as it would be trivial to
> make code strings perform exactly the same, but it really would only
> make a difference if the tests where mixed with some string, some
> code ref, which neither of our code does.
> I'm still looking for that repeated sub ref you mentioned...
My lack of understanding of the Benchmark module working here.
> : $foo = ' foo ';
> : $foo =~ s/(?:^\s+|\+$)//g;
> /|\
> |
> I'm not the only one with syntax errors! :-)
Actually I was just clipping and pasting yours. 8-)
As it turns out, the difference in time in my runs ended up being the
amount of time necessary to handle the syntax error. I missed the repeated
syntax error and also the ?:, which I know does exactly what you say.
In any case, though my analysis was hasty, the first benchmark as posted
was meaningless. The second one posted by me was as well, though not
toward my main point -- trimming whitespace with one regex is not
necessary nor desirable.
--
Mike Heins http://www.minivend.com/ ___
Internet Robotics |_ _|____
Just because something is 131 Willow Lane, Floor 2 | || _ \
obviously happening doesn't Oxford, OH 45056 | || |_) |
mean something obvious is <mikeh@minivend.com> |___| _ <
happening. --Larry Wall 513.523.7621 FAX 7501 |_| \_\
------------------------------
Date: Thu, 16 Apr 1998 20:28:34 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: How to skip HTML codes?
Message-Id: <35365ac1.9092394@news.btinternet.com>
On Sat, 18 Apr 1998 19:20:36 +1000, "Noel Sampol"
<noels@chilli.net.au> wrote:
>Hi, I'm trying to write a CGI script that basically ignores and skips past
>HTML code - anything and including between < > like <p align=center>.
>
Slightly altered from perlfaq9 (you did check the FAQ didnt you?:
s/(?:<[^>'"]*|".*?"|'.*?')+>//gs;
Will
...
>
>...and, I want to only display "This is only a test file" and "Entry
>Code=ENTRY01". That is, any non-HTML code between <!--ENTRY BEGIN--> and
><!--ENTRY END--> . How would I display it?
However to do *this* you will probably want to do something a little
more fancy with HTML::Parser (Hmm second time today I've recommended
this) How precisely is left as an exercise ...
/J\
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm
------------------------------
Date: Sat, 18 Apr 1998 14:05:00 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
To: Richard Webber <richard@cs.newcastle.edu.au>
Subject: Re: Implementation of map.
Message-Id: <8cbttzb508.fsf@gadget.cscaper.com>
>>>>> "Richard" == Richard Webber <richard@cs.newcastle.edu.au> writes:
Richard> Does the builtin map function guarantee that it will process
Richard> each element of a list in order (actually process, not just output)?
Richard> This is important if you want the block passed to map to have
Richard> side-effects.
Yes. It's guaranteed. Or at least, even if it isn't, there are so
many programs now that presume it that changing that would break
everything. This works:
$n = 0; %foo = map { $n++, $_ } @list;
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 136 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Thu, 16 Apr 1998 20:28:29 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Informix
Message-Id: <35364837.4677522@news.btinternet.com>
On Fri, 17 Apr 1998 17:31:43 -0700, Indu Bingham <indu@healtheon.com>
wrote:
>I need to build a web interface with infromix backend using perl.
That takes me back a few years ;-{
There is a DBD::Informix module at
http://www.perl.com/CPAN-local/modules/by-module/DBD/
However you will need to have Informix ESQL/C to install this.
If you only have the SQL development tools (isql/ACE/PERFORM etc) you
are not completely lost however because you can run the external tools
from within a perl program, for instance using IPC::Open2 e.g:
#!/usr/bin/perl -w
use IPC::Open2;
use Symbol;
$QUERY = gensym(); # create typeglobs
$RESPONSE = gensym();
$pid = open2($RESPONSE,$QUERY,"isql <your database> -");
if($pid)
{
# This of course could be any SQL
$the_query = "SELECT * FROM <some table>;\n";
print $QUERY $the_query;
close($QUERY);
while(<$RESPONSE>)
{
# Do something with results of query
print;
}
close($RESPONSE);
}
else
{
die "couldnt open pipe to sql" ;
}
__END__
There are other alternatives if you have a fairly static query with
some parameters. You could build an ACE report which writes to STDOUT
and then run that from perl and so on like :
$command = "sacego report " . $param1 . " " . $param2 ; #etc
open(REPORT,"$command |") || die "Cant run report",$!;
while(<REPORT>)
{
#do sume stuff
print ;
}
close(REPORT);
There are a number of little tricks you can do within your Informix
query to make the output more Perl friendly but that is Informix and
not Perl innit.
You might have noticed that I have skipped over the "Web Interface"
aspects of this question. There is a vast wealth of documentation
available on using perl with CGI, some of which is available at :
http://www.perl.com/
Hope that is some help
/J\
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm
------------------------------
Date: Thu, 16 Apr 1998 20:28:40 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: IS THERE SUCH A THING AS MULTI TASKING?
Message-Id: <35366709.12130515@news.btinternet.com>
On Fri, 17 Apr 1998 17:56:43 -0700, "K. Watson" <cwts@earthlink.net>
wrote:
>I'd like to be able to display a "PLEASE WAIT" screen while an independent
>(credit card authorization) process is going on. In MVS assembler, I'd call
>it multi-tasking. Is there a PERL equivalent?
>
I think fork() (at least on supporting platforms) is what you are
looking for to some extent ; synchronization is left as an exercise.
This reference to MVS assembler worries me: odds on the first "I have
an RPG-III program running under system 39 emulation on AS/400 that I
need to convert to Perl ... " anyone ?.
Any how off to the pub with me.
/J\
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm
------------------------------
Date: 18 Apr 1998 11:02:02 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Neutering exit in eval
Message-Id: <6haf9a$4ub$1@monet.op.net>
Keywords: corporate defray Hopkinsian Valparaiso
In article <6h8vba$57j@fcnews.fc.hp.com>,
Jack Applin <neutron@fc.hp.com> wrote:
>I can use $SIG{__DIE__} to intercept the user code if it does a die.
>What can I do if it does an exit?
1. Real answer: Look into the `Safe' package.
2. Hack answer: Redefine the exit function:
use subs 'exit';
sub exit { "Don't do that!" }
#2 is a hack answer because it still doesn't prevent the user code
from doing syscall(&SYS_exit) or kill 6 => $$; or anything else like
that.
I think there was a third answer, but I forgot what it was while I was
writing the second answer.
------------------------------
Date: 18 Apr 1998 13:57:30 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: order of declaration - my, local, anonymous sub
Message-Id: <6habga$4ta$1@lyra.csx.cam.ac.uk>
Phil R Lawrence <prl2@lehigh.edu> wrote:
>
>Specifically, the 2nd doesn't executes the disconnect method, and thus some
>errors are written to the console as I dump out of the program. Why does
>the order of declaration matter? I should think the 'no strict' would
>eliminate that need.
Others have explained why the order of declaration affects your program.
But why did you expect that "no strict;" would have any effect on the
semantics? All strict does is forbid certain constructions which are
regarded as "dangerous". It never changes the meaning of anything.
And your program contains no such construct anyway (well done!).
Mike Guy
------------------------------
Date: Thu, 16 Apr 1998 20:28:35 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Perl, MySQL on my home PC
Message-Id: <3536643a.11517333@news.btinternet.com>
On Sat, 18 Apr 1998 01:35:01 -0500, darren vollmer
<inept@mail.anet-stl.com> wrote:
>Ill try not to sound like a bonified moron:
>
Do you mean bona fide or is this a synonym for ossified :-)?
<snip>
>What download of Perl should I get? Theres a quite a list of files. Do
1) http://www.perl.com/latest.html
>I need to "build" the perl install with a c compiler? Where can I get a
>compatible c compiler (free). I have a non compatable version boreland
>compiler.
2) The cygwin32 version of gcc is available at http://www.cygnus.com/
>
>If someone out there could take the time to layout in newbie speak how
>to correctly install and make perl, correctly install and make MySQL on
>a win95 laptop/desktop it would be greatly appreciatted. The simplest
>route to install that permits me to use the MySQL module is what I'm
>looking for.
>
3) How to build *perl* with the compiler you got at stage 2 is
documented in the distribution you got at stage 1. But MySQL, well,
that is another matter altogether, after all this is a Perl newsgroup.
For all I know it might compile right away with cygwin32 on the other
hand it might not but that would probably be addressed in the
documentation you would hopefully have with the distribution of MySQL.
(However see :
http://outside.organic.com/mail-archives/mysql/May1997/0205.html
)
>
>I realize that most , if not all, of this information is available on
>the net, but the problem is: There is an overwhelming amount of it. I
However the excellent wealth of documentation that is available for
Perl both as part of the distribution and at www.perl.com is almost
certainly more accurate and reliable and more easily refered to than
any response you might get from this newsgroup on these matters.
>have quite a bit of experience scripting in perl, but never setting it
>up.
>
Look upon this as an opportunity to broaden your skills ;-}
PS You might find more on MySQL at http://mirrors.iquest.net/mysql/
/J\
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm
------------------------------
Date: Thu, 16 Apr 1998 20:28:27 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Perl/Tcl
Message-Id: <3536440e.3613241@news.btinternet.com>
On Fri, 17 Apr 1998 18:01:11 -0400, "LOI N PHAM" <LPHAM@prodigy.net>
wrote:
> I'm trying to call (or learning how to call) Tcl-based libraries in
> Netscape Enterprise Server/Unix environment.
>
Uh oh, heres trouble
>
> 1. If I install Tcl extension module for Perl5, then I can instantiate
> Tcl interpreter as Per5 object, and excute embedded Tcl code. I saw
> Tcl extension for Perl5 is still in beta1 in CPAN, how reliable is this
> beta module? Is there any other Tcl extension for Perl5 available?
>
I have no experience of the module but like all beta releases it will
come with some caveats. But then again there modules out there that
people use everyday which have always been in Beta and possibly always
will - things are in a com#nstant state of improvement.
>
> 2. Alternatively, I can use straight Tcl code to generate HTML pages.
> Pro's and con's against using Tcl extension for Perl5?
>
I see no reason why it shouldnt (Perl does not have the monopoly for
CGI) but the question is better asked in a Tcl group before things
start to get too heretical here.
>
> 3. Is there a "Tcl for Win32" (like "Perl for Win32")?
>
Yes, released by Sun themselves - I think (if my beer injured brain
serves me right) that it can be found at :
http://www.sunscript.com
/J\
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm
------------------------------
Date: 18 Apr 1998 14:37:11 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: perl_eval_pv: how to catch errors?
Message-Id: <6hadqn$66j$1@lyra.csx.cam.ac.uk>
In article <6h8fi1$19$1@nnrp1.dejanews.com>, <igor@everyware.com> wrote:
>Hi,
>
>If I do
>
> SV* result = perl_eval_pv(string, FALSE);
>
>in my embedded interpretor, and string contains:
>
> "use Foo;" (literally)
>
>I can get an error from $@, send it back to user, etc.
>Ditto for any other syntax or run-time gotchas.
>If, however, I try:
>
> "use Socket qw(foo);" (literally)
>
>the BEGIN block gets executed and the error (about foo not being
>imported by Socket.pm) is reported on stderr,
>which, among other things looks quite unprofessional for a daemon,
>while my $@ contains only "Can't continue after import errors..."
>
>So, how I can catch this kind of errors?
You'll need to set up a $SIG{__WARN__} which either converts the warn
to a die, or squirrels away the error string for later checking.
Mike Guy
------------------------------
Date: 18 Apr 1998 14:06:41 GMT
From: mrjeff@blithe.ircbar.com (Jeff Workman)
Subject: Re: Question?
Message-Id: <6hac1h$k2v$1@supernews.com>
Don't you ever have anything constructive to say? Or are you here merely to
belittle those who aren't as 3733+ as you?
Abigail (abigail@fnx.com) wrote:
: Sam P. Kaipa (skaipa@leland.stanford.edu) wrote on MDCLXXXVIII September
: MCMXCIII in <URL: news:35342F1F.6F1093AF@leland.stanford.edu>:
: ++ How do I do a GetLine in perl?
: You use diamonds.
: RTFM.
: Abigail
: --
: perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET", "http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content)) =~ /(.*\))[-\s]+Additional/s) [0]'
------------------------------
Date: 18 Apr 1998 14:48:09 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: recursive fuctions
Message-Id: <6haef9$6g8$1@lyra.csx.cam.ac.uk>
Kevin B Cohen <kcohen@julius.ling.ohio-state.edu> wrote:
>one thing i was surprised (though i guess i shouldn't have been) to
>discover recently is that if you use strict (as you do in the script
>you posted), my'd variables in main are not accessible by subroutines
>called by main, and must be passed to them if you want the subs to
>have their data. makes sense, i guess-- i just expected main to be
>different from a subroutine. guess i was wrong.
Eh? I don't understand that. Could you post an example?
a) The accessibility of my variables is determined solely by
the lexical scoping, which is not changed by "use strict;".
b) "use strict;" should have no effects on the meaning of any program [*].
Its sole effect is to forbid certain constructs which would otherwise
be legal.
[*] unless you diddle with $^H, or otherwise grub in the innards.
Mike Guy
------------------------------
Date: Sat, 18 Apr 1998 15:07:16 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: recursive fuctions
Message-Id: <ErM7C4.85J@world.std.com>
kcohen@julius.ling.ohio-state.edu (Kevin B Cohen) writes:
>one thing i was surprised (though i guess i shouldn't have been) to
>discover recently is that if you use strict (as you do in the script
>you posted), my'd variables in main are not accessible by subroutines
>called by main, and must be passed to them if you want the subs to
>have their data. makes sense, i guess-- i just expected main to be
>different from a subroutine. guess i was wrong.
Thats not quite it either. Variables delclared with my() are visible
from their declaration to the end of their scope. For a my() variable
declared outside of any block, the scope is the entire file. For my()
variable declared inside of a block, the scope is until the end of the
block. (but this includes any inner blocks.)
So variables declared as my() in a file, but outside of any subroutine
(which is what I think you are talking about when you talk about
"main") or block may be visible to a subroutine, as long as the
subroutine is in the same file and the variable is declared before the
subroutine's declaration.
--
Andrew Langmead
------------------------------
Date: Sat, 18 Apr 1998 14:07:28 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
To: Pat_kane@compuserve.com
Subject: Re: Retrieve HTML FORM POST info within CGI Perl Program
Message-Id: <8c7m4nb4w5.fsf@gadget.cscaper.com>
>>>>> "Pat" == Pat Kane <Pat_kane@compuserve.com> writes:
Pat> The world wants to see how you solved this problem. Please share your
Pat> solution with us.
Actually, it sounds pretty straightforward once you've seen "perldoc
lwpcook" from the LWP library, and see how easy it is to submit with
POST. Maybe that's what the additional 10 minutes were for. :-)
Is there some part of LWP you're not quite yet grokking? We'd be
happy to ask specific questions.
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 136 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Thu, 16 Apr 1998 20:28:32 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Retrieve HTML FORM POST info within CGI Perl Program
Message-Id: <35365329.7479356@news.btinternet.com>
On Sat, 18 Apr 1998 02:05:03 -0400, Pat Kane <Pat_kane@compuserve.com>
wrote:
>snay,
>The world wants to see how you solved this problem. Please share your
>solution with us.
>
I though that, but then I was just about to post a suggestion. It
might be fun to guess though.
One might use LWP::UserAgent and LWP::Request to post the query and
retrieve the results into a variable and then HTML::Parser to glean
the relevant parts of the returned HTML. Using HTML::Parser is the
prefered method for doing this kind of stuff because it deals with
many wierd exigencies that may occur in the real world (have you seen
the HTML MS Frontpage emits ;-}). Using the module may look hairy to
the uninitiated because of the need to override its methods for it do
anything useful but once the scales fall from your eyes ......
/J\
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm
------------------------------
Date: 18 Apr 1998 15:09:12 GMT
From: bbirthisel@aol.com (Bbirthisel)
Subject: Re: unpacking multiple binary shorts (WORDS)
Message-Id: <1998041815091200.LAA17136@ladder03.news.aol.com>
Hi Tony:
>Part of the file contains a long(ish) array (>10,000) of 2-byte WORDS
>specifying simple integer values that I need to get into an array.
Ok.
> $byte_count = read (IN, $buffer,$WORD);
> if($byte_count == 2){
> $buffer = hex(unpack("H4", $buffer));
> push (@slurped_data, $buffer);
Is there a good reason (which I don't see in the example) for using "H4"
instead
of "S" (or possibly "v") in the unpack? Since you want simple integers, there
is
no advantage to converting to/from hex first.
>It would be nice to read in the whole length of the array at once and split
>it up into unpacked 2 byte chunks in a single operation. Is this possible?
Should be possible. The following code works for a short string of shorts:
###> ($num1, $num2, $num3, $num4, $num5) = unpack ("S5", $fiveshorts);
I haven't tried the following (but I suspect it would work):
###> @num = unpack ("S5", $fiveshorts);
You would need to insert the real length "S$length".
-bill
------------------------------
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 2359
**************************************