[19942] in Perl-Users-Digest
Perl-Users Digest, Issue: 2137 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 15 06:10:54 2001
Date: Thu, 15 Nov 2001 03:10:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1005822613-v10-i2137@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 15 Nov 2001 Volume: 10 Number: 2137
Today's topics:
Re: socket buffering even with $| set (Maurizio Codogno)
Re: socket buffering even with $| set (Maurizio Codogno)
specific array items, loop iterator <sh@planetquake.com>
Re: specific array items, loop iterator <bernard.el-hagin@lido-tech.net>
Re: specific array items, loop iterator <wuerz@yahoo.com>
Re: specific array items, loop iterator <peb@bms.umist.ac.uk>
Re: specific array items, loop iterator <usenet@michnet.de>
Re: specific array items, loop iterator <bernard.el-hagin@lido-tech.net>
Re: specific array items, loop iterator <bernard.el-hagin@lido-tech.net>
Re: specific array items, loop iterator <wuerz@yahoo.com>
URL to TXT problem with tables (Anand Ramamurthy)
Re: URL to TXT problem with tables <s_grazzini@hotmail.com>
Re: using modules in subdirectories with a dash (Mark Jason Dominus)
What do ecommerce authentication and ecommerce security <bigbanana@mailandnews.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 15 Nov 2001 10:00:35 +0100
From: mau@beatles.cselt.it (Maurizio Codogno)
Subject: Re: socket buffering even with $| set
Message-Id: <9t007j$j4l@beatles.cselt.it>
: Output?
:
: There's no socket _output_ in the code you posted, only socket input.
Actually I tried also to modify autoflush for $client, but it turned out
that I overlooked the behaviour of <> in array context.
Thanks, .mau.
--
Tra poco / Coming soon: http://xmau.com/
------------------------------
Date: 15 Nov 2001 10:06:49 +0100
From: mau@beatles.cselt.it (Maurizio Codogno)
Subject: Re: socket buffering even with $| set
Message-Id: <9t00j9$jau@beatles.cselt.it>
Uri Guttman scripsit:
: MC> select ((select($server), $|=1)[0]);
:
: that has no effect on accepted sockets. a server/listener socket never
: does any i/o, it is only used for accepting connections.
Yup, I eventually noticed it and started autoflushing $client, but it was
not sufficient.
: MC> while ($client = $server->accept()) {
:
: IO::Socket now makes sockets unbuffered by default. check your version
: of perl and this module and upgrade if necessary.
Unfortunately I cannot upgrade the system I am working on... eventually I
got the right tip, and this snippet works fine:
while (my $client = $server->accept()) {
# $client is the new connection
$client->autoflush(1);
while(<$client>){
print
}
}
Thanks for your help, .mau.
--
Tra poco / Coming soon: http://xmau.com/
------------------------------
Date: Thu, 15 Nov 2001 09:06:23 GMT
From: "Sean Hamilton" <sh@planetquake.com>
Subject: specific array items, loop iterator
Message-Id: <jALI7.5092$c4.957093@news0.telusplanet.net>
1. Is there a good way to extract only certain items from an array? For
example, if I only want the inode of a file, I can use something like
my $inode = (stat ($file))[1];
However, what if I want the first and ninth item? Must I create a bunch of
dummy variables?
2. I seem to recall reading somewhere about some variable which indicates
the current index in a foreach (@array) loop. Which variable is this?
TiA,
sh
------------------------------
Date: Thu, 15 Nov 2001 09:13:38 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@lido-tech.net>
Subject: Re: specific array items, loop iterator
Message-Id: <slrn9v74ql.3il.bernard.el-hagin@gdndev25.lido-tech>
On Thu, 15 Nov 2001 09:06:23 GMT, Sean Hamilton <sh@planetquake.com> wrote:
> 1. Is there a good way to extract only certain items from an array? For
> example, if I only want the inode of a file, I can use something like
>
> my $inode = (stat ($file))[1];
>
> However, what if I want the first and ninth item? Must I create a bunch of
> dummy variables?
(stat($file))[1,9];
> 2. I seem to recall reading somewhere about some variable which indicates
> the current index in a foreach (@array) loop. Which variable is this?
There's no such variable.
Cheers,
Bernard
------------------------------
Date: 15 Nov 2001 04:20:42 -0500
From: Mona Wuerz <wuerz@yahoo.com>
Subject: Re: specific array items, loop iterator
Message-Id: <m3g07gwfth.fsf@DCCMBX01.njitdm.campus.njit.edu>
"Sean Hamilton" <sh@planetquake.com> writes:
> 1. Is there a good way to extract only certain items from an array? For
> example, if I only want the inode of a file, I can use something like
>
> my $inode = (stat ($file))[1];
>
> However, what if I want the first and ninth item? Must I create a bunch of
> dummy variables?
use a list slice:
my $inode = (stat ($file))[1, 9];
> 2. I seem to recall reading somewhere about some variable which indicates
> the current index in a foreach (@array) loop. Which variable is this?
As far as I recall $# was under consideration for that; how seriously,
I don't know. Currently that is still $OFMT, and to my knowledge no
`current index' variable exists. You'll have to keep count manually.
--
$_="\n,rekcah egnufeB rehtona tsuJ";#v1<?>g\:pv-<5<
s s\S+(?:B)sunpack'u',q q$;')E4qsee;#>60#^<(v!<)g6<
print scalar reverse,$@ unless m,[+;#]55,;m:_,:#^1<
------------------------------
Date: Thu, 15 Nov 2001 09:24:07 +0000
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: specific array items, loop iterator
Message-Id: <3BF389B7.28CC5FEB@bms.umist.ac.uk>
Sean Hamilton wrote:
>
> 1. Is there a good way to extract only certain items from an array? For
> example, if I only want the inode of a file, I can use something like
>
> my $inode = (stat ($file))[1];
>
> However, what if I want the first and ninth item? Must I create a bunch of
> dummy variables?
You can just take an array slice.
my ($inode, $uid, $gid) = (stat ($file))[1, 4, 5];
> 2. I seem to recall reading somewhere about some variable which indicates
> the current index in a foreach (@array) loop. Which variable is this?
I'm not aware of a variable for this purpose.
You can just put in your own index variable.
my $i;
foreach(@array){
#do something
$i++;
}
HTH
Paul
------------------------------
Date: Thu, 15 Nov 2001 10:25:10 +0100
From: Michael Velten <usenet@michnet.de>
Subject: Re: specific array items, loop iterator
Message-Id: <ml10t9.r71.ln@conscious.reno.de>
* Bernard El-Hagin <bernard.el-hagin@lido-tech.net> in clpm:
>> 2. I seem to recall reading somewhere about some variable which
>> indicates the current index in a foreach (@array) loop. Which
>> variable is this?
> There's no such variable.
It's not the index of the iteration but it might be that he means »$_«
to output the current value?
Michael
------------------------------
Date: Thu, 15 Nov 2001 09:28:20 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@lido-tech.net>
Subject: Re: specific array items, loop iterator
Message-Id: <slrn9v75m7.3il.bernard.el-hagin@gdndev25.lido-tech>
On Thu, 15 Nov 2001 10:25:10 +0100, Michael Velten <usenet@michnet.de> wrote:
> * Bernard El-Hagin <bernard.el-hagin@lido-tech.net> in clpm:
>
>>> 2. I seem to recall reading somewhere about some variable which
>>> indicates the current index in a foreach (@array) loop. Which
>>> variable is this?
>> There's no such variable.
>
> It's not the index of the iteration but it might be that he means »$_«
> to output the current value?
I think he meant what he wrote, but even if he didn't $_ is not
a general enough answer because $_ can be anything else you choose.
foreach my $blah (@array){}
Cheers,
Bernard
------------------------------
Date: Thu, 15 Nov 2001 09:28:57 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@lido-tech.net>
Subject: Re: specific array items, loop iterator
Message-Id: <slrn9v75nc.3il.bernard.el-hagin@gdndev25.lido-tech>
On 15 Nov 2001 04:20:42 -0500, Mona Wuerz <wuerz@yahoo.com> wrote:
> "Sean Hamilton" <sh@planetquake.com> writes:
>
>> 1. Is there a good way to extract only certain items from an array? For
>> example, if I only want the inode of a file, I can use something like
>>
>> my $inode = (stat ($file))[1];
>>
>> However, what if I want the first and ninth item? Must I create a bunch of
>> dummy variables?
>
> use a list slice:
>
> my $inode = (stat ($file))[1, 9];
You probably want to assign that to a list, not to a single scalar. :)
Cheers,
Bernard
------------------------------
Date: 15 Nov 2001 04:50:39 -0500
From: Mona Wuerz <wuerz@yahoo.com>
Subject: Re: specific array items, loop iterator
Message-Id: <m3bsi4wefk.fsf@DCCMBX01.njitdm.campus.njit.edu>
Bernard El-Hagin <bernard.el-hagin@lido-tech.net> writes:
> On 15 Nov 2001 04:20:42 -0500, Mona Wuerz <wuerz@yahoo.com> wrote:
>
> > my $inode = (stat ($file))[1, 9];
>
> You probably want to assign that to a list, not to a single scalar. :)
Oh my, the perils of cut'n'paste. You're right of course.
-mona
------------------------------
Date: 14 Nov 2001 19:17:54 -0800
From: anand_ramamurthy@yahoo.com (Anand Ramamurthy)
Subject: URL to TXT problem with tables
Message-Id: <761041e6.0111141917.1bf0d5a6@posting.google.com>
When I covert from URL to TXT the values in a table
come one after the other instead of one next to other.
Eg.
<TABLE>
<tr>
<td id="fieldname" align="right">Product ID:</td>
<td id="fieldvalue" align="left">C7200-8000 </td>
</tr>
becomes:
Product ID:
C7200-8000
instead of Product ID: C7200-8000
The script I am using is:
sub processURL($host_target) {
my $host_target = shift;
my $url;
my $p = HTML::Parser->new(api_version => 3,
handlers => [start => [\&tag, "tagname, '+1'"],
end => [\&tag, "tagname, '-1'"],
text => [\&text, "dtext"],
],
marked_sections => 1,
);
$url="http://www.perl.com";
my $content = get($url) || die "Can't download $url: $!\n";
printf $content;
$p->parse($content);
}
sub tag {
my($tag, $num) = @_;
$inside{$tag} += $num;
}
sub text {
return if $inside{script} || $inside{style};
print $_[0];
}
------------------------------
Date: Thu, 15 Nov 2001 06:04:32 GMT
From: "Steve Grazzini" <s_grazzini@hotmail.com>
Subject: Re: URL to TXT problem with tables
Message-Id: <QVII7.86588$XA5.14715483@typhoon.nyc.rr.com>
"Anand Ramamurthy" <anand_ramamurthy@yahoo.com> wrote in message
news:761041e6.0111141917.1bf0d5a6@posting.google.com...
> When I covert from URL to TXT the values in a table
> come one after the other instead of one next to other.
[... code prints raw text ...]
It's just a parser! If you want formatted tables,
you sort of need to keep track of <tr> and <td> yourself.
Unless...
#!/usr/bin/perl
print `lynx -dump www.perl.com`;
Well, maybe not :)
-Steve
------------------------------
Date: Thu, 15 Nov 2001 05:39:30 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: using modules in subdirectories with a dash
Message-Id: <3bf35511.60f$246@news.op.net>
In article <3BF30570.625A3DE9@earthlink.net>,
Benjamin Goldberg <goldbb2@earthlink.net> wrote:
>Mark Jason Dominus wrote:
>> It doesn't work anyway. Even omitting the spurious : after BEGIN, I
>> get 'Can't locate UNIVERSAL/require.pm in @INC'.
>
>Well, duh. First download them from CPAN, as I said to do in my
>response to your asking this same question in an earlier thread.
You seem to have me confused with someone else.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Wed, 14 Nov 2001 14:41:10 -0000
From: "Big Banana" <bigbanana@mailandnews.com>
Subject: What do ecommerce authentication and ecommerce security mean?
Message-Id: <9sv9mb$ubv$1@news8.svr.pol.co.uk>
Can someone tell me what ecommerce authentication and ecommerce security
mean?
What technologies are we talking about?
I kinda know the answer... but just want a more concrete one.
Thanks.
BB
------------------------------
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 2137
***************************************