[19265] in Perl-Users-Digest
Perl-Users Digest, Issue: 1460 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 8 03:05:37 2001
Date: Wed, 8 Aug 2001 00:05:09 -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: <997254309-v10-i1460@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 8 Aug 2001 Volume: 10 Number: 1460
Today's topics:
Re: action=stuff? <aether@centurytel.net>
Can't make emacs & cperl-mode & gud work. (David Combs)
Re: Embedded perl question <brentdax1@earthlink.net>
FAQ: How can I use a reference as a hash key? <faq@denver.pm.org>
For loop aliasing?? <miscellaneousemail@yahoo.com>
Re: For loop aliasing?? <brentdax1@earthlink.net>
Re: For loop aliasing?? <aether@centurytel.net>
Re: For loop aliasing?? (Sam Holden)
Re: For loop aliasing?? <jeff_haralson@qwest.net>
Re: get rid of these leading zeros in Perl <aether@centurytel.net>
Re: Pattern Matching: Which subpattern (rather than sub <gimi@psico.ch>
perldoc is like Greek to a beginner?? <miscellaneousemail@yahoo.com>
Re: perldoc is like Greek to a beginner?? <wyzelli@yahoo.com>
Re: Print outputs despite no value to print out?? <ilya@martynov.org>
Re: Save memory and measure used memory??? <goldbb2@earthlink.net>
Using a http proxy <nc@uq.net.au>
Re: Using a http proxy <ilya@martynov.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 8 Aug 2001 00:56:07 -0500
From: "Aether" <aether@centurytel.net>
Subject: Re: action=stuff?
Message-Id: <9kqk9s$5v15c$1@ID-101733.news.dfncis.de>
If you mean that you want to get the value of the parameter "action" then
add this:
use CGI qw(:all);
$action = param("action");
Now if you call this "script.pl?action=something", the variable $action will
be "something"
Hope this helps
PS - Check out http://stein.cshl.org/WWW/software/CGI for the whole story.
Nathan Randle <nathan.randle@ntlworld.com> wrote in message
news:uGYb7.23809$hs5.3808507@news2-win.server.ntlworld.com...
>
> Nathan Randle <nathan.randle@ntlworld.com> wrote in message
> news:LMXb7.17082$3K2.2065420@news6-win.server.ntlworld.com...
> > I want to put links on a page that lead to a perl script in the form
> > action=something. and each action will perform a different job
>
> That should be script.pl?action=something
> sorry
>
> >
> > I have seen other pages using this method and as a Perlish newbie I
would
> > like to know :-)
> >
> > hope you can help
> > Nathan
> >
> >
>
>
------------------------------
Date: 8 Aug 2001 01:36:16 -0400
From: dkcombs@panix.com (David Combs)
Subject: Can't make emacs & cperl-mode & gud work.
Message-Id: <9kqj4g$4f6$1@panix2.panix.com>
HELP: Can't make (cperl-mode and) M-x perldb (gud) work
First, here's what I'm using:
perl 5.6.1, on a sparc-5, solaris 7, (via:
-rw-r--r-- 1 dkc staff 5983695 Jun 19 01:57 perl-5.6.1.tar.gz )
I'm having problems trying to make "gud" work.
FIRST, from the doc (the FSF-paperback "GNU EMACS MANUAL"
(13th edition, version 20, July 1997 -- and which appears to have
IDENTICAL content as the *info*, at least for "Compiling and
Testing Programs"))
, I cannot figure out how to get "M-x perldb" to
show the source with me stepping through it, with the
little arrow moving down the screen.
That's what I want -- to see the source while setting breakpoints,
etc. (Else, I would just use *shell*.)
BUT, it turns out that I can't get "M-x perldb" to work AT ALL!
HELP!
Here's my tiny test-program, and a (successful) GUD-LESS, *shell* run:
--------------------
#!/usr/local/bin/perl5 -w ~dkc/PUT-PROG-NAME-HERE.pl
use strict;
#use diagnostics;
$^W = 1;
$SIG{__WARN__} = sub {print STDERR "PWARN: ", $_[0], "\n"};
print "hello world1\n";
print "hello world2\n";
print "hello world3\n";
print "hello world4\n";
--------------------
And of course it works:
762 ==/myexternals/home/dkc==> perl foo2.pl
hello world1
hello world2
hello world3
hello world4
------- AND, I *can* successfully run the debugger, from *shell*:
(But WITHOUT gud):
----------- This run lifted from *shell*:
767 ==/myexternals/home/dkc==> perl -w -d foo2.pl
Default die handler restored.
Loading DB routines from perl5db.pl version 1.07
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
main::(foo2.pl:4): $^W = 1;
DB<1> w
1 #!/usr/local/bin/perl5 -w ~dkc/PUT-PROG-NAME-HERE.pl
2: use strict;
3 #use diagnostics;
4==> $^W = 1;
5: $SIG{__WARN__} = sub {print STDERR "PWARN: ", $_[0], "\n"};
6
7: print "hello world1\n";
8: print "hello world2\n";
9: print "hello world3\n";
10: print "hello world4\n";
DB<1> b 7
DB<2> c
main::(foo2.pl:7): print "hello world1\n";
DB<2> s
hello world1
main::(foo2.pl:8): print "hello world2\n";
DB<2> s
hello world2
main::(foo2.pl:9): print "hello world3\n";
DB<2> c
hello world3
hello world4
Debugged program terminated. Use q to quit or R to restart,
use O inhibit_exit to avoid stopping after program termination,
h q, h R or h O to get additional info.
DB<2> q
768 ==/myexternals/home/dkc==>
-------- See -- it works just fine.
-------------------------- MY PROBLEM: I now try M-x perldb:
(Unfortunately, gives a very, *very* different result!)
First, I get "into" the buffer that has that source (foo2.pl), do a
"M-x perldb" and then it asks me for the command string.
I show my doing it twice, once with a -d, and then without:
------------------------------------ Several (annotated) "GUD" runs:
---- First, a perldb, my command, WITH a "-d": "perl -w -d foo2.pl":
Current directory is /myexternals/home/dkc/
Default die handler restored.
Loading DB routines from perl5db.pl version 1.07
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
Unquoted string "macs" may clash with future reserved word at -e line 1.
Useless use of a constant in void context at -e line 1.
main::(-e:1): macs
DB<1> w
1==> macs
DB<1> l
1==> macs
DB<1> b 7
Line 7 not breakable.
DB<2> s
Debugged program terminated. Use q to quit or R to restart,
use O inhibit_exit to avoid stopping after program termination,
h q, h R or h O to get additional info.
DB<2>
(To quit, I now do a "C-C C-\", and get back this:)
Debugger quit (core dumped)
(and then (hopefully) REALLY finish it off by
killing its buffer, *gud-foo2.pl*.)
QUESTION what was that "macs" as "main::"?
---- and then, WITHOUT the "-d": "perl -w foo2.pl":
(result: EXACTLY THE SAME)
Current directory is /myexternals/home/dkc/
Default die handler restored.
Loading DB routines from perl5db.pl version 1.07
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
Unquoted string "macs" may clash with future reserved word at -e line 1.
Useless use of a constant in void context at -e line 1.
main::(-e:1): macs
DB<1> w
1==> macs
DB<1> l
1==> macs
DB<1> b 7
Line 7 not breakable.
DB<2> s
Debugged program terminated. Use q to quit or R to restart,
use O inhibit_exit to avoid stopping after program termination,
h q, h R or h O to get additional info.
DB<2>
(Again, to quit, I now do a "C-C C-\", and get back this:)
Debugger quit (core dumped)
(and again (hopefully) REALLY finish it off by
killing its buffer, *gud-foo2.pl*.)
-------------------------
NOTE that no buffer containing the source showed up (although
there was my foo2.pl buffer right there in *Buffer List*,
and I could C-x b to it whenever I wanted.
QUESTION: whenever I tried the "f" command (its doc (from doing "h") is:
f filename
Switch to viewing filename. File must be already loaded.
filename may be either the full name of the file, or a regular
expression matching the full file name:
f /home/me/foo.pl and f oo\. may access the same file.
Evals (with saved bodies) are considered to be filenames:
f (eval 7) and f eval 7\b access the body of the 7th eval
(in the order of execution).
), I got this error about my file not being "loaded" (whatever
that means! -- and I went through those "Running Debuggers Under Emacs"
*info* pages, searching on
each one (of the five) for the word "load": NOTHING THERE)
Here's another run:
Unquoted string "macs" may clash with future reserved word at -e line 1.
Useless use of a constant in void context at -e line 1.
main::(-e:1): macs
DB<9> f foo2.pl
No file matching `foo2.pl' is loaded.
DB<10>
(I say again that my foo2.pl buffer was right there in *Buffer List*,
and I could C-x b to it whenever I wanted!)
-------
Is there any OTHER documentation on gud and its perldb?
What am I doing wrong?
THANKS!
David
------------------------------
Date: Wed, 08 Aug 2001 05:47:01 GMT
From: "Brent Dax" <brentdax1@earthlink.net>
Subject: Re: Embedded perl question
Message-Id: <pn4c7.4861$nb4.442951@newsread1.prod.itd.earthlink.net>
"Robert J. Lee" <Zarlock@pretty.co.uk> wrote in message
news:262e5e2a.0108071958.5a3fa92a@posting.google.com...
> Is there any easy way of saving the state of the perl interpretor to a
> file (i.e. the values of all variables AND any subroutines which have
> been processed)?
>
> Basically, I've decided to use embedded perl to add scripting
> capabilities to a MUD I'm writing in C++, which has to be stopped and
> restarted periodically as code changes (needing recompiling). So,
> obviously, I need to save any changes to the perl bits as well.
>
> I've got as far as getting a hashtable of all data out of the stash,
> which should contain globs of all the data AFAICT. But the docs don't
> seem to give much explanation on what I should be doing with globs
> ("GV*"s) to turn them into data to save. (Also, I seem to be getting
> "SV*"s from the hash and I don't know how to turn them into "GV*"s).
Eek.
The best advice I can give you is to look at something like Data::Dumper or
FreezeThaw. These allow you to turn variables into strings. Both support
complicated data structures (although neither handles globs well or can save
subroutines.)
HTH,
--Brent Dax
brentdax1@earthlink.net
------------------------------
Date: Wed, 08 Aug 2001 06:17:01 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How can I use a reference as a hash key?
Message-Id: <xP4c7.128$T3.191078912@news.frii.net>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.
+
How can I use a reference as a hash key?
You can't do this directly, but you could use the standard Tie::Refhash
module distributed with Perl.
-
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to
news:news.answers
or to the many thousands of other useful Usenet news groups.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-1999 Tom Christiansen and Nathan
Torkington. All rights reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
04.67
--
This space intentionally left blank
------------------------------
Date: Wed, 08 Aug 2001 04:39:05 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: For loop aliasing??
Message-Id: <MPG.15da70323bf95606989717@news.edmonton.telusplanet.net>
Hi everyone,
I have been reading through various documents online including perldoc
stuff and am having a hard time finding what I need to know. Can someone
explain something to me.
Given the code snippet below...
for ($string) {
s/^\s+//; # ^ anchor to beginning, \s space, + multiple spaces, replace
with nothing.
s/\s+$//; # $ anchor to end, replace with nothing.
}
I believe I can rewrite it like this...
$string =~ s/^\s+//;
$string =~ s/\s+$//;
What I don't understand is the aliasing that is occuring inside the for
loop. Does the scalar $string get assigned to the $_ implied variable
and then does this $_ variable become the target of each regular
expression?
Can someone recommend a good link somewhere on aliasing and what happens
and when underneath code like above. I have been looking and reading and
searching and searching but it's like looking for a needle in a haystack.
Thanks.
---
Carlos
www.internetsuccess.ca
------------------------------
Date: Wed, 08 Aug 2001 05:41:11 GMT
From: "Brent Dax" <brentdax1@earthlink.net>
Subject: Re: For loop aliasing??
Message-Id: <Xh4c7.4845$nb4.441010@newsread1.prod.itd.earthlink.net>
"Carlos C. Gonzalez" <miscellaneousemail@yahoo.com> wrote in message
news:MPG.15da70323bf95606989717@news.edmonton.telusplanet.net...
> Hi everyone,
>
> I have been reading through various documents online including perldoc
> stuff and am having a hard time finding what I need to know. Can someone
> explain something to me.
>
> Given the code snippet below...
>
> for ($string) {
> s/^\s+//; # ^ anchor to beginning, \s space, + multiple spaces, replace
> with nothing.
> s/\s+$//; # $ anchor to end, replace with nothing.
> }
>
> I believe I can rewrite it like this...
>
> $string =~ s/^\s+//;
> $string =~ s/\s+$//;
>
> What I don't understand is the aliasing that is occuring inside the for
> loop. Does the scalar $string get assigned to the $_ implied variable
> and then does this $_ variable become the target of each regular
> expression?
>
> Can someone recommend a good link somewhere on aliasing and what happens
> and when underneath code like above. I have been looking and reading and
> searching and searching but it's like looking for a needle in a haystack.
Foreach aliasing can't be explained, as it doesn't really appear anywhere
else in the language--it Just Happens. It's kinda like a typeglob
assignment (*_=\$string), except that the variable outside the parenthesis
can be myed. (Actually, @_ is aliased too, although I'm not sure if it's
the same mechanism.) My guess is that behind the scenes it's kinda like
local's saving and restoring of temps, although that doesn't entirely
explain it either, as local also only works on globals...
--Brent Dax
brentdax1@earthlink.net
------------------------------
Date: Wed, 8 Aug 2001 00:44:17 -0500
From: "Aether" <aether@centurytel.net>
Subject: Re: For loop aliasing??
Message-Id: <9kqjjo$5ubun$1@ID-101733.news.dfncis.de>
Yes $string gets assigned to $_. If there were multiple iterations of the
loop (like a for each) the same would happen for each value. And yes $_ is
the target of a reg ex without an explicit target.
One difference between this version and yours is that the "loop" does not
alter the value of $string. It assigns it to $_ and modifies that. Of
course, this code does nothing with $_ so the loop does nothing.
I don't have a link for you but a suggestion. Sams Teach Yourself Perl. It's
a little basic and doesn't spend much time on modules, but it covers the
fundamentals nicely. Worth a read.
Carlos C. Gonzalez <miscellaneousemail@yahoo.com> wrote in message
news:MPG.15da70323bf95606989717@news.edmonton.telusplanet.net...
> Hi everyone,
>
> I have been reading through various documents online including perldoc
> stuff and am having a hard time finding what I need to know. Can someone
> explain something to me.
>
> Given the code snippet below...
>
> for ($string) {
> s/^\s+//; # ^ anchor to beginning, \s space, + multiple spaces, replace
> with nothing.
> s/\s+$//; # $ anchor to end, replace with nothing.
> }
>
> I believe I can rewrite it like this...
>
> $string =~ s/^\s+//;
> $string =~ s/\s+$//;
>
> What I don't understand is the aliasing that is occuring inside the for
> loop. Does the scalar $string get assigned to the $_ implied variable
> and then does this $_ variable become the target of each regular
> expression?
>
> Can someone recommend a good link somewhere on aliasing and what happens
> and when underneath code like above. I have been looking and reading and
> searching and searching but it's like looking for a needle in a haystack.
>
> Thanks.
>
> ---
> Carlos
> www.internetsuccess.ca
------------------------------
Date: 8 Aug 2001 05:55:43 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: For loop aliasing??
Message-Id: <slrn9n1l3k.jt8.sholden@pgrad.cs.usyd.edu.au>
On Wed, 8 Aug 2001 00:44:17 -0500, Aether <aether@centurytel.net> wrote:
>Yes $string gets assigned to $_. If there were multiple iterations of the
>loop (like a for each) the same would happen for each value. And yes $_ is
>the target of a reg ex without an explicit target.
>
>One difference between this version and yours is that the "loop" does not
>alter the value of $string. It assigns it to $_ and modifies that. Of
>course, this code does nothing with $_ so the loop does nothing.
It in fact does modify $string, since $_ is made an alias for $string.
Perhaps you should try things out before declaring them as facts...
--
Sam Holden
------------------------------
Date: Tue, 7 Aug 2001 23:25:44 -0700
From: "Jeff" <jeff_haralson@qwest.net>
Subject: Re: For loop aliasing??
Message-Id: <4X4c7.3194$87.438823@news.uswest.net>
"Carlos C. Gonzalez" <miscellaneousemail@yahoo.com> wrote in message
news:MPG.15da70323bf95606989717@news.edmonton.telusplanet.net...
> Hi everyone,
>
> I have been reading through various documents online including perldoc
> stuff and am having a hard time finding what I need to know. Can someone
> explain something to me.
>
> Given the code snippet below...
>
> for ($string) {
> s/^\s+//; # ^ anchor to beginning, \s space, + multiple spaces, replace
> with nothing.
> s/\s+$//; # $ anchor to end, replace with nothing.
> }
>
> I believe I can rewrite it like this...
>
> $string =~ s/^\s+//;
> $string =~ s/\s+$//;
>
> What I don't understand is the aliasing that is occuring inside the for
> loop. Does the scalar $string get assigned to the $_ implied variable
> and then does this $_ variable become the target of each regular
> expression?
>
> Can someone recommend a good link somewhere on aliasing and what happens
> and when underneath code like above. I have been looking and reading and
> searching and searching but it's like looking for a needle in a haystack.
>
> Thanks.
>
> ---
> Carlos
> www.internetsuccess.ca
>
the construct ( ) is an array like ( 1,2,3,4 ) is an array containing 4
items. In your example you have an array with one item ($string)
Typically you see a for loop written
for $string (@strings)
{
$string =~ s/^\s+//;
$string =~ s/\s+$//;
}
In this case $string gets a reference to each item in @strings
In the absence of "$string" in my loop the for loop would assign $_ a
reference to each item in the array. References are something like pointers
in C. They allow you to directly manipulate the items in the array without
doing the reassignment suffle you describe above. Unlike C pointers,
references have some loose rule especially when you have not set the pragma
'use strict ref'. Perl will attempt to use the value stored in a scalar
"$variable" as the name of a real variable if you have not set 'use strict
ref'. If you search for references and read up you'll get the picture.
Jeff
------------------------------
Date: Wed, 8 Aug 2001 01:14:27 -0500
From: "Aether" <aether@centurytel.net>
Subject: Re: get rid of these leading zeros in Perl
Message-Id: <9kqlcc$5v5bv$1@ID-101733.news.dfncis.de>
Forget the reg ex, perl does this automatically.
Someone already suggested "print int($id1);"
printf("%d", $id1);
will also work and you can add text and suck to it.
The point is perl strips the insignificant zeros for you.
Hope this helps
Larry S <dime0000@yahoo.com> wrote in message
news:8fd7acb0.0108070639.2a49a2d9@posting.google.com...
> hey all.
>
> i have a really simple (i believe) problem, and i'm new to this..
>
> i want to print out a value of $id1, without leading zeros, so say
> $id1 is "00061", i want to print it as "61".
>
> i'm assuming its a printf function, but i'm not sure. please help!
>
> thanks
------------------------------
Date: Wed, 08 Aug 2001 07:28:10 +0200
From: gimi <gimi@psico.ch>
Subject: Re: Pattern Matching: Which subpattern (rather than substring) was matched?
Message-Id: <3B70CDEA.76969A46@psico.ch>
hi bart,
Bart Lateur wrote:
> gimi wrote:
> > not cool, but it would work this way:
> > $string =~ /$subpattern1/ and print "matched $subpattern1\n"
> > or $string =~ /$subpattern2/ and print "matched $subpattern2\n"
> > # and so on
> > ;
> >
> >so you would know which.
>
> No way. The OP likely wants the first pattern to do the leftmost match.
(i don't give a d*** on what _he_ wants! :)
- but read on please..)
> For example:
> $_ = 'xxxxdefxxxxabcxxxx';
> /(abc)|(def)/;
>
> This will find the "def", because it matches more towards the left than
> "abc"; while yours will find the "abc".
right. - so, i remove the 'or's and get
$string =~ /$subpattern1/ and print "matched $subpattern1\n";
$string =~ /$subpattern2/ and print "matched $subpattern2\n";
# and so on
now both will be found successively; and if
you replace 'print "matched $subpattern1\n"' by
something like '$position1 = pos()' you get
where i wanted _him_ to go, but you didn't
get nor quote that i also said:
< Simon Best wrote:
< > Anyway, the reason I wish to do this is because I wish to find the
< > earliest match (the one furthest to the left in the string) out of a
< > number of alternatives, and know which alternative it was that
matched.
<
< as for the 'earliest'.. ask pos() every time and compare the
< numbers you get. see
< % perldoc -f pos
with 'ask pos() every time' i meant to ask pos()
after every single successful match, like
$string =~ /$subpattern1/ and $position1 = pos();
then compare the $positionX values to find out
which one came first.
i expected _him_ to put one and one together
and this would result in a working solution,
wouldn't it?
- though i didn't think of the @-/@+ family
right then. - i read about these, although
have not used them.. but now i remember, and
i can also see another use for them.. :D
i'm sorry that i could not make myself clear to
you. but i hope you're happy now. - i am. :D
yodel,
gimi
--
$_ = "sing "; # moloko
while ($_) {
s/sing/sing it back/g;
print;
die "until its over" if /.{100}/;
}
------------------------------
Date: Wed, 08 Aug 2001 04:38:24 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: perldoc is like Greek to a beginner??
Message-Id: <MPG.15da6ff931aa281d989716@news.edmonton.telusplanet.net>
Hi everyone,
A lot of the perldoc documentation is very thorough and people have
graciously put a lot of time into it. For this I am grateful but a lot
of it for someone like me who is a beginner is like Greek.
Interpolation, unary operator, lexical scope, expected semantics, extent
of a string... These are just some of the "Greek" terms in perldoc
perlop that I saw. Now I have some idea of what some of these are but
the point I am making is that it seems to me that another version of the
documentation needs to be rewritten in common English. Without so much
computereese in it. Especially for us new beginners.
It is very frustrating sometimes to be told to go read this or that perl
documentation only to go to the documentation and to find myself reading
something that has a bunch of terms that I don't even understand. I need
a simple answer to a simple and pointed question and I end up being
confronted with a volume of information which ends up throwing terms at
me that are even more confusing.
Please don't get me wrong. It's good to read through the documentation
and I appreciate every tid bit and insight that is given me on this
newsgroup and every suggestion as to which docomentation I should read.
I truly do. But I guess I am just wondering if it might not be good to
have a new perldoc added devoted to giving the common meaning to as many
computereese terms as can be found?
I don't mean to step on anyone's toes. I am just expressing my
frustrations as a beginner to Perl for what they are worth and welcome
any feedback on any of this.
Thanks.
--
Carlos
www.internetsuccess.ca
------------------------------
Date: Wed, 8 Aug 2001 15:07:26 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: perldoc is like Greek to a beginner??
Message-Id: <A74c7.12$5o.1195@vic.nntp.telstra.net>
"Carlos C. Gonzalez" <miscellaneousemail@yahoo.com> wrote in message
news:MPG.15da6ff931aa281d989716@news.edmonton.telusplanet.net...
> Hi everyone,
>
> A lot of the perldoc documentation is very thorough and people have
> graciously put a lot of time into it. For this I am grateful but a lot
> of it for someone like me who is a beginner is like Greek.
> Interpolation, unary operator, lexical scope, expected semantics, extent
> of a string... These are just some of the "Greek" terms in perldoc
> perlop that I saw. Now I have some idea of what some of these are but
> the point I am making is that it seems to me that another version of the
> documentation needs to be rewritten in common English. Without so much
> computereese in it. Especially for us new beginners.
>
> It is very frustrating sometimes to be told to go read this or that perl
> documentation only to go to the documentation and to find myself reading
> something that has a bunch of terms that I don't even understand. I need
> a simple answer to a simple and pointed question and I end up being
> confronted with a volume of information which ends up throwing terms at
> me that are even more confusing.
>
> Please don't get me wrong. It's good to read through the documentation
> and I appreciate every tid bit and insight that is given me on this
> newsgroup and every suggestion as to which docomentation I should read.
> I truly do. But I guess I am just wondering if it might not be good to
> have a new perldoc added devoted to giving the common meaning to as many
> computereese terms as can be found?
>
> I don't mean to step on anyone's toes. I am just expressing my
> frustrations as a beginner to Perl for what they are worth and welcome
> any feedback on any of this.
>
www.manning.com/Johnson/
Wyzelli
--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;
------------------------------
Date: 08 Aug 2001 10:47:33 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: Print outputs despite no value to print out??
Message-Id: <87itfzhwu2.fsf@abra.ru>
>> No it doesn tryies to print to filehandle HTML. It looks for me like a
>> Perl bug.
MC> Not a bug, really, but a result of how Perl determines the return value
MC> of a subroutine. In the absence of a return() statement, Perl uses the
MC> result of the last evaluation as the return value. That is, these are
MC> equivilant:
MC> sub answer {
MC> return 42;
MC> }
MC> sub answer {
MC> 42;
MC> }
MC> With nothing else in the sub, the return value becomes @_. That is, it
MC> returns whatever you passed in.
But why it doesn't work under perl debugger?
bash-2.05$ cat > test.pl
sub test { }
print test("test\n");
bash-2.05$ perl test.pl
test
bash-2.05$ perl -d test.pl
Default die handler restored.
Loading DB routines from perl5db.pl version 1.07
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
main::(test.pl:2): print test("test\n");
DB<1> c
Debugged program terminated. Use q to quit or R to restart,
use O inhibit_exit to avoid stopping after program termination,
h q, h R or h O to get additional info.
DB<1> q
bash-2.05$
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Wed, 08 Aug 2001 02:19:12 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Save memory and measure used memory???
Message-Id: <3B70D9E0.ED2C508F@earthlink.net>
Markus wrote:
>
> I want to read and store thousands of rules like these:
>
> A -> MPN NP
> A -> MPN NP $.
> A -> MPN NP NE $.
> A -> MPN NP NP NP NP $.
> A -> MPN NP NP NP NP NP
> A -> MPN NP NP PP NP NP NP AP $.
> A -> MPN NP PP NP NP NP $.
> B -> NP PP
> B -> NP PP CD
>
> What is the most memory-saving efficient way to store the rules?
> Note that many rules begin with the same symbols.
use Tree::Trie;
my $rules = Tree::Trie->new;
$rules -> add( <DATA> );
sub getrules() {
my $item = shift;
$rules -> lookup( $item . " -> " );
}
print getrules("A");
__DATA__
A -> MPN NP
A -> MPN NP $.
A -> MPN NP NE $.
A -> MPN NP NP NP NP $.
A -> MPN NP NP NP NP NP
A -> MPN NP NP PP NP NP NP AP $.
A -> MPN NP PP NP NP NP $.
B -> NP PP
B -> NP PP CD
__END__
--
I need more taglines. This one is getting old.
------------------------------
Date: Wed, 08 Aug 2001 15:35:54 +1000
From: Matthew Braid <nc@uq.net.au>
Subject: Using a http proxy
Message-Id: <3B70CFBA.EFDE239C@uq.net.au>
Hi all,
I need to write a program that will fetch webpages via a proxy.
The way I do it on the command line is similar to:
# telnet proxy 80
GET http://www.somesite.com/index.html HTML/1.0
<BLAH>
I had great trouble trying to do this in perl (I just couldn't send
stuff to telnet, whether I redirected info from a file with a '<', or
passed it in by using:
open(TH, "|telnet proxy 80 > temp_file");
print TH 'GET http://www.somesite.com/index.html HTML/1.0', "\n\n";
(temp_file always ended up with just the connection messages and nothing
else)
So then I looked at Net::Telnet, but without a prompt I couldn't get it
working (well, at least I think that was what was wrong).
I'm guessing I should actually be using sockets, but I'd be buggered if
I can figure that out either. This is what I tried:
--- START PERL ---
use Socket;
my ($remote, $port, $iaddr, $paddr, $proto, $line);
$remote = "proxy";
$port = 80;
$iaddr = inet_aton($remote) or die "NO HOST $remote - $!";
print "IADDR = $iaddr\n";
$paddr = sockaddr_in($port, $iaddr);
print "PADDR = $paddr\n";
$proto = getprotobyname('tcp');
print "PROTO = $proto\n";
socket(SOCK, PF_INET, SOCK_STREAM, $proto) or die "NO SOCKET - $!";
connect(SOCK, $paddr) or die "NO CONNECT - $!";
print SOCK 'GET http://www.somesite.com/index.html HTTP/1.0' . "\n\n";
while (defined($line = <SOCK>)) {
print ": $line";
}
close(SOCK);
exit;
--- END PERL ---
This just froze (I'm guessing it was waiting for something to come in on
SOCK).
So what am I doing wrong? If there's some massive chunk of documentation
out there that I'm missing, please point the way.
MB (change nc to mb in my email address to make it work).
------------------------------
Date: 08 Aug 2001 10:52:32 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: Using a http proxy
Message-Id: <87elqnhwlr.fsf@abra.ru>
MB> Hi all,
MB> I need to write a program that will fetch webpages via a proxy.
Don't bother with socket level programming. Use LWP::UsarAgent to
fetch webpages. It has support for proxies.
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 1460
***************************************