[9683] in Perl-Users-Digest
Perl-Users Digest, Issue: 3277 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 28 15:18:37 1998
Date: Tue, 28 Jul 98 12:00:24 -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 Tue, 28 Jul 1998 Volume: 8 Number: 3277
Today's topics:
Re: [Perl] How to find the Perl FAQ <efaiz@idirect.com>
Re: [Q] Regexp, speed, stringsplit (Sean McAfee)
Re: [Q] Regexp, speed, stringsplit (Craig Berry)
bizarre(?) problem, tied hash of tied hashes teletype@my-dejanews.com
Re: blat blues <sponge@iav.com>
Re: bug in lexical array reference? <jpowers@cs.oberlin.edu>
BUG: in POSIX::localeconv() <Stefan.Vogtner@ruhr-uni-bochum.de>
Changes from 5.003_07 to 5.004_04 <krislock@info6.load-otea.hrdc-drhc.gc.ca>
Re: Changes from 5.003_07 to 5.004_04 (M.J.T. Guy)
Re: Counting fork()s. dwiesel@my-dejanews.com
Re: Counting fork()s. (Abigail)
Re: deadlocking sockets faganb@my-dejanews.com
Re: Help reg. exp: shouldn't ^ match at beginning only? (Craig Berry)
Re: Inheritance broken when objects share a file? <tchrist@mox.perl.com>
Misleading documentation (Joe McMahon)
More on pattern matching schnibitz@my-dejanews.com
Re: Nead a Redir Script, Please (Eric Harley)
Re: Net::Telnet -like module without telnet (Eric Harley)
Re: newbie string questions. (Craig Berry)
perl complier for ms dos <sursood@emirates.net.ae>
perl database problem on dec machines (Henryrb)
Perl/X11 CONUNDRUM kj0@mailcity.com
Re: sending mail from within perl <newsonly@usa.net>
Re: Sorting for Uniques <tchrist@mox.perl.com>
Wanted AWK To Perl Translater A2P.exe for cygnus/WIN32 <noone@nowhere.com>
WANTED: Perl Autoreponder - Any Takers? (David Deutsch)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 28 Jul 1998 14:39:19 -0700
From: Ejaz <efaiz@idirect.com>
Subject: Re: [Perl] How to find the Perl FAQ
Message-Id: <35BE4507.5A4E@idirect.com>
Tom Phoenix wrote:
>
> Archive-name: perl-faq/finding-perl-faq
> Posting-Frequency: weekly
> Last-modified: 18 May 1998
>
> [ That "Last-modified:" date above refers to this document, not to the
> Perl FAQ itself! The last major update of the Perl FAQ was in Spring of
> 1997; of course, ongoing updates are made as needed. ]
>
> For most people, this URL should be all you need in order to find Perl's
> Frequently Asked Questions (and answers).
>
> http://cpan.perl.org/doc/FAQs/
>
> Please look over (but never overlook!) the FAQ and related docs before
> posting anything to the comp.lang.perl.* family of newsgroups.
>
> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
>
> Beginning with Perl version 5.004, the Perl distribution itself includes
> the Perl FAQ. If everything is pro-Perl-y installed on your system, the
> FAQ will be stored alongside the rest of Perl's documentation, and one
> of these commands (or your local equivalents) should let you read the FAQ.
>
> perldoc perlfaq
> man perlfaq
>
> If a recent version of Perl is not properly installed on your system,
> you should ask your system administrator or local expert to help. If you
> find that a recent Perl distribution is lacking the FAQ or other important
> documentation, be sure to complain to that distribution's author.
>
> If you have a web connection, the first and foremost source for all things
> Perl, including the FAQ, is the Comprehensive Perl Archive Network (CPAN).
> CPAN also includes the Perl source code, pre-compiled binaries for many
> platforms, and a large collection of freely usable modules, among its
> 560_986_526 bytes (give or take a little) of super-cool (give or take
> a little) Perl resources.
>
> http://cpan.perl.org/
> http://www.perl.com/CPAN/
> http://cpan.perl.org/doc/FAQs/FAQ/html/perlfaq.html
> http://www.perl.com/CPAN/doc/FAQs/FAQ/html/perlfaq.html
>
> You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
> you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
> selected FTP sites is especially good for you, a full list of CPAN sites
> is in the SITES file within CPAN.)
>
> California ftp://ftp.cdrom.com/pub/perl/CPAN/
> Texas ftp://ftp.metronet.com/pub/perl/
> South Africa ftp://ftp.is.co.za/programming/perl/CPAN/
> Japan ftp://ftp.dti.ad.jp/pub/lang/CPAN/
> Australia ftp://cpan.topend.com.au/pub/CPAN/
> Netherlands ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
> Switzerland ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
> Chile ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/
>
> If you have no connection to the Internet at all (so sad!) you may wish
> to purchase one of the commercial Perl distributions on CD-Rom or other
> media. Your local bookstore should be able to help you to find one.
> Another possibility is to use one of the FTP-via-email services; for
> more information on doing that, send mail to <mail-server@rtfm.mit.edu>
> (not to me!) with these lines in the body of the message, flush left:
>
> setdir usenet-by-group/news.announce.newusers
> send Anonymous_FTP:_Frequently_Asked_Questions_(FAQ)_List
>
> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
>
> Comments and suggestions on the contents of this document
> are always welcome. Please send them to the author at
> <pfaq&finding*comments*@redcat.com>. Of course, comments on
> the docs and FAQs mentioned here should go to their respective
> maintainers.
>
> Have fun with Perl!
>
> --
> Tom Phoenix Perl Training and Hacking Esperanto
> Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 28 Jul 1998 17:03:26 GMT
From: mcafee@choplifter.rs.itd.umich.edu (Sean McAfee)
Subject: Re: [Q] Regexp, speed, stringsplit
Message-Id: <yvnv1.5562$24.32614039@news.itd.umich.edu>
In article <i6qaf5u9bnd.fsf@pvv.org>,
Frode Stenstrxm <frodeste+news@pvv.org> wrote:
>What's the fastest way to splitt a string (eg. "John-F M. F Doe")
>to two variables like firstname and lastname ($lastname="Doe")?
>I've fiddled with split
>($first, $last) = split (/\s+/, $string, 2);
>But this does not quite give me what I want. Two rules apply:
>1. Space is the only seperator
>2. Last word in string is _always_ $last (name).
That's what the Benchmark module is for:
----------------------------------------------------------------------
use Benchmark;
$name = "John-F M. F Doe";
timethese(1_000_000, {
Regex => sub { my ($first, $last) = $name =~ /(.*) (.*)/; },
Index => sub { my ($first, $last, $i); $i = rindex($name, " ");
$first = substr($name, 0, $i); $last = substr($name, $i + 1); }
});
----------------------------------------------------------------------
Benchmark: timing 1000000 iterations of Index, Regex...
Index: 58 secs (53.92 usr 0.00 sys = 53.92 cpu)
Regex: 76 secs (69.28 usr 0.01 sys = 69.29 cpu)
--
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
| K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
| tv+ b++ DI++ D+ G e++>++++ h- r y+>++** | umich.edu
------------------------------
Date: 28 Jul 1998 17:49:43 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: [Q] Regexp, speed, stringsplit
Message-Id: <6pl2vn$n0e$3@marina.cinenet.net>
Frode Stenstrxm (frodeste+news@pvv.org) wrote:
: What's the fastest way to splitt a string (eg. "John-F M. F Doe")
: to two variables like firstname and lastname ($lastname="Doe")?
Fastest way depends on your data, the particulars of your definition, and
other factors.
: I've fiddled with split
: ($first, $last) = split (/\s+/, $string, 2);
:
: But this does not quite give me what I want. Two rules apply:
Yes, that will fail in lots of cases, including your example string.
: 1. Space is the only seperator
: 2. Last word in string is _always_ $last (name).
Taking 'word' to mean \w+ (feel free to add allowed characters if you need
a broader definition), here's how I'd do it:
($first, $last) = $string =~ /(.*) (\w+) *$/;
That causes .* to eat the entire string, then backtracks far enough to
find a space followed by some word chars, followed by optional space (just
for insurance) then end-of-string.
Note that everything except the final word, the space just before it, and
any spaces after it will all get lumped into $first.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Tue, 28 Jul 1998 18:30:08 GMT
From: teletype@my-dejanews.com
Subject: bizarre(?) problem, tied hash of tied hashes
Message-Id: <6pl5bh$dqt$1@nnrp1.dejanews.com>
I am having what I think is a bizarre problem. I have a HoH and I am trying
to tie it. Now, I know that tie will not do this. All of the keys of the top
level hash are known, so what I did was to inititialise these keys within my
TIEHASH function. I create pointers to the hashes within the toplevel hash,
and I tie those. It will probably make much more sense if you view the source
below.
package HostDB;
$debug=1;
sub TIEHASH {
my ($class, $dbfile)=@_;
my $self={};
print "TIEHASH: $self\n" if $debug;
open(DB, "<$dbfile");
my @hostlines=grep(/^host\s/, <DB>);
foreach $_ (@hostlines) {
my($keyword,$host,@rest)=split;
#$self{$host}={};
#print "TYING $self{$host}\n";
#i tie the hashes right here... tie(%{$self{$host}}, "HostDB::Sublevel",
$dbfile, $host); #and i poke some values into them that i need for later
$self{$host}{__DBFILE__}=$dbfile; $self{$host}{__PARENT__}=$host;
#$self{$host}=%newhash; #$self{$host}=$blah; #$self{$host}=$blah;
#$blah=\%newhash; print "host: $host hostptr: $self{$host}
$self{otherhost}->{__PA RENT__}\n"; }
return bless $self;
}
#fetch a value
sub FETCH {
my ($self, $key)=@_;
print "FETCH1: Self=$self Key=$key\n";
#foreach $ref (keys %{$self{$key}}) {
#print "REF: $ref $self{$key}{$ref}\n";
#}
return $self{$key};
}
sub STORE {
my ($self, $key, $val)=@_;
print "here in STORE\n";
$self{$key}=$val;
}
package HostDB::Sublevel;
$debug=1;
sub TIEHASH {
my ($class, $dbfile, $parent)=@_;
my $self={};
#$self{__DBFILE__}=$dbfile;
#$self{__PARENT__}=$parent;
print "TIEHASH2: $self $parent\n" if $debug;
return bless $self, $class;
}
sub FETCH { my ($self, $key)=@_; print "FETCH2: Self=$self Key=$key
DBFile=$self{__DBFILE__} Parent=$self {__PARENT__} val: $self{$key}\n";
#foreach $ref (keys %self) { #print "REF2: $ref $self{$ref}\n"; #}
$self{$key}; }
sub STORE {
my ($self, $key, $val)=@_;
print "STORE2: Self=$self Key=$key Val=$val Old=$self{$key}\n";
$self{$key}=$val;
}
OK. Now the problem is this: When I run this, it creates the HoH just fine.
As you can see, I put lots of prints in here to track what is happening with
my data. The HoH is created just fine, and each hash has a unique pointer. I
am able to dereference these pointers, and put data into the hash. The
problem is, when I later try to use this data, I discover that any of the
hashes I read from contains the same data! (whatever was put into the last
hash)
Like so:
#!/usr/local/bin/perl
use lib '.';
use HostDB2;
tie(%hostdb, "HostDB", "hostdb.txt");
$hostdb{otherhost}{ipaddr}="127.0.0.1";
print "RESULT: $hostdb{otherhost}{ipaddr}\n";
(the important parts of the) output:
TIEHASH: HASH(0x2001b5e0) #hash is created
#this shows that the "child" hash, 0x2006911c is created, and that this data
was #stored in it
#here, a "child" hash is created and tied. notice the pointer address.
TIEHASH2: HASH(0x20069110) testhost #i set some values STORE2:
Self=HostDB::Sublevel=HASH(0x20069110) Key=__DBFILE__ Val=hostdb.txt Old =
STORE2: Self=HostDB::Sublevel=HASH(0x20069110) Key=__PARENT__ Val=testhost
Old= host: testhost hostptr: HASH(0x20069104) #now, another "child" hash is
created and tied. TIEHASH2: HASH(0x2006911c) otherhost #now, when these
values are being stored, notice that they *already exist* #and that the data
is that from the previous hash. Yet the pointers are unique. STORE2:
Self=HostDB::Sublevel=HASH(0x2006911c) Key=__DBFILE__ Val=hostdb.txt Old
=hostdb.txt STORE2: Self=HostDB::Sublevel=HASH(0x2006911c) Key=__PARENT__
Val=otherhost Old= testhost FETCH2: Self=HostDB::Sublevel=HASH(0x2006911c)
Key=__PARENT__ DBFile=hostdb.txt Parent=otherhost val: otherhost host:
otherhost hostptr: HASH(0x2006914c) otherhost
Why is this behaving this way? I am stumped. Is this a bug, or have I done
something entirely wrong?
TIA,
Rob King
robert.m.king@fmr.com
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Tue, 28 Jul 1998 07:35:25 -1000
From: "Neal Miyake" <sponge@iav.com>
Subject: Re: blat blues
Message-Id: <6pl2ce$qqj@enews2.newsguy.com>
Just as a followup: Got it! I had the Exchange/PDC server and the IIS
server DNS configured. After clearing that out and rebooting, it works
fine--email bangs through in no time flat. During blat install, I set the
SMTP server to the computername. I guess WINS took care of finding it
without going through a DNS search.
Thank you, to all who assisted.
Neal
Neal Miyake wrote:
>Been porting over some unix perl scripts to NT4 Servers running Exchange
>5.5, IIS4 and Perl for Win32. Am trying to send mail via command line, and
>was told to try blat.
>
>Blat works great... sometimes. For some reason, it takes a really long
>time before the command runs, maybe two minutes. The command usually
>timeouts before it can send the message.
>
>Part of the problem may lie in the way the Exchange server was configured.
>The lan uses Microsoft Network to identify the components, so the dns
>service is not enabled. As for Exchange, the SMTP addressing is not like a
>typical dns address.
>
>Usually, you set up blat with this install line:
>blat -install SMTPserver.blah.com userid@SMTPserver.blah.com
>
>I've tried many configs, but the only way I could get it to work is:
>blat -install NTcomputername userid@domainname.fakedomain.com
>
>where the Exchange server recognizes SMTP addressing as
>domainname.fakedomain.com.
>
>As mentioned before, most of the time, the command timeouts. However,
>sometimes the message actually is sent correctly. I'm guessing that it's
>having problems finding the server since it is not a typical dns name. Any
>suggestions or solutions would be greatly appreciated. Please also copy a
>reply to sponge@iav.com. Thank you very much in advance.
>
>Neal
------------------------------
Date: Tue, 28 Jul 1998 14:37:34 -0400
From: Joshua Powers <jpowers@cs.oberlin.edu>
To: ts <decoux@moulon.inra.fr>
Subject: Re: bug in lexical array reference?
Message-Id: <Pine.ULT.3.96.980728143457.2623P-100000@occs.cs.oberlin.edu>
Are you sure about that? I am using "strict 'vars'", and it does not give
a compilation error. If @old_vals is indeed a package variable, it should
force me to qualify it. Besides, I don't see why one way of writing it
should produce different behavior from another way of writing it.
On 28 Jul 1998, ts wrote:
> >>>>> "J" == Joshua Powers <jpowers@cs.oberlin.edu> writes:
>
> J> The interesting thing (which I just discovered) is that this does not
> J> happen if I rewrite the code which writes @old_vals as follows:
> J> {
> J> my @old_vals;
> J> if (defined ($caller->{"old\037values"})) {
> J> @old_vals = @{$caller->{"old\037values"}};
> J> }
> J> ...
> J> (etc.)
>
> There is a difference, in the previous example @old_vals is *always* a
> my() variable
>
>
> J> It seems that if I say:
>
> J> my @old_vals = @{$caller->{"old\037values"}} if defined
> J> ($caller->{"old\037values"});
>
> Now @old_vals is a my() variable *only* if defined($caller->...)
> otherwise this is a package variable.
>
> --
>
> Guy Decoux
>
-_-^-_-^-_-^-_-^-_-^-_-^-_-^-_-^-_-^-_-^-_-^-_-^-_-^-_-^-_-^-_-^-_-^-_-^-_-^-_-
Josh Powers - jpowers@cs.oberlin.edu
http://www.cs.oberlin.edu/~jpowers
------------------------------
Date: Tue, 28 Jul 1998 20:24:50 +0200
From: Stefan Vogtner <Stefan.Vogtner@ruhr-uni-bochum.de>
Subject: BUG: in POSIX::localeconv()
Message-Id: <35BE1771.EBFC0939@ruhr-uni-bochum.de>
Today I found a bug (?) in the POSIX::localeconv function running
perl, version 5.004_03 on Linux 2.0.30 i586 (Slackware 3.2). Here's the
code:
#!/usr/bin/perl -w
use strict;
use POSIX;
setlocale (LC_ALL, "de_DE"); # or other locale with "," as decimal sep
my $x = 3.14;
printf ("%7.3f\n", $x); # prints 3,14
my $lc;
$lc = localeconv ();
printf ("%7.3f\n", $x); # should print 3,14
it yields on my system:
3,140
3.140
It seems that the systems "forgets" about the locale settings after
calling localeconv. Previous versions of perl produce the correct
results.
BTW: If running scripts with "-w" and using a locale setting with "," as
the decimal separator Perl loudly complains about every number which
was read in (<>) and is uses the first time in arith operations though
the correct results are produced.
Any suggestions?
--
Stefan Vogtner
------------------------------
Date: Tue, 28 Jul 1998 17:20:08 GMT
From: Nathan Krislock <krislock@info6.load-otea.hrdc-drhc.gc.ca>
Subject: Changes from 5.003_07 to 5.004_04
Message-Id: <Pine.LNX.3.96.980728122042.21396A-100000@info6.load-otea.hrdc-drhc.gc.ca>
Hi, I was wondering if anyone knows of a list of changes made from Perl
5.003_07 to Perl 5.004_04. I'm interested because a program I wrote works
great with 5.003_07, but has problems when run with 5.004_04.
Thank you.
- nathan
------------------------------
Date: 28 Jul 1998 17:53:34 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Changes from 5.003_07 to 5.004_04
Message-Id: <6pl36u$c6k$1@pegasus.csx.cam.ac.uk>
Nathan Krislock <krislock@info6.load-otea.hrdc-drhc.gc.ca> wrote:
>
>Hi, I was wondering if anyone knows of a list of changes made from Perl
>5.003_07 to Perl 5.004_04. I'm interested because a program I wrote works
>great with 5.003_07, but has problems when run with 5.004_04.
See perldoc perldelta.
There are also much more exhaustive / exhausting lists of changes in the
various Changes* files in the distribution.
Mike Guy
------------------------------
Date: Tue, 28 Jul 1998 17:26:09 GMT
From: dwiesel@my-dejanews.com
Subject: Re: Counting fork()s.
Message-Id: <6pl1jh$7cd$1@nnrp1.dejanews.com>
Hi again, and thank you!
Just one question. Doesn't the counter $started_forks get incremented even if
the fork fails? If so, then the loop will always go $number_of_forks times.
The purpose was to make sure that there *always* is $number_of_forks forks,
even if one or more fails.
// Daniel
> There are several problems with your program. First, "$started_forks ++"
> only happens *after* fork(), which means that every child gets the
> original value of $started_forks. Hence, there will always be a child
> who has $started_forks == 0. Second, (and this makes the first thing so
> bad), the 'if ($pid == 0) {}' part is *inside* the 'if ($pid = fork)'
> part. Hence, that will never be executed - no child will ever reach the
> 'exit 0'. Third, the '$started_forks <= $number_of_forks' is wrong;
> that should be '$started_forks < $number_of_forks'.
>
> #!/usr/local/bin/perl -w
>
> use strict;
>
> my $number_of_forks = 5;
> my $started_forks = 0;
> my $finished_forks = 0;
>
> $SIG {CHLD} = sub { wait;
> $finished_forks ++;
> warn "$$ reaped a child (finished: $finished_forks)\n";
> };
>
> while ($started_forks < $number_of_forks) {
> $started_forks ++;
> my $pid = fork;
> if ($pid) {
> warn "$$ forked process $pid (started: $started_forks)\n";
> }
> else {
> if (defined $pid) {
> warn "Child stuff by $$\n";
> }
> else {
> warn "Fork by $$ failed\n";
> }
> exit;
> }
> }
>
> while ($finished_forks != $number_of_forks) {sleep 1;}
>
> warn "$$: Terminating\n";
>
> __END__
> --
> perl5.004 -wMMath::BigInt -e'$^V=new
Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|
838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=
@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'
>
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 28 Jul 1998 18:27:21 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Counting fork()s.
Message-Id: <6pl569$i89$2@client3.news.psi.net>
dwiesel@my-dejanews.com (dwiesel@my-dejanews.com) wrote on MDCCXCII
September MCMXCIII in <URL: news:6pl1jh$7cd$1@nnrp1.dejanews.com>:
++
++ Just one question. Doesn't the counter $started_forks get incremented even if
++ the fork fails? If so, then the loop will always go $number_of_forks times.
++ The purpose was to make sure that there *always* is $number_of_forks forks,
++ even if one or more fails.
If you want to do that, then move the '$started_forks ++;' inside
the 'if ($pid)' part. Just make sure that if $pid is false, you
will reach 'exit' before reaching 'fork' again.
Abigail
--
perl -wleprint -eqq-@{[ -eqw\\- -eJust -eanother -ePerl -eHacker -e\\-]}-
------------------------------
Date: Tue, 28 Jul 1998 16:50:20 GMT
From: faganb@my-dejanews.com
Subject: Re: deadlocking sockets
Message-Id: <6pkvgc$54n$1@nnrp1.dejanews.com>
In article <7x4sw2f6wr.fsf@fidelio.vcpc.univie.ac.at>,
Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at> wrote:
> Re: deadlocking sockets, faganb <faganb@my-dejanews.com>
> said:
>
> faganb> I am trying to write a c/s app using sockets and
> faganb> developing my own application level protocol. I
> faganb> can't send and receive on the socket without
> faganb> deadlocking. Does anyone have a more extensive
> faganb> example of a send-receive-send scenario? I've got
> faganb> camel, llama, and leopard to no avail. I'm missing
> faganb> something obvious.
>
> Have you tried the Net::Cmd and IO::Socket modules?
>
> hth
> tony
> --
> Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
> Liechtensteinstrasse 22, A-1090 Wien, AT | <URI:http://www.vcpc.univie.ac.at/>
> "You see? You see? Your stupid minds! | personal email:
> Stupid! Stupid!" ~ Eros, Plan9 fOS. | tony_curtis32@hotmail.com
>
This should clarify. These examples were taken from one (many?) sources
including Robin Chatterjee, Perl docs, "camel", etc.
Server
======
use IO::Socket;
$sock = new IO::Socket::INET (LocalHost => 192.64.104.143,
LocalPort => 54723,
Proto => 'tcp',
Listen => 5,
Reuse => 1);
die "Socket could not be created. Reason $!" unless $sock;
while ($new_sock = $sock->accept())
{
while (defined($buf = <$new_sock>))
{
# this splits the attribute=value pairs
@pair = split (/=/, $buf);
$len_pair = @pair;
# this prints the attribute + value on separate lines
for ($i=0; $i < $len_pair; $i++)
{
print "@pair[$i]\n";
}
#This is _supposed_ to reply to client if it receives value "TEST"
# if (@pair[1]!="TEST")
# {
# select($new_sock); $| = 1; select(STDOUT);
# print $new_sock "RECVD=TEST\n";
# }
}
}
close ($sock);
Client
======
#tcp-client
( $them, $port ) = @ARGV;
$port = 54723;
$them = 'localhost';
$AF_INET = 2;
$SOCK_STREAM = 1;
$SIG{'INT'} = 'dokill';
sub dokill {
kill 9,$child if $child;
}
$sockaddr = 'S n a4 x8';
#chop($hostname = `hostname`);
($name,$aliases,$proto) = getprotobyname('tcp');
($name,$aliases,$port) = getservbyname($port,'tcp')
unless $port =~ /^\d+$/;;
($name,$aliases,$type,$len,$thisaddr) = gethostbyname($hostname);
($name,$aliases,$type,$len,$thataddr) = gethostbyname($them);
$this = pack($sockaddr, $AF_INET, 0, $thisaddr);
$that = pack($sockaddr, $AF_INET, $port, $thataddr);
if (socket(S, $AF_INET, $SOCK_STREAM, $proto)) {
print "socket ok\n";
}
else {
die $!;
}
if (bind(S, $this)) {
print "bind ok\n";
}
else {
die $!;
}
if (connect(S,$that)) {
print "connect ok\n";
}
else {
die $!;
}
select(S); $| = 1; select(STDOUT);
# Send attribute=value pair for TEST
print S "HELLO=TEST\n";
#This is _supposed_ to read the response from the server and print it out
#but it hangs and never prints it out
while ($resp = <S>)
{
print STDOUT "resp=$resp\n";
}
close (S);
exit;
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 28 Jul 1998 17:18:23 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Help reg. exp: shouldn't ^ match at beginning only?
Message-Id: <6pl14v$n0e$2@marina.cinenet.net>
M.J.T. Guy (mjtg@cus.cam.ac.uk) wrote:
: In article <6pjb9k$7u0$1@nnrp1.dejanews.com>, <cortez@ali.com.au> wrote:
: >...........................................
: >$s = 'This is a test line';
: >$s =~ /^([^ ]* )*/;
: >print $1, "\n";
: >...........................................
: >
: >The script above will give:
: >test
: >
: >Isn't ' ^ ' suppossed to match at the beginning of the string only?
:
: Not when it's inside []. Then it negates the character class.
Yes, but he has one *outside* the [] as well, which is (I believe) what
he was asking about.
: Here's a regular expression with three different meanings for ^ :
:
: m/^[^^]/;
Cute.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 28 Jul 1998 16:59:06 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Inheritance broken when objects share a file?
Message-Id: <6pl00q$3f9$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, Karmadon@my-dejanews.com writes:
:Am I wrong assuming it as a bug?
Yup. The only bug is your understanding of @ISA, I fear. :-(
--tom
--
s = (char*)(long)retval; /* ouch */
--Larry Wall in doio.c from the perl source code
------------------------------
Date: Tue, 28 Jul 1998 13:38:59 -0400
From: joe.mcmahon@gsfc.nasa.gov (Joe McMahon)
Subject: Misleading documentation
Message-Id: <joe.mcmahon-2807981338590001@prtims.stx.com>
Note: I am NOT asking a question, but pointing out what I feel is an
ambiguous meaning, or perhaps an oversight, in a Perl error message.
Please do not write me with how to fix this; read carefully, and you'll
see that I already DID fix it.
I was faced with this message yesterday:
Can't locate object method "definitely_there" via package "A_Package"
when calling an instance method in Package_B that wanted to call the
"definitely_there" method in Package_A. An identically-written call, in a
class method in this Package_B, to the same "definitely_there" method in
A_package, worked fine.
Okay, so I dutifully check the source of A_Package. Not a problem,
"definitely_there" is there. I check the spellings in Package_B. No
problem. I look at the debug output - the definitely_there() call in the
Package_B class method worked fine, but the call in the instance method
didn't. Eh?
I go to the perldiag manpage. It says, re this message:
(F) You called a method correctly, and it correctly indicated a package
functioning as a class, but that package doesn't define that particular
method, nor does any of its base classes. See the perlobj manpage.
So I look at A_Package again. No, it's definitely there. I spend a fair
amount of time looking at this before it hits me. No, I couldn't have done
that. I look. Yep, I did.
I didn't put in "use A_Package" in Package_B. The routine which called the
class method in Package_B, however, *had* already done so, so apparently
it could find the method.
I'd like to propose a clarification of this message:
Can't locate object method "%s" via package "%s"
is fine when the package is known in this namespace, but the message
should read something like
Object method "%s" was called in package "%s" not known in this namespace
or something similar. Either that, or the expansion of the explanation to
add a reminder that this message can occur when the package has not been
made accessible in the current namespace.
--- Joe M.
------------------------------
Date: Tue, 28 Jul 1998 18:05:35 GMT
From: schnibitz@my-dejanews.com
Subject: More on pattern matching
Message-Id: <6pl3tf$bat$1@nnrp1.dejanews.com>
Hi all, Below is a little script I wrote that will read in a file and look
for certain patterns. What I want it to do is read in a page of html called
"rogue.html." I specifically infected this page with harmful javascript. I
want the script to recognize keywords within the context of a javascript,
embedded in the html of "rogue.html." Hope that made sense. Anyhow, I want
it to delete the entire javascript, if a certain pattern like "file:" is
found. It works great if there is only one script on the page, but if there
are several scripts, it sometimes deletes the wrong script. Is there any way
to make sure it deletes only the script(s) with the patterns/keywords and
leaves the others untouched? Any advice would be greatly appreciated.
~Prime
____________________________script_______________
#!/usr/local/bin/perl -w
use strict;
my $file = 'rogue.html'; open(INFO, $file) or die "Couldn't open $file. $!";
while (<INFO>) { if (/date/i) { # This checks for header info that a server
# would normally send. { local $/; $_ = <INFO>; } # If the header starts
with date, slurp up # the file so that it is not read line-by- # line. if
(/[<]script.*file:.*script[>]/i) {# If the "file:" pattern appears in the JS,
s!<script\s.*?</script>!!is; # delete the entire script. Problem is, # how
do I make sure that it only delets # the harmful script, and not the others?
if (/embed SRC="file.{150,}/) { s!embed!!is; } } print $_; } else { print
$_; } } __END__
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Tue, 28 Jul 1998 10:13:27 -0700
From: eharley@pacbell.net (Eric Harley)
Subject: Re: Nead a Redir Script, Please
Message-Id: <eharley-2807981013270001@ppp-207-214-149-248.snrf01.pacbell.net>
In article
<eharley-2707981629580001@ppp-207-214-149-155.snrf01.pacbell.net>,
eharley@pacbell.net (Eric Harley) wrote:
>
>[Shameless proposition snipped]
>
Sorry about that. I didn't mean to send that to the newsgroup.
Eric
eharley@pacbell.net
------------------------------
Date: Tue, 28 Jul 1998 10:17:13 -0700
From: eharley@pacbell.net (Eric Harley)
Subject: Re: Net::Telnet -like module without telnet
Message-Id: <eharley-2807981017130001@ppp-207-214-149-248.snrf01.pacbell.net>
> I'm using Net::Telnet module now to execute commands on another computer.
> I don't need to log onto another computer any more, I can use the same
> computer where the script is located.
> I'd like to use similar method in executing programs, that is used in
> Net::Telnet module.
> Can anybody help me with this?
> Expect?
>
#!/usr/local/bin/perl
use Shell;
ls('-lr'); #Generate directory listing.
--
Eric Harley
Freelance Programmer
You need it done, I'm your man.
eharley@pacbell.net
http://burn.victim.com/~eharley
------------------------------
Date: 28 Jul 1998 17:00:04 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: newbie string questions.
Message-Id: <6pl02k$n0e$1@marina.cinenet.net>
Michael Maraist (maraism@sterlingdi.com) wrote:
: Simple enough.. Just require that a sentence be defined as a line of
: characters followed by a period and two spaces. That's how I've always
: been taught at least.. Then you could do something like.
:
: $para =~ s/^(.*?\.) .*$/$1/;
I think
$para =~ s/\. .*/./;
is a better choice. No non-greediness, no capturing parens.
: Maybe it could be cleaned up a bit, since the non-greedy .*? will go
: pretty slow, and the entry and exiting of the parenthesis will occur
: rather often.
Yes. It's also needlessly complicated. I find it a useful rule of thumb
that s/// to eliminate stuff from a string often works better by defining
what you *don't* want and turning it into an empty string, rather than
defining what you *do* want, capturing it, and subsituting with just the
captured portion.
: This could work too, but supposedly, it messes up perls internal reg-ex
: optimization for the whole script:
:
: $x =~ /^.*?\. /;
: $x = $&;
:
: Hmm, how about this:
:
: $x =~ /\. /;
: $x = $` . ".";
Use of $` and $' have the same global performance penalties as $&.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Tue, 28 Jul 1998 20:18:38 +0400
From: sursood <sursood@emirates.net.ae>
Subject: perl complier for ms dos
Message-Id: <35BDF9DE.634C4B2@emirates.net.ae>
i don't have access to cgi-bin directory or perl on my server can i try
the scripts on my stand alone machine?
suruchi
------------------------------
Date: 28 Jul 1998 17:22:40 GMT
From: henryrb@aol.com (Henryrb)
Subject: perl database problem on dec machines
Message-Id: <1998072817224000.NAA15522@ladder03.news.aol.com>
Hi, I tried running both perl 5.004_01 and 5.004_04 on our dec machine (OSF1
V4.0 564 Alpha), and whenever the perl scripts try to do dbaccess, either it
gets null values or causes memory faults. Dec does not support perl, according
to our help desk. What can I do? Is there an OS patch or some trick to make
perl db access work?
Henry
------------------------------
Date: 28 Jul 1998 17:46:04 GMT
From: kj0@mailcity.com
Subject: Perl/X11 CONUNDRUM
Message-Id: <6pl2os$jd8@news1.panix.com>
I've racked my brain over this one, but I can't come even close to a
solution: how to fork a child on its own xterm (or xwsh, etc.)
window, while retaining the possibility of 2-way communication between
child and parent. Many processes take over a window (e.g. ftp,
telnet, gnuplot, youNameIt); it would be **extremely** useful to be
able to swawn one such process in its own window so as not to
interfere with the user's ability to communicate with the parent
processes via STDIN/STDOUT, and such that the parent can still
communicate with the child. Is there any way to do this in Perl?
Thanks in advance,
K.
------------------------------
Date: Tue, 28 Jul 1998 18:33:40 GMT
From: "Bob L." <newsonly@usa.net>
Subject: Re: sending mail from within perl
Message-Id: <8Qov1.17$zu.221717@proxye1.nycap.rr.com>
Thanks. I did this and I got the code to work. Thank you.
Bob
Ray McVay <rmcvay@acm.org> wrote in message 35BD37FA.AE55BC8E@acm.org...
>Bob L. wrote:
>> I tried to use it but I get "Document Contains No Data". I looked in the
>> Perl directory and found other Net: types but not SMTP. Do I have to
get
>> the SMTP module? I was told it would be part of Perl. I'm using the
latest
>> version from activestate.
>
>That's your problem. Toss the Activestate Perl and get the standard
>Perl 5.004, the GS port. I've done both SMTP and MAPI/Exchange mail
>with it.
>
>--
>
>Ray
>
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>+ "All the world is but a play. Be thou the joyful players." +
>+ Maya - Incredible String Band +
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>
------------------------------
Date: 28 Jul 1998 17:03:03 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Sorting for Uniques
Message-Id: <6pl087$3f9$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, "George H" <george@tapestry.net> writes:
:Is there an easy way to sort an array for uniques?
You mean beyond the way described in the standard pelrfaq4 manpage? :-)
--tom
--
Think of your family tonight. Try to crawl home after the
computer crashes.
------------------------------
Date: Tue, 28 Jul 1998 10:52:23 -0600
From: Paul Neth <noone@nowhere.com>
Subject: Wanted AWK To Perl Translater A2P.exe for cygnus/WIN32
Message-Id: <35BE01C6.41090CEC@nowhere.com>
Can someone give me the location of where I could download the A2P awk
to perl translater. I cannot find one where I have been looking. I
dont have it with the cygnus GNU awk distribution V3.03.
Please tell me where I can download the executable or source code to
compile. I would prefer the executable.
Thanks in advance
Paul
------------------------------
Date: Tue, 28 Jul 1998 17:43:48 GMT
From: david@completehost.com (David Deutsch)
Subject: WANTED: Perl Autoreponder - Any Takers?
Message-Id: <35be0c8a.251026787@news.supernews.com>
I'm in need of a perl based autoreponder that is called from the
/etc/aliases file. It will be ran under Linux with Sendmail 8.9.x and
must perform the following functions:
1) Forward orginal message to a specified recipient
2) Send a reply to author based on content from a text file
3) Change the replyto, from, and subject to a specified
setting...
4) Must not allow the from and replyto to be set to the
address of the auoresponder itself (will be passed as a var)
I need this ASAP, I doubt it should take more than an hour or two,
please send qutoes/questions/rates to me privately at
david@completehost.com .
--David Deutsch
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3277
**************************************