[25191] in Perl-Users-Digest
Perl-Users Digest, Issue: 7439 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 23 09:05:46 2004
Date: Tue, 23 Nov 2004 06:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 23 Nov 2004 Volume: 10 Number: 7439
Today's topics:
Re: cookie failes <nospam@nospam.com>
Re: cookie failes bmay2068@hotmail.com
Re: error from pipe in sendmail alias <joe@inwap.com>
FAQ 9.10: How do I decode or create those %-encodings o <comdog@panix.com>
Re: File slurp takes a long time on some files <joe@inwap.com>
Re: File slurp takes a long time on some files <bart.lateur@pandora.be>
Re: finding the number of keys in hash (Anno Siegel)
Re: How can I rid a Deprecated REF problem? (Anno Siegel)
how does ByteLoader work? <fxn@hashref.com>
Re: how does ByteLoader work? <tassilo.von.parseval@rwth-aachen.de>
Re: how does ByteLoader work? <fxn@hashref.com>
Re: how does ByteLoader work? <tassilo.von.parseval@rwth-aachen.de>
How to create a non-blocking Socket? <qjzhupublic@__nospam__yahoo.ie>
Re: How to create a non-blocking Socket? <kalinaubears@iinet.net.au>
Re: How to create a non-blocking Socket? bmay2068@hotmail.com
Re: IO object version 1.21 does not match bootstrap par <spamtrap@dot-app.org>
passing parameters from xsl to cgi script <lievemario@hotmail.com>
Re: Perl on the Pocket PC - Easy! (Anno Siegel)
Re: Perl on the Pocket PC - Easy! <mritty@gmail.com>
redirect question <nospam@nospam.com>
Re: redirect question (Anno Siegel)
Re: redirect question <richard@zync.co.uk>
Strange asterisk use in a hash declaration (Jess Graves)
Re: Strange asterisk use in a hash declaration <spamtrap@dot-app.org>
sysread(socket..) problem on perl 5.8.0 linux <bcant@centra-systems.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 23 Nov 2004 06:33:11 -0500
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: cookie failes
Message-Id: <1101209667.172064@nntp.acecape.com>
"MrReallyVeryNice"
<MrReallyVeryNice.REMOVE.NO.SPAM@Yahoo.REMOVE.NO.SPAM.com> wrote in message
news:xeWdnXeTXZFILD_cRVn-sQ@comcast.com...
> When I execute the script from my browser (Firefox 1.0), it displays:
> 'foo' is set to bar.
> You should hopefully see the same results from your browser. :)
>
> I hope that this is helpful.
> MrRVN
got it.....i missed the part that it is ONLY written to the file if it is
persistent....i assumed as long as the browser stayed open, it would appear
within the cookie file
------------------------------
Date: 23 Nov 2004 05:44:12 -0800
From: bmay2068@hotmail.com
Subject: Re: cookie failes
Message-Id: <15a18d1a.0411230544.21d72f8e@posting.google.com>
"daniel kaplan" <nospam@nospam.com> wrote in message
[SNIP]
> my $q = new CGI;
> my $c = new CGI::Cookie(-name => 'foo', -value => 'bar');
>
> print $q->header(-cookie => $c);
> exit 0;
The following code seems to work fine for me... notice that I'm
using the object $q to generate my cookie and not doing a new
cookie object like you did in your code.
my $q = new CGI;
my $c = $q->cookie(-name => 'foo',
-value => 'bar');
print $q->header(-cookie=>$c);
exit 0;
Cheers!
------------------------------
Date: Tue, 23 Nov 2004 10:57:32 GMT
From: Joe Smith <joe@inwap.com>
Subject: Re: error from pipe in sendmail alias
Message-Id: <wIEod.75298$V41.37313@attbi_s52>
nickname wrote:
> maillog, stat=unknown mailer error 137
Sometimes error code 137 is 9 + 128 = Segmentation fault, core dumped.
> and messages, /kernel: pid 94738 (perl), uid 26, was killed: out of
> swap space
That happens when your program gets into an infinite loop constantly
allocating memory. Try printing progress messages to a log file.
-Joe
------------------------------
Date: Tue, 23 Nov 2004 11:03:00 +0000 (UTC)
From: PerlFAQ Server <comdog@panix.com>
Subject: FAQ 9.10: How do I decode or create those %-encodings on the web?
Message-Id: <cnv5d4$jkc$1@reader1.panix.com>
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 Perl.
--------------------------------------------------------------------
9.10: How do I decode or create those %-encodings on the web?
If you are writing a CGI script, you should be using the CGI.pm module
that comes with perl, or some other equivalent module. The CGI module
automatically decodes queries for you, and provides an escape() function
to handle encoding.
The best source of detailed information on URI encoding is RFC 2396.
Basically, the following substitutions do it:
s/([^\w()'*~!.-])/sprintf '%%%02x', ord $1/eg; # encode
s/%([A-Fa-f\d]{2})/chr hex $1/eg; # decode
However, you should only apply them to individual URI components, not
the entire URI, otherwise you'll lose information and generally mess
things up. If that didn't explain it, don't worry. Just go read section
2 of the RFC, it's probably the best explanation there is.
RFC 2396 also contains a lot of other useful information, including a
regexp for breaking any arbitrary URI into components (Appendix B).
--------------------------------------------------------------------
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.
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-2002 Tom Christiansen and Nathan
Torkington, and other contributors as noted. 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.
------------------------------
Date: Tue, 23 Nov 2004 10:40:17 GMT
From: Joe Smith <joe@inwap.com>
Subject: Re: File slurp takes a long time on some files
Message-Id: <lsEod.75260$V41.4395@attbi_s52>
Tom Sliva wrote:
> I have two text files I am trying to slurp.
Have you tried using File::Slurp instead of a do-it-yourself solution?
It is specifically optimized for certain cases.
-Joe
------------------------------
Date: Tue, 23 Nov 2004 13:02:37 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: File slurp takes a long time on some files
Message-Id: <ruc6q0ttufkhijsihutgb00tn6nobkikdn@4ax.com>
Tom Sliva wrote:
>Type A files open and dump in ~1 second. Type B files take ~5 seconds
>for the 1st file and ~77 seconds for the second.
Quick, uninformed guess: type B is too big to fit in the cache, type A
fits, though tightly.
--
Bart.
------------------------------
Date: 23 Nov 2004 12:39:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: finding the number of keys in hash
Message-Id: <cnvb1p$hrf$1@mamenchi.zrz.TU-Berlin.DE>
Alan Mead <amead@comcast.net> wrote in comp.lang.perl.misc:
> Here's what you want, I think.. but why?
>
> for (my $i=0; $i< scalar keys %$A; $i++) { print "$i\n"; }
^^^^^^
No need for "scalar", since "<" puts its arguments in scalar context.
A bit shorter is
for my $i ( 0 .. keys %$A ) { ... }
Anno
------------------------------
Date: 23 Nov 2004 11:06:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How can I rid a Deprecated REF problem?
Message-Id: <cnv5jd$fdr$1@mamenchi.zrz.TU-Berlin.DE>
Ian Pellew <ipellew@pipemedia.co.uk> wrote in comp.lang.perl.misc:
> Hi All;
>
> Why am I getting the perl -W complaint like:-
> [Thu Nov 18 22:44:07 2004] w: Using a hash as a reference is
> deprecated at w line 435.
> . . . . .
>
> from the likes of :-
> 435: my $en = \%$t_xmlin->{$child}->{$tag_s};
Precedence -- the expression is parsed as
\ ( %$t_xmlin->{$child}->{$tag_s});
which gives you a scalar ref (and the warning).
I'm not sure why you think you need all this de-referencing and
referencing.
my $en = $t_xmlin->{$child}->{$tag_s};
Anno
------------------------------
Date: 23 Nov 2004 01:16:25 -0800
From: "Xavier Noria" <fxn@hashref.com>
Subject: how does ByteLoader work?
Message-Id: <1101201385.891026.138410@c13g2000cwb.googlegroups.com>
Normally you see source filters explained as modules that intercept
source code before it's feed to the tokener. Nevertheless ByteLoader
looks like something that would load somehow the bytecodes directly
into the interpreter, bypassing any parsing. Is that guess right? If it
is, how can the module bypass the parser?
-- fxn
------------------------------
Date: Tue, 23 Nov 2004 11:17:41 +0100
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: how does ByteLoader work?
Message-Id: <slrncq63i5.5l6.tassilo.von.parseval@localhost.localdomain>
Also sprach Xavier Noria:
> Normally you see source filters explained as modules that intercept
> source code before it's feed to the tokener. Nevertheless ByteLoader
> looks like something that would load somehow the bytecodes directly
> into the interpreter, bypassing any parsing. Is that guess right? If it
> is, how can the module bypass the parser?
It uses a source-filter. Source filters are hooked into the optree
building process before the parser and lexer start their work.
Unlike most other source-filters, DynaLoader does not rewrite the
source. Instead, it creates an optree from it and nulls out the source
code so that the parser afterwards gets an empty token stream.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 23 Nov 2004 02:32:18 -0800
From: "Xavier Noria" <fxn@hashref.com>
Subject: Re: how does ByteLoader work?
Message-Id: <1101205938.566950.246090@f14g2000cwb.googlegroups.com>
So the question then is: how can ByteLoader (I guess DynaLoader was
ByteLoader in your post) tell perl to use the optree it builds and
ignore the output of the parser, which is empty? Does perl offer in the
C side something like
disable_parser_for_this_source_stream();
load_optree(*my_hand_made_optree);
so to speak?
-- fxn
------------------------------
Date: Tue, 23 Nov 2004 13:08:53 +0100
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: how does ByteLoader work?
Message-Id: <slrncq6a2l.60e.tassilo.von.parseval@localhost.localdomain>
Also sprach Xavier Noria:
> So the question then is: how can ByteLoader (I guess DynaLoader was
> ByteLoader in your post) tell perl to use the optree it builds and
> ignore the output of the parser, which is empty? Does perl offer in the
> C side something like
>
> disable_parser_for_this_source_stream();
> load_optree(*my_hand_made_optree);
>
> so to speak?
The pointer to the main optree is kept in two global variables,
PL_main_root and PL_main_start, I think. ByteLoader's source filter
simply modifies this global optree so there is no separate
'my_hand_made_optree'. It re-assembles the serialized bytecode and
fiddles it into the real optree.
Disabling the parser isn't necessary either. The parser will still be
invoked but it wont see the original source (i.e. the serialized
bytecode). ByteLoader does that by setting PL_rsfp (the file-pointer of
the source-file) to NULL.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Tue, 23 Nov 2004 14:36:18 +0800
From: metfan <qjzhupublic@__nospam__yahoo.ie>
Subject: How to create a non-blocking Socket?
Message-Id: <opshwnasdaixx7zf@ehc022.ehealth-china.com>
Hi,
I want to get a non-blocking socket, here is my code:
use IO::Socket::INET;
my $sock = IO::Socket::INET->new(Listen => 5,
LocalPort => 8000,
Proto => 'tcp',
Type => SOCK_STREAM,
Timeout => 0.01,
MultiHomed => 1,
ReuseAddr => 1,
Blocking => 0
)
or die "can'nt create $!.\n";
after running this code, $sock was evaluated to undef and program died.
if I remove Blocking => 0 in the constructor, I can got a defined $sock,
but any socket accepted by $sock will be in blocking mode, I can not do
non-blocking IO on them. can you give me any idea?
thanks.
------------------------------
Date: Tue, 23 Nov 2004 07:48:10 +0000
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: How to create a non-blocking Socket?
Message-Id: <41a2faa7$1$25772$5a62ac22@per-qv1-newsreader-01.iinet.net.au>
metfan wrote:
> Hi,
> I want to get a non-blocking socket, here is my code:
> use IO::Socket::INET;
>
> my $sock = IO::Socket::INET->new(Listen => 5,
> LocalPort => 8000,
> Proto => 'tcp',
> Type => SOCK_STREAM,
> Timeout => 0.01,
> MultiHomed => 1,
> ReuseAddr => 1,
> Blocking => 0
> )
> or die "can'nt create $!.\n";
> after running this code, $sock was evaluated to undef and program died.
> if I remove Blocking => 0 in the constructor, I can got a defined $sock,
> but any socket accepted by $sock will be in blocking mode, I can not do
> non-blocking IO on them. can you give me any idea?
> thanks.
I find that all I need specify (on Win32) is as follows:
use warnings;
use strict;
use IO::Socket;
my $server = IO::Socket::INET->new(LocalPort => 8000,
Type => SOCK_STREAM,
Reuse => 1,
Listen => 1 )
or die "Couldn't be a tcp server on port 8000 : $!\n";
while(1) {
# receive and process
}
__END__
Hope that does the job for you, too.
Cheers,
Rob
--
To reply by email u have to take out the u in kalinaubears.
------------------------------
Date: 23 Nov 2004 05:31:06 -0800
From: bmay2068@hotmail.com
Subject: Re: How to create a non-blocking Socket?
Message-Id: <15a18d1a.0411230531.241c7976@posting.google.com>
metfan <qjzhupublic@__nospam__yahoo.ie> wrote in message news:<opshwnasdaixx7zf@ehc022.ehealth-china.com>...
> Hi,
> I want to get a non-blocking socket...
[SNIP]
Search engines are a wonerful creation! Do a little
searching on keywords such as PERL NONBLOCK SOCKET.
That being said...
use POSIX;
fcntl($sock, F_SETFL(), O_NONBLOCK());
Cheers!
------------------------------
Date: Tue, 23 Nov 2004 00:19:06 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: IO object version 1.21 does not match bootstrap parameter 1.18
Message-Id: <47idnT03TqnQVT_cRVn-1w@adelphia.com>
Eugene Borukhovich wrote:
> I have compiled form scratch some modules for ex Net::Ping and for
> some reason can not use them.
How did you compile them? Did you use the *full* standard procedure, up
to and including the "make install"? Any special options or flags?
> IO object version 1.21 does not match bootstrap parameter 1.18 at
> /usr/lib/perl5/5.8.3/i386-linux-thread-multi/DynaLoader.pm line 249.
The IO module has two separate pieces, a compiled C component that's in
a .so file, and a Perl component that's in a .pm file. This error
indicates that the version number reported by these two pieces does not
match.
This is generally the result of an incorrectly installed module, which
is why I asked above how you installed it.
> I actually thought to upgrade the DynaLoader
That's absurd. The error message clearly states what module - IO - is
misconfigured.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Tue, 23 Nov 2004 12:11:32 +0100
From: "lievemario" <lievemario@hotmail.com>
Subject: passing parameters from xsl to cgi script
Message-Id: <cnv5pv$ke2$1@snic.vub.ac.be>
I have made a perl script witch gets information out of a database,
transfers it into an xml-file file and than I parse this to a html document
using xsl.
The problem is dat the html doc needs a parameter which can be found in the
xml file.
I've done something like
<xsl:variable name="id" select="person_id"/>
<a href="http://localhost/CGI/detailsselection.cgi?ID=$id"><xsl:value-of
select="name"></xsl:value-of><xsl:value-of
select="first_name"></xsl:value-of></a>
Of course this doesn't give me the value of the id-variable. But it just
returns $id.
How can I solve this?
Thanks
L
------------------------------
Date: 23 Nov 2004 11:24:13 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Perl on the Pocket PC - Easy!
Message-Id: <cnv6kt$fdr$2@mamenchi.zrz.TU-Berlin.DE>
wana <ioneabu@yahoo.com> wrote in comp.lang.perl.misc:
> > map() should almost never be used in a void context. Use map when you
> > want to obtain a list of modified values from an existing list. If
> > you're not using the modified values (or in this case, not even
> > modifying them), use a foreach loop instead:
> >
> > for (@b) {
> > $c += $1 if /^(\d+)\s/;
> > }
> >
>
> > Knowing how to use them is a good step in the right direction. Knowing
> > *when* to use them is a better step. :-)
> >
> > Paul Lalli
> >
>
> It just occurred to me why I used map (other than to just use it). I was
> under the impression, probably erroneously, that $_ is very safely
> localized within the block evaluated by map.
It is, but the same is true for "for" loops (but not for "while").
Anno
------------------------------
Date: Tue, 23 Nov 2004 12:16:15 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Perl on the Pocket PC - Easy!
Message-Id: <jSFod.6624$8o.6386@trndny08>
"wana" <ioneabu@yahoo.com> wrote in message
news:10q5btm7jkrlbcd@news.supernews.com...
> > map() should almost never be used in a void context. Use map when
you
> > want to obtain a list of modified values from an existing list. If
> > you're not using the modified values (or in this case, not even
> > modifying them), use a foreach loop instead:
> >
> > for (@b) {
> > $c += $1 if /^(\d+)\s/;
> > }
> >
>
> It just occurred to me why I used map (other than to just use it). I
was
> under the impression, probably erroneously, that $_ is very safely
> localized within the block evaluated by map.
Yes, $_ is local'ized in a map block. However it is also localized in a
foreach-style loop (as above).
> I was wondering if the $_ in a map block is localized more
> safely than a local $_ in an ordinary block.
$_ isn't localized in an "ordinary" block unless you do it explicitly.
map and foreach do it automatically.
> It would seem that $_ might not be safe to use in all but the
smallest,
> simplest scripts. Doesn't it bypass the checking done by using
strict?
The "special" variables (all the ones that are listed in perldoc
perlvar) are not subject to the strict 'vars' pragma, no. They always
exist. More to the point, you cannot create lexical variables with
those names, even if you wanted to. This is a run time error:
my $_ = 'foo';
You can only assign temporary values to the already-existing global
variables, with local.
Paul Lalli
------------------------------
Date: Tue, 23 Nov 2004 08:13:14 -0500
From: "daniel kaplan" <nospam@nospam.com>
Subject: redirect question
Message-Id: <1101215671.839815@nntp.acecape.com>
hi all,
i can do a redirect OR i can set a cookie, but it appears that i cannot do
BOTH on the same page.
obviously what i would like to do is to have a user log in:
set a cookie saying so
then send them off to the new page.
but according to my documentation "the redirect header has to be printed
before anything else is emmited from the CGI script. so of course, i tried
doing the redirect FOLLOWED by setting the cookie. but that didn't work
either...
i have confirmed that i can individually do either or....just not not
both...
so i replaced the redirect with the META refresh statement.....and of course
that works. but since i fail to find a reference to it in the FAQ, i just
want to make sure there isn't a more proper way to execute the logic.
as always,thanks ahead
daniel
------------------------------
Date: 23 Nov 2004 13:51:53 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: redirect question
Message-Id: <cnvf9p$lg1$1@mamenchi.zrz.TU-Berlin.DE>
daniel kaplan <nospam@nospam.com> wrote in comp.lang.perl.misc:
> hi all,
>
> i can do a redirect OR i can set a cookie, but it appears that i cannot do
> BOTH on the same page.
>
> obviously what i would like to do is to have a user log in:
>
> set a cookie saying so
> then send them off to the new page.
>
> but according to my documentation "the redirect header has to be printed
> before anything else is emmited from the CGI script. so of course, i tried
> doing the redirect FOLLOWED by setting the cookie. but that didn't work
> either...
>
> i have confirmed that i can individually do either or....just not not
> both...
>
> so i replaced the redirect with the META refresh statement.....and of course
> that works. but since i fail to find a reference to it in the FAQ, i just
> want to make sure there isn't a more proper way to execute the logic.
There is no Perl content in any of this. Please learn to identify
your problem domains.
Anno
------------------------------
Date: Tue, 23 Nov 2004 14:05:28 +0000
From: Richard Gration <richard@zync.co.uk>
Subject: Re: redirect question
Message-Id: <pan.2004.11.23.14.05.28.2900@zync.co.uk>
On Tue, 23 Nov 2004 08:13:14 -0500, daniel kaplan wrote:
> hi all,
>
> i can do a redirect OR i can set a cookie, but it appears that i cannot do
> BOTH on the same page.
I haven't tried it but I know I have done just what you describe in the
past with cgi scripts. I am currently doing it with mod_perl. It
absolutely, completely, definitely, beyond a shadow of a doubt works.
Are you using CGI.pm? If so:
use strict;
use warnings;
use CGI qw(&cookie &redirect);
my $cookie = cookie(-name=>'blah',-value=>'blah');
print redirect(-cookie=>$cookie,-uri=>'http://google.com');
This is the sequence of headers produced:
Status: 302 Moved
Set-Cookie: blah=blah; path=/
Date: Tue, 23 Nov 2004 13:54:08 GMT
Location: http://google.com
Rich
------------------------------
Date: 23 Nov 2004 05:31:35 -0800
From: jessgraves1@comcast.net (Jess Graves)
Subject: Strange asterisk use in a hash declaration
Message-Id: <74f6f057.0411230531.6b5e969c@posting.google.com>
In WWW::Scraper::Google (a module by Glenn Wood), a this hash is
declared:
(exactly as in Google.pm)
my $scraperRequest =
{
'fieldTranslations' => {
'*' => {
'*' => '*'
}
},
#http://www.google.com/search?hl=en&lr=&ie=UTF-8&oe=utf-8&safe=active&q=turntable&btnG=Google+Search
'SKIP' => ''
'nativeDefaults' => {
'q' => '',
#'as_eq' => 'turntable',
#'oe' => 'utf-8',
#'as_q' => '',
'lr' => '',
'hl' => 'en',
'btnG' => 'Google Search',
'safe' => 'active',
#'as_epq' => 'google com',
#'as_sitesearch' => '',
#'as_oq' => '',
'ie' => 'UTF-8'
},
'nativeQuery' => 'q',
'url' => 'http://www.google.com/search?',
'cookies' => 0,
'type' => 'QUERY',
'defaultRequestClass' => undef
};
The first key fieldTranslations is assigned something I can't figure
out and I've had no luck searching (and searching and searching) for
the answer.
(If Google could just include symbols in their indexing life would be
so much better...)
Does the asterisk have any special meaning used like this? Could this
be as mundane as a hash field pointing to a hash field with a single
key that is an asterisk that points to a hash that has... yadda
yadda.. ?
If anyone knows what this:
'fieldTranslations' => {
'*' => {
'*' => '*'
}
},
accomplishes, I'd be greatful for some insight.
Thanks,
Jess
------------------------------
Date: Tue, 23 Nov 2004 08:39:00 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Strange asterisk use in a hash declaration
Message-Id: <zdadnUWtkdHioD7cRVn-tQ@adelphia.com>
Jess Graves wrote:
> If anyone knows what this:
>
> 'fieldTranslations' => {
> '*' => {
> '*' => '*'
> }
> },
>
> accomplishes, I'd be greatful for some insight.
The '*'s are just one-character strings, nothing more. What meaning
those strings might have for the module or for Google, I don't know, but
to Perl they're just strings, nothing special.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Tue, 23 Nov 2004 13:13:49 +0000 (UTC)
From: "Bean" <bcant@centra-systems.com>
Subject: sysread(socket..) problem on perl 5.8.0 linux
Message-Id: <cnvd2c$sr9$1@hercules.btinternet.com>
Hi,
I've been debugging a socket read problem using perl 5.8.0 on RH8.0. The
following script fails consistantly on perl 5.8.0 but works fine on 5.8.3
and 5.8.5. It also works if either side (client or server) is _not_ running
on 5.8.0.
The problem is that the client sysread returns 0 (eof) when the server has
sent data. I've strace'd both sides and the server thinks it has sent 1024
bytes but the client receives nothing and sysread returns 0, strace reports
ESPIPE on the socket fd.
Am I doing something wrong in the code? Could it be a perl bug or maybe a
hardware problem? My different versions of perl are all on different
machines.
Can any one help?
Regards, Ben.
Output:
$ ./sfile.pl server
sent header FILE:2082:1024
server wrote a block 1024 in size
server wrote a block 1024 in size
server wrote a block 34 in size
write total size = 2082
$ ./sfile.pl client
read header FILE:2082:1024
trying to reading 1024
sysread returned 0
read total size = 0
Script:
#!/usr/bin/perl
# -*- perl -*-
use strict;
use warnings;
use IO::Socket::INET;
use IO::File;
$|=1;
server() if $ARGV[0] eq 'server';
client() if $ARGV[0] eq 'client';
sub server
{
my $s = IO::Socket::INET->new
(
LocalPort => 9999,
Listen => 1,
Proto => 'tcp',
Type => SOCK_STREAM,
ReuseAddr => 1,
) || die $!;
$s->autoflush(1);
$s->blocking(1);
while (1)
{
my $n = $s->accept;
write_file($n,$0);
$n->close;
}
}
sub client
{
my $s = IO::Socket::INET->new
(
PeerAddr => 'localhost',
PeerPort => 9999,
Proto => 'tcp',
Type => SOCK_STREAM,
) || die $!;
$s->autoflush(1);
$s->blocking(1);
read_file($s);
$s->close;
}
sub write_file
{
my $s = shift;
my $f = shift;
die unless -f $f;
my $fh = IO::File->new("<$f") || die $!;
my $bs = 1024;
my $sz = (stat($f))[7];
my $ts = 0; # total size written
if ( $sz < $bs )
{
$bs = $sz;
}
my $head = "FILE:$sz:$bs\n";
die "header write failed" if syswrite($s,$head,length($head)) !=
length($head);
print "sent header $head";
while ( $bs )
{
my $buf = '';
my $wr = sysread($fh,$buf,$bs) || die "reading $bs from file: $!";
$ts += $wr;
my $sw = syswrite($s,$buf,$wr);
print "short write!" if ( $sw != $wr );
print "server wrote a block $sw in size\n";
if ( ( $sz - $ts ) < $bs )
{
$bs = $sz - $ts;
}
}
print "write total size = $ts\n";
}
sub read_file
{
my $s = shift;
my $head = $s->getline || die "header read failed";
print "read header $head";
my ($ts, $bs);
if ( $head =~ /FILE\:(\d+)\:(\d+)\n/ )
{
($ts, $bs) = ($1,$2);
}
else
{
die "incorrect header format";
}
my $tr = 0; # total size read
while ($bs)
{
if ( ( $ts - $tr ) < $bs )
{
$bs = $ts - $tr;
}
print "trying to reading $bs\n";
my $buf = '';
my $rd = sysread($s,$buf,$bs);
if ( $rd > 0 )
{
$tr += $rd;
}
else
{
print "sysread returned $rd\n";
last;
}
}
print "read total size = $tr\n";
}
My perl is:
Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
Platform:
osname=linux, osvers=2.4.18-11smp, archname=i386-linux-thread-multi
uname='linux daffy.perf.redhat.com 2.4.18-11smp #1 smp thu aug 15
06:41:59 edt 2002 i686 i686 i386 gnulinux '
config_args='-des -Doptimize=-O2 -march=i386 -mcpu=i686 -Dmyhostname=localhost
-Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red Hat,
Inc. -Dinstallprefix=/usr -Dprefix=/usr -Darchname=i386-linux -Dvendorprefix=/usr
-Dsiteprefix=/usr -Duseshrplib -Dusethreads -Duseithreads -Duselargefiles -Dd_dosuid
-Dd_semctl_semun -Di_db -Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm
-Duseperlio -Dinstallusrbinperl -Ubincompat5005 -Uversiononly -Dpager=/usr/bin/less
-isr'
hint=recommended, useposix=true, d_sigaction=define
usethreads=define use5005threads=undef useithreads=define
usemultiplicity=define
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc', ccflags
='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
-I/usr/include/gdbm',
optimize='-O2 -march=i386 -mcpu=i686',
cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -I/usr/include/gdbm'
ccversion='', gccversion='3.2 20020822 (Red Hat Linux Rawhide 3.2-5)',
gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='gcc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lgdbm -ldb -ldl -lm -lpthread -lc -lcrypt -lutil
perllibs=-lnsl -ldl -lm -lpthread -lc -lcrypt -lutil
libc=/lib/libc-2.2.92.so, so=so, useshrplib=true, libperl=libperl.so
gnulibc_version='2.2.92'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef,
ccdlflags='-rdynamic -Wl,-rpath,/usr/lib/perl5/5.8.0/i386-linux-thread-multi/CORE'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES
PERL_IMPLICIT_CONTEXT
Built under linux
Compiled at Sep 1 2002 23:56:49
@INC:
/usr/lib/perl5/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/5.8.0
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0
/usr/lib/perl5/vendor_perl
.
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 7439
***************************************