[17967] in Perl-Users-Digest
Perl-Users Digest, Issue: 127 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 23 14:05:38 2001
Date: Tue, 23 Jan 2001 11:05:14 -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: <980276713-v10-i127@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 23 Jan 2001 Volume: 10 Number: 127
Today's topics:
Re: [OT] Italic fonts too big (David H. Adler)
Adobe Acrobat Support . . . ameendausha@my-deja.com
Re: Adobe Acrobat Support . . . <cublai@earthlink.net>
ANNOUNCE: Perl-OOP by classgen 3.03 <Michael.Schlueter@philips.com>
Re: Behaviour of __PACKAGE__ inside eval nobull@mail.com
Borland Paradox db dumper <peckert@epicrealm.com>
Re: Catching warnings from Getopt::Std (Anno Siegel)
Re: Catching warnings from Getopt::Std <james@NOSPAM.demon.co.uk>
Re: Getopt::Long question? <remi@multiweb.nl>
Re: hash table <boussard@my-deja.com>
Installing ActivePerl 5.6 on Linux/Apache shared websit wheels_ohio@my-deja.com
Re: kill -HUP only works once (Abigail)
Re: Newbie question : Read configuration file. <brannon@lnc.usc.edu>
Re: Non Unix user needs help with File::Find sjamiso@my-deja.com
open web site with virtual users mike_solomon@lineone.net
Re: open web site with virtual users egwong@netcom.com
Passing parameters to a script (Miguel Manso)
Re: Passing parameters to a script <james@NOSPAM.demon.co.uk>
Re: Perl Crashes on my Win2k Box <skx@tardis.ed.ac.uk>
Re: Q: socket communication between perl and java time4tea@my-deja.com
Re: Random Numbers with a Twist (Abigail)
Re: s/// inconsistency (Anno Siegel)
Re: s/// inconsistency (Ilya Zakharevich)
Re: s/// inconsistency <david.kernen@bms.com>
Re: Socket error sgi_ripe@my-deja.com
Re: Still Can't Get MIME Lite To Send Attachment... (Rand Simberg)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 23 Jan 2001 18:44:45 GMT
From: dha@panix2.panix.com (David H. Adler)
Subject: Re: [OT] Italic fonts too big
Message-Id: <slrn96rk8t.rpc.dha@panix2.panix.com>
On 23 Jan 2001 10:14:16 -0500, Nevin Kapur <kapur@mts.jhu.edu> wrote:
>[posted and mailed]
>
>On 23 Jan 2001, David H. Adler wrote:
>>
>> Why in the world are you asking this in a perl newsgroup?
>
>It was mistake. I posted a followup to the effect AND canceled the
>article too. I apologize again.
Thank you. Given the number of people who blatantly ignore usenet
etiquette, your response is both welcome and appreciated.
(note to all: I am *not* being sarcastic.)
dha, wishing there would be a higher mistake to blatant disregard
ratio...
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
America leads the world in shocks.
- Gil Scott-Heron
------------------------------
Date: Tue, 23 Jan 2001 16:16:08 GMT
From: ameendausha@my-deja.com
Subject: Adobe Acrobat Support . . .
Message-Id: <94kanu$o3$1@nnrp1.deja.com>
I'm looking for a way to access the data in an Adobe Acrobat file
(.pdf) at work so I can put a Perl app together to automate the
gathering of data. Can anyone point me in the right direction (the
direction of a Perl mod. or something that can help)?
Ben
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 23 Jan 2001 16:55:45 GMT
From: "Zarathustra" <cublai@earthlink.net>
Subject: Re: Adobe Acrobat Support . . .
Message-Id: <lIib6.3415$wh1.352343@newsread2.prod.itd.earthlink.net>
<ameendausha@my-deja.com> wrote in message
news:94kanu$o3$1@nnrp1.deja.com...
> I'm looking for a way to access the data in an Adobe Acrobat file
> (.pdf) at work so I can put a Perl app together to automate the
> gathering of data. Can anyone point me in the right direction (the
> direction of a Perl mod. or something that can help)?
Depends on what type of data you are trying to extract. The PDF module
extracts metadata about the PDF.
I ended up using the pdftotext.exe that comes with the Xpdf distribution
http://www.foolabs.com/xpdf/ and then
parsing the the text file it creates.
------------------------------
Date: Tue, 23 Jan 2001 09:42:46 +0100
From: "Michael Schlueter" <Michael.Schlueter@philips.com>
Subject: ANNOUNCE: Perl-OOP by classgen 3.03
Message-Id: <t6rbhqnmsthvf2@corp.supernews.com>
Version 3.03 is now available on:
http://search.cpan.org/search?dist=Class-Classgen-classgen
(Sorry, I provided too many examples, so this page appears a bit cluttered.
Look for 'classgen' in the lower part of the page to access the
documentation. I apologize for some bad formats, though.)
# - - - - - - - - - - - - - - - - - - - - - - - -
Creating Perl-objects by classgen:
1) edit a simple control file, specifying the intended variables inside the
object
2) run classgen, which creates two .pm modules for you
3) simply use the object within another Perl-script
4) add more functions to the .pm with your editor
5) be productive ;-)
# - - - - - - - - - - - - - - - - - - - - - - - -
To create your object, just run:
classgen my_object.control_file My_Object.pm
# - - - - - - - - - - - - - - - - - - - - - - - -
I think there are many ways to use the skeltons created by classgen:
* beginners in Perl-OOP can easily create objects with complex internal data
structures one at a time; just use them; please have a look at
/examples/getting_started; /examples/peanuts may be worth a look, as well
* more advanced Perl-OOP users can utilize inheritance of object
hierarchies, easily; please have a look at /examples/inheritance
* if you know about UML perhaps implementing associations between different
objects becomes more interesting than inheritance; please have a look at
/examples/associations
# - - - - - - - - - - - - - - - - - - - - - - - -
Please let me know your feedback.
------------------------------
Date: 23 Jan 2001 18:11:35 +0000
From: nobull@mail.com
Subject: Re: Behaviour of __PACKAGE__ inside eval
Message-Id: <u9n1cii1ew.fsf@wcl-l.bham.ac.uk>
"Hugh Williams" <hugh@grugach.freeserve.co.uk> writes:
> so although the variable $a in the eval statement resolves in the expected
> namespace, the __PACKAGE__ symbol itself is inaccurate. Can anyone explain
> what is happening here?
Looks like you've found a bug. I see mjd@plover.com has now submitted
your post to bugs.perl.org where it is listed as 20010123.028
Funny thing is ISTR having read of this bug before. I went to
bugs.perl.org confident that I'd find it and be able to say
"this is bug #xxxxxxxx.xxx"
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 23 Jan 2001 18:58:38 GMT
From: Paul Eckert <peckert@epicrealm.com>
Subject: Borland Paradox db dumper
Message-Id: <3A6DD461.4F5BF3F4@epicrealm.com>
Anybody have any idea where I can get a Paradox DBI module or perhaps a
script to parse and/or dump Paradox database files to text?
I don't care about any of the funny indexing stuff, just the data.
Thanks!
Paul
------------------------------
Date: 23 Jan 2001 17:48:08 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Catching warnings from Getopt::Std
Message-Id: <94kg4o$br$1@mamenchi.zrz.TU-Berlin.DE>
James Taylor <james@NOSPAM.demon.co.uk> wrote in comp.lang.perl.misc:
>I'm trying to use Getopt::Std to process command line options
>with code similar to this:
>
>#!/usr/bin/perl -w
>
>use strict;
>use Getopt::Std;
>
>my %options;
>getopts('i', \%options);
>
>print "-i ", $options{i} ? "present" : "absent", "\n";
>print "\@ARGV is now: @ARGV\n";
>
>However, when an unknown option is encountered Getopt::Std just
>removes it from @ARGV and displays the warning "Unknown option: x"
>which my program does not know about. I would like my program to be
>told when there are unknown options so that I can stop with a suitable
>error message. Any ideas anyone?
This may be an occasion where the __WARNINGS__ hook in %SIG comes
in handy. Put a handler in there that extracts the faulty key
from the warning message and do with it whatever you please. In
the code example below I stick them into %options with an undefined
value, which is good enough for a demonstration.
Anno
#!/usr/bin/perl
use strict; use warnings; $| =1;
use Getopt::Std;
my %options;
$SIG{ __WARN__} = \ &handle_warning;
getopts( 'i', \%options);
$SIG{ __WARN__} = 'DEFAULT';
print "Options given: ",
join( '', grep $options{ $_}, keys %options), "\n";
print "Unknown options: ",
join( '', grep !defined $options{ $_}, keys %options), "\n";
#########################################################
sub handle_warning {
local $_ = shift;
if ( /^Unknown option: (.)$/ ) { # deal only with this one
undef $options{ $1}; # the key now exists with an undefined value
} else {
warn $_; # regenerate warning
}
}
__END__
------------------------------
Date: Tue, 23 Jan 2001 18:51:05 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: Catching warnings from Getopt::Std
Message-Id: <ant23180563dfNdQ@oakseed.demon.co.uk>
In article <94kg4o$br$1@mamenchi.zrz.TU-Berlin.DE>, Anno Siegel
<URL:mailto:anno4000@lublin.zrz.tu-berlin.de> wrote:
>
> This may be an occasion where the __WARNINGS__ hook in %SIG comes
> in handy. Put a handler in there that extracts the faulty key
> from the warning message and do with it whatever you please. In
> the code example below I stick them into %options with an undefined
> value, which is good enough for a demonstration.
More than good enough. This is exactly the sort of thing I need. Thanks.
> sub handle_warning {
> local $_ = shift;
> if ( /^Unknown option: (.)$/ ) { # deal only with this one
> undef $options{ $1}; # the key now exists with an undefined value
> } else {
> warn $_; # regenerate warning
> }
> }
Wouldn't the "regenerate warning" line result in the handler being
called in an infinite loop?
It is a pity, though, that Getopt::Std doesn't throw errors, because
it really shouldn't be necessary to do all this messy %SIG handling
just to discover whether Getopt saw a valid command line.
--
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: Tue, 23 Jan 2001 19:27:18 -0000
From: "paul" <remi@multiweb.nl>
Subject: Re: Getopt::Long question?
Message-Id: <D2kb6.6363$ti1.543542@news.soneraplaza.nl>
"Johan Vromans" <JVromans@Squirrel.nl> wrote in message
news:wl3u26qag8s.fsf@plume.nl.compuware.com...
> "paul" <remi@multiweb.nl> writes:
>
> > my ($ip) = '';
> > GetOptions('ip=s' => \$ip );
> > print "The ip is $ip\n";
> > my ($name) = '';
> > GetOptions('name=s' => \$name );
> > print "The name is $name\n";
>
> Getopt::Long is designed to return all information at once. The right
> invocation is:
>
> my ($ip) = '';
> my ($name) = '';
> GetOptions('ip=s' => \$ip, 'name=s' => \$name );
> print "The ip is $ip\n";
> print "The name is $name\n";
>
-------snip-------------
i want to start by saying thnx for the info ....
but i have 1 question left ... in the above example how do a test if all the
options are filled in ?
something like this ?
my ($ip) = '';
my ($name) = '';
GetOptions('ip=s' => \$ip, 'name=s' => \$name );
if ($ip eq "") { exit; }
if ($name eq "") { exit; }
else {
print "The ip is $ip\n";
print "The name is $name\n";
}
or something like this ?
thnx paul
------------------------------
Date: Tue, 23 Jan 2001 18:36:25 GMT
From: boussard <boussard@my-deja.com>
Subject: Re: hash table
Message-Id: <94kiv8$8tl$1@nnrp1.deja.com>
Sure, I have 4 files with a few variables and ~10,000 values in each
file.
for example:
file 1:
diseaseID patientid
file 2:
diseaseID diseaseName
file 3:
diseaseName medicine
I would like to create a new file with
patientID, diseaseName, medicine
I don't want to merge the hashes, because that will give me duplicate
information, right? Do you have a better suggestion?
In article <3a6d38fd$0$8791$4dbef881@businessnews.de.uu.net>,
"Michael Schlueter" <Michael.Schlueter@philips.com> wrote:
> Hi,
>
> Can you please give a simple example for the files of your situation?
>
> My first guess was using grep.
>
> Michael Schlueter
>
>
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 23 Jan 2001 16:40:09 GMT
From: wheels_ohio@my-deja.com
Subject: Installing ActivePerl 5.6 on Linux/Apache shared website
Message-Id: <94kc57$2a9$1@nnrp1.deja.com>
I'm trying to install the generic Linux/Solaris Version of Perl on my
web server. I do not have root permissions, buy I'm told I don't need
root permission to install this version. I'm installing this version
of Perl because I want to be able to install and use perl modules from
CPAN. My webhost already has Perl installed, but I'm not able to
install modules myself. I'm hoping to use this version of Perl instead
and be able to install modules on my own.
Anyhow I'm having a problem installing it on my Linux/Apache web
server. I used the instructions on the website for installing it. And
I'm getting an error. Anybody else have this problem? Here is what
the telnet session looks like:
Enter top level directory for install [/usr/local/ActivePerl-
5.6] /home/t-shirts
hopper/modules
/home/t-shirtshopper/modules appears to already exist.
WARNING: Install may fail if any existing files cannot be overwritten.
The typical ActivePerl software installation requires 35 megabytes.
Please make sure enough free space is available before continuing.
Proceed? [y]
Continuing...
Setting up links
Installing ActivePerl software, please wait...
install.sh: /tmp/.ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZpErLZZZZZZZZZZZZZZZZZZZZ
ZZZZZZZZ
ZZperl/bin/perl: No such file or directory
Install failed, unable to relocate perl!
If you had problems or questions about the installation process,
please contact us at support@ActiveState.com
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 23 Jan 2001 18:30:49 GMT
From: abigail@foad.org (Abigail)
Subject: Re: kill -HUP only works once
Message-Id: <slrn96rjep.csh.abigail@tsathoggua.rlyeh.net>
Christian Meisl (meisl@amvt.tu-graz.ac.at) wrote on MMDCCII September
MCMXCIII in <URL:news:m3vgr6748u.fsf@famvtpc59.tu-graz.ac.at>:
}} anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
}} > Yes. While a process is handling a signal, that signal is blocked.
}}
}} Hmmm, I must admit that I have read about this somewhere,
}} somewhen... ;-)
Maybe it's time to point out the most useful book for Perl programmers:
Advanced Programming in the UNIX Environment,
by the late Stevens. (Addison Wesley).
Abigail
--
$_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; $chop};
$chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
-> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
------------------------------
Date: Tue, 23 Jan 2001 16:05:45 GMT
From: Terrence Brannon <brannon@lnc.usc.edu>
Subject: Re: Newbie question : Read configuration file.
Message-Id: <lbwvbms17r.fsf@lnc.usc.edu>
"Andy Geraerts" <angeraer@hotmail.com> writes:
> Hello,
>
> I have a few simple perl scripts. They all use variables. Some of these
> variables are used over all my scripts and have the same value. What is the
> easiest way to read out an configuration file which I would put under /etc?
You could use Config::IniFiles or AppConfig on
www.CPAN.org for your purposes.
--
Terrence Brannon
Carter's Compass...
I know I'm on the right track when by deleting code I'm adding
functionality.
------------------------------
Date: Tue, 23 Jan 2001 16:36:18 GMT
From: sjamiso@my-deja.com
Subject: Re: Non Unix user needs help with File::Find
Message-Id: <94kbu1$1u7$1@nnrp1.deja.com>
If you're interested:
This is how I ended up solving this problem with your help.
Thank you all!
sub wanted {
if ( $File::Find::dir =~ /.*$opt_skip.*/ios ){ next; }
if ( $opt_filespec )
{
push @bad_files, $File::Find::name if ( !-d && /.*\.$opt_filespec\b/i )
}
elsif ( !-d && -w )
{
push @bad_files, $File::Find::name
}
} #End of wanted
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 23 Jan 2001 17:48:42 GMT
From: mike_solomon@lineone.net
Subject: open web site with virtual users
Message-Id: <94kg5m$620$1@nnrp1.deja.com>
I have been asked to write a Perl script to access a web site with 6000
virtual users for 6 minutes at a time
We need this as we are testing a web site.
It will be used with a product called LoadRunner (I don't know if that
is relevant)
While I know a bit about Perl I haven't the faintest idea how to go
about writing this!!
Any pointers or suggestions will be very gratefully received
Thanks
Regards
Mike Solomon
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 23 Jan 2001 18:12:26 GMT
From: egwong@netcom.com
Subject: Re: open web site with virtual users
Message-Id: <eQjb6.16658$J%.1286143@news.flash.net>
Try something like LWP::Parallel
(http://search.cpan.org/search?dist=ParallelUserAgent)
mike_solomon@lineone.net wrote:
> I have been asked to write a Perl script to access a web site with 6000
> virtual users for 6 minutes at a time
> We need this as we are testing a web site.
> It will be used with a product called LoadRunner (I don't know if that
> is relevant)
> While I know a bit about Perl I haven't the faintest idea how to go
> about writing this!!
> Any pointers or suggestions will be very gratefully received
> Thanks
> Regards
> Mike Solomon
------------------------------
Date: Tue, 23 Jan 2001 18:24:06 GMT
From: mmanso@localhost.localdomain (Miguel Manso)
Subject: Passing parameters to a script
Message-Id: <slrn96rjaj.1l1.mmanso@localhost.localdomain>
Hi ppl.
I'm trying to write a perl script that accepts three optional parameters.
Lets say:
PARAM1, PARAM2 and PARAM3
When I execute the program like:
program.pl PARAM1 PARAM2 PARAM3
i know that the the parameters will be available in the @ARGV array.
Now, has told, the parameters are optional, so, if I call the script like:
program.pl PARAM1 PARAM3
the @ARGV will have two elements and I can't tell which one is which... I
mean, $ARGV[1] in this case is PARAM3 and not PARAM2.
Is there any technique to avoid this problem?
Thanks.
------------------------------
Date: Tue, 23 Jan 2001 18:56:26 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: Passing parameters to a script
Message-Id: <ant2318269eefNdQ@oakseed.demon.co.uk>
In article <slrn96rjaj.1l1.mmanso@localhost.localdomain>, Miguel Manso
<URL:mailto:mmanso@localhost.localdomain> wrote:
>
> program.pl PARAM1 PARAM3
>
> the @ARGV will have two elements and I can't tell which one is which... I
> mean, $ARGV[1] in this case is PARAM3 and not PARAM2.
>
> Is there any technique to avoid this problem?
Yes, use named parameters like:
program.pl -temp <PARAM1> -source <PARAM2> -dest <PARAM3>
program.pl -source <PARAM2> -dest <PARAM3>
Getopt::Long and Getopt::Std will do this sort of thing for you.
--
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: Tue, 23 Jan 2001 16:10:16 +0000
From: Steve Kemp <skx@tardis.ed.ac.uk>
Subject: Re: Perl Crashes on my Win2k Box
Message-Id: <Pine.GS4.4.21.0101231608560.23913-100000@tardis.tardis.ed.ac.uk>
On Tue, 23 Jan 2001, Jeffrey Grace wrote:
> It would have to be a pretty serious error to get the error he described ,
> which is a windows error message (normally an illegal instruction or illegal
> memory access) not a perl error message. I know a flock() error is shown by
> perl, has anyone come across an error that caused Windows to forcibly kill
> perl before? Hogan I suggest you search the ActivePerl web page to see if
> there is any known issues with Windows 2000, or your installation may have a
> corrupt file, or a DLL conflict.
.. Here's a simple way of killing perl on Windows:
perl -P [script.pl]
It has caused me trouble on Windows before, using perl 5.005, and
now 5.6.0 - which I built from source myself.
Steve
---
# NT Emacs FAQ maintainer.
http://www.gnu.org/software/emacs/windows/faq.html
# All about Steve # And his GNU Software
http://www.steve.org.uk http://GNUSoftware.com
------------------------------
Date: Tue, 23 Jan 2001 18:02:56 GMT
From: time4tea@my-deja.com
Subject: Re: Q: socket communication between perl and java
Message-Id: <94kh0a$70h$1@nnrp1.deja.com>
In article <3A6C6319.B1209A80@damtp.cam.ac.uk>,
Bjorn Hassler <bh213@damtp.cam.ac.uk> wrote:
>
> Hello all!
>
> I was wondering whether somebody has experimented with `sticking a bit
> of perl'
> between two java apps (on linux btw.), e.g.
>
> JAVA Simple Perl Java
>
APPLET---->socket1<--------Server---------------->socket2<--------Server
>
> where the perl server simply relays all that comes in from the applet
to
> the
> Java server, and vice versa. THe reason why I want to do this is long,
> complicated
> and horrible, so let's just treat it as an exercise :-)
>
> I've got all the bits of code, and the various servers and applet all
> recognise
> eachother connecting and disconnecting, but I cannot get them to pass
> any data.
>
> Perl details: I am using IO::Socket, tcp connection, and recv/send
> methods
> Java details: java.net.* (serverSocket), e.g. stream.writeUTF (uses
tcp
> too(?))
>
> Both the perl methods and the java methods use tcp - so what else
could
> there
> be going wrong? (Could of course be very elementary - I am really no
> network
> guru!)
>
> Just in case anybody has ever played with this kinda thing - I'd be
> grateful for a posting!
>
> Bjoern
>
Heres a little program you can use....If you want perl to print the data
you need to make sure that its not in unicode format...if you want to
just forward the data, this will be fine.
If one java program writes out UTF, you need to make sure the other one
reads UTF too....
This program is different from fwdport, cos it uses Event, so that all
processing is done as a single program (no forks)
I think deja will screw up the line breaks here....
#!/u/bin/perl
#
#
#
use IO::Socket;
use IO::Select;
use FileHandle;
use POSIX qw(isprint);
use Time::HiRes;
my $GATEWAY = "some.place.com";
my $PORT = "20024";
my %connected;
my $filehandles;
my $BYTES_PER_LINE = 16;
sub format_output {
my ($buffer) = @_;
my $ln = 0;
my $b;
while ( length ( $buffer ) > 0 ) {
my $display = "";
my $line = substr ( $buffer, 0, $BYTES_PER_LINE, "" );
$display_line = sprintf ( "%.4x " , $ln * $BYTES_PER_LINE ) ;
my $hex_line = "";
my $char_line = "";
for ( my $i = 0 ; $i < length ( $line ); $i++ ) {
my $t = substr ( $line, $i, 1 );
my $hex = sprintf ( "%.2x ", ord ( $t ));
$hex_line.= $hex;
my $char = isprint ( $t ) ? $t : ".";
$char_line.= $char;
}
if ( length ( $hex_line ) < 3 * $BYTES_PER_LINE ) {
$hex_line.= " " x ( 3*$BYTES_PER_LINE - length($hex_line) );
}
$display_line.= "$hex_line $char_line\n";
$b.= $display_line;
$ln++;
}
return $b;
}
# Main Program
my $server_socket = IO::Socket::INET->new ( Listen => 1, LocalPort =>
20024, Reuse => 1 );
if ( ! defined ($server_socket) ) {
croak ( " Can't open server socket: $!");
}
warn ( "Server listening on port 20024");
my $select = IO::Select->new ( $server_socket );
while ( 1 ) {
while ( my @ready = $select->can_read() ) {
foreach my $fh ( @ready ) {
if ( $fh == $server_socket ) {
my $client_sock = $fh->accept();
my $new_connection = IO::Socket::INET->new ( PeerHost =>
$GATEWAY,
PeerPort =>
$PORT );
if ( ! defined ( $new_connection ) ) {
warn ( "Can't open new connection to ISE");
next;
}
warn ( "Opened new connection to $PORT\@$GATEWAY");
my $filename = "/tmp/data/fwd" .
$client_sock->peerport() ;
my $logfh = new FileHandle ( ">$filename" );
$connected{ $client_sock } = $new_connection;
$connected{ $new_connection } = $client_sock;
$filehandles{ $client_sock } = $logfh;
$filehandles{ $new_connection } = $logfh;
$select->add ( $new_connection );
$select->add ( $client_sock );
}
else {
my $buffer;
my $bytes = $fh->sysread ( $buffer, 16384 );
if ( $bytes == 0 ) {
my $other_side = $connected{$fh};
warn ( "Client at " . $fh->peerhost() . " closed
connection. Closing other side " . $other_side->peerhost() .
", port " . $other_side->peerport );
$select->remove( $fh );
$select->remove( $other_side );
$fh->close();
$other_side->close();
delete $connected{$other_side};
delete $connected{$fh};
$filehandles{ $other_side }->close();
delete ( $filehandles{ $other_side } );
delete ( $filehandles{ $fh } );
}
else {
my $other_side = $connected{$fh};
$other_side->syswrite( $buffer );
my $date = localtime(time);
my ( $secs, $micros ) = Time::HiRes::gettimeofday();
my $text = "\n$date.$micros Data ( $bytes) from " .
$fh->peerhost() . ", port " . $fh->peerport() . "\n";
my $outbuf = format_output ( $buffer );
$filehandles{ $other_side }->syswrite ( $text,
length($text) );
$filehandles{ $other_side }->syswrite ( $outbuf );
}
}
}
}
}
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 23 Jan 2001 18:23:34 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Random Numbers with a Twist
Message-Id: <slrn96rj16.csh.abigail@tsathoggua.rlyeh.net>
Gordon.Haverland@agric.gov.ab.ca (Gordon.Haverland@agric.gov.ab.ca) wrote
on MMDCCII September MCMXCIII in <URL:news:3a6d8d78.412036016@news.gov.ab.ca>:
:)
:) >On 20 Jan 2001 00:42:40 GMT, abigail@foad.org (Abigail) wrote:
:) >
:) >>The hard part is deciding when to stop, that is, when is the set
:) >>random enough?
:)
:) You are heading down a slippery path on this one! It is entirely
:) possible to "draw" random coordinates from a universe of points and
:) end up with something that is highly ordered/symmetric. It may be
:) unlikely, but it is possible. If you reject a given outcome for being
:) "unrandom" according to your personal feelings, you bias your results.
Oh, I wasn't suggesting you couldn't stop because the result still
looked to ordered. You would have to decide in advance when to stop
- and that is the hard problem.
Abigail
--
perl -le 's[$,][join$,,(split$,,($!=85))[(q[0006143730380126152532042307].
q[41342211132019313505])=~m[..]g]]e and y[yIbp][HJkP] and print'
------------------------------
Date: 23 Jan 2001 16:45:47 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: s/// inconsistency
Message-Id: <94kcfr$ol8$1@mamenchi.zrz.TU-Berlin.DE>
Roman Moeller <roman@topologix.de> wrote in comp.lang.perl.misc:
>What I wanted to point out is :
>if
> s/pattern/substitution/
>is equvalent to
> $sub="substitution";
> s/pattern/$sub/
>and this is the almost always the case, why does this equivalence
>doesn't hold if the string happens to contain backreferences ?
Well, there is no such equivalence. The actual rule is that the
substitution part undergoes (one level of) variable interpolation
upon each match. This happens the same way, whether the variables
are ordinary Perl scalars or what you call backreferences ($1, $2,...).
Another level of substitution isn't attempted, even if the resulting
string happens to contain what looks like a Perl variable, $-sign and
all.
Anno
------------------------------
Date: 23 Jan 2001 17:14:31 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: s/// inconsistency
Message-Id: <94ke5n$hqe$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Roman Moeller
<roman@topologix.de>],
who wrote in article <94k78h$71d$1@crusher.de.colt.net>:
> What I wanted to point out is :
> if
> s/pattern/substitution/
> is equvalent to
> $sub="substitution";
> s/pattern/$sub/
> and this is the almost always the case
In programming there is no "almost always", it is one of "always",
"never", and "undefined".
Try
$bar = 12;
$sub = "foo$bar";
$bar = 333;
s/pattern/$sub/;
to clarify your misunderstandings.
Ilya
------------------------------
Date: Tue, 23 Jan 2001 13:19:04 -0500
From: Dave <david.kernen@bms.com>
Subject: Re: s/// inconsistency
Message-Id: <3A6DCB17.12E37928@bms.com>
Anno Siegel wrote:
> Roman Moeller <roman@topologix.de> wrote in comp.lang.perl.misc:
>
> >What I wanted to point out is :
> >if
> > s/pattern/substitution/
> >is equvalent to
> > $sub="substitution";
> > s/pattern/$sub/
> >and this is the almost always the case, why does this equivalence
> >doesn't hold if the string happens to contain backreferences ?
>
> Well, there is no such equivalence. The actual rule is that the
> substitution part undergoes (one level of) variable interpolation
> upon each match. This happens the same way, whether the variables
> are ordinary Perl scalars or what you call backreferences ($1, $2,...).
> Another level of substitution isn't attempted, even if the resulting
> string happens to contain what looks like a Perl variable, $-sign and
> all.
>
> Anno
OTH, you can always force perl to obey you, just so long as you know what
you want. Eg:
use strict;
my $sub = q("$2$1");
$_ = 'foobar';
s/(foo)(bar)/$sub/ee;
print;
Dave Kernen
------------------------------
Date: Tue, 23 Jan 2001 16:52:38 GMT
From: sgi_ripe@my-deja.com
Subject: Re: Socket error
Message-Id: <94kcsg$2vb$1@nnrp1.deja.com>
I've just found a solution !!!
I changed the line in /etc/nsswitch.conf
-protocols: db files
+protocols: files
I thinks it's a bug in glibc-2.1.2.
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 23 Jan 2001 18:31:46 GMT
From: simberg.interglobal@trash.org (Rand Simberg)
Subject: Re: Still Can't Get MIME Lite To Send Attachment...
Message-Id: <3a6ecd59.15849044@nntp.ix.netcom.com>
On 23 Jan 2001 10:06:14 GMT, in a place far, far away,
vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse) made the phosphor on
my monitor glow in such a way as to indicate that:
>>I set it to Type => 'application/octet-stream' and it worked just
>>fine...
>That also depends on what the receiving mail program defines as
>an attachment. As far as MIME is concerned, there is no real difference
>between the main text and the attachments, but the mail program may
>choose to display plain text attachment on the terminal rather than
>offer the possibility to save the attachment to disk.
>
>Maybe the line: "Content-Disposition: inline" has something to do with
>it as well.
That's a good point. I never tried it with any email client other
than Eurora. Perhaps Outlook would have attached it instead.
>The 'Content-Transfer-Encoding: binary' is a bit iffy. Should preferely
>be Base64 for real binary data and 7bit or 8bit for plain text. Then
>again, if Content-Type is plain/text, then the contents should realy be
>plain text, that is, displayable and printable text, and then you also
>need to specify the character set.
Well, I didn't specify the encoding. It seems to work, so I won't
look a gift horse in the mouth.
>Now sounds like a mime question rather than a perl question, so
>it is becoming off topic.
What's the best ng for a mime question?
************************************************************************
simberg.interglobal.org * 310 372-7963 (CA) 307 739-1296 (Jackson Hole)
interglobal space lines * 307 733-1715 (Fax) http://www.interglobal.org
"Extraordinary launch vehicles require extraordinary markets..."
Replace first . with @ and throw out the "@trash." to email me.
Here's my email address for autospammers: postmaster@fbi.gov
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 127
**************************************