[24905] in Perl-Users-Digest
Perl-Users Digest, Issue: 7155 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 18 03:07:02 2004
Date: Sat, 18 Sep 2004 00:05:23 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 18 Sep 2004 Volume: 10 Number: 7155
Today's topics:
Re: $| (undocumented) magic? <tadmc@augustmail.com>
Re: anonymous hash notation question <ceo@nospam.on.net>
Re: anonymous hash notation question <ceo@nospam.on.net>
Re: anonymous hash notation question <kkeller-usenet@wombat.san-francisco.ca.us>
Defining 3D array (Duke of Hazard)
Re: Defining 3D array <spamtrap@dot-app.org>
Re: Need more efficient use of the substitution operato <ebohlman@omsdev.com>
POE and Port Redirection (Theo James)
Re: POE and Port Redirection <troc@pobox.com>
Re: Repeatedly parsing a file to "clean" it. <tadmc@augustmail.com>
Write to memory error <joericochuyt@msn.com>
Re: Write to memory error <postmaster@castleamber.com>
Re: Write to memory error <zebee@zip.com.au>
Re: Xah Lee's Unixism <kkt@drizzle.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 18 Sep 2004 01:20:47 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: $| (undocumented) magic?
Message-Id: <slrncknktv.2g6.tadmc@magna.augustmail.com>
Michele Dondi <bik.mido@tiscalinet.it> wrote:
> I'm an idiot!!
I think you have misidentified who the idiot is in this thread...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 18 Sep 2004 03:45:44 GMT
From: ChrisO <ceo@nospam.on.net>
Subject: Re: anonymous hash notation question
Message-Id: <IbO2d.19983$ZC7.11954@newssvr19.news.prodigy.com>
Abigail wrote:
> wana (ioneabu@yahoo.com) wrote on MMMMXXXV September MCMXCIII in
> <URL:news:bf0b47ca.0409170842.6f195504@posting.google.com>:
> && what is the difference between:
> &&
> && {a=>b, c=>d}
> &&
> && and
> &&
> && {-a=>b, -c=>d}
> &&
> && ?
> &&
> && Specifically, what is the significance of the dash?
>
>
> Do you understand the difference between:
>
> {a => b, c => d}
>
> and
>
> {qa => b, qc => d}
>
> ?
>
> Do you understand the significance of the q?
I don't think this at least slightly sarcastic response is a fair answer
to the question. I had been programming in Perl for quite some time
before I realized that the dashed hash arguments some module writers
expected in their method calls was just that -- no different than "qa"
and that all they were doing was inventing their own "funky" notation
(somehow, I guess "paralleling" switched arguments.)
Perl, while powerful, can be MAJORLY "quirky" at times. There is no
"standard" per se for module writing. There are WRITTEN "standards" on
CPAN, but Perl by itself doesn't enforce those standards, and anyone can
write a module to take arguments however they want. I've seen all KINDS
of ways to pass arguments to module method calls.
And with "-" in most languages, not just Perl, usually having at least
one special meaning (negation, urinary significance, etc.), someone with
experience in another language, but only superficial experience in Perl
would AUTOMATICALLY think there *has* to be something significant with
"-a" and no way would they think it's really no different than "qa" --
which it just happens to be...
I think sometimes people in this NG are too unforgiving for those new to
the language. I've just gone around and around with some folks in
another newsgroup about these little so-called "flakey things" in Perl,
and while I at first didn't believe them or feel their arguments (no pun
intended) had merit, I came to see that many of their complaints did
have at least *some* merit. I'm just used to Perl syntax so I "see" it
differently when I scan Perl code. But some people, especially new to
the language, don't "see" it immediately. So give 'em a break...
And realize that there are actually people just starting to learn Perl
for the first time. We should be happy this is the case instead of
making them feel like idiots, esp. over something like "-a" which ISN'T
SO OBVIOUS after all and ISN'T really documented very obviously (if at
all even in the modules that call for arguments that way -- even the
module writers "assume" we know "-a" is no different than "qa".)
None of this to say there aren't A TON of stupid questions posted in
c.l.p.m every day -- questions that SHOULD and COULD be researched WAY
better than they are before posting. But this question was fair; I know
of no place off hand that this "behavior" is CLEARLY documented; the
assumption is made that we should know "-a" = "qa". And THAT'S quirky.
-ceo
------------------------------
Date: Sat, 18 Sep 2004 03:59:10 GMT
From: ChrisO <ceo@nospam.on.net>
Subject: Re: anonymous hash notation question
Message-Id: <hoO2d.19985$ZC7.9819@newssvr19.news.prodigy.com>
ChrisO wrote:
> And with "-" in most languages, not just Perl, usually having at least
> one special meaning (negation, urinary significance, etc.), someone with
I about died laughing when I read this over again after posting it. I
hope no one "pees" on me for spelling "unary" as "urinary" although the
OP probably felt "peed" on and I just was reflecting that impression.
Two phunny...
-ceo
------------------------------
Date: Fri, 17 Sep 2004 22:10:26 -0700
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: anonymous hash notation question
Message-Id: <2jss12xl64.ln2@goaway.wombat.san-francisco.ca.us>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
On 2004-09-18, wana <ioneabu@yahoo.com> wrote:
> You have to admit
> that the language sets people up for a little confusion the way that
> the same symbol has different meanings in different contexts.
You mean, like many natural languages?
- --keith
- --
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFBS8M9hVcNCxZ5ID8RAiOIAJ4/IP06ocsI05625QrqndgleyjvYQCgl4g4
l0M0qkQCq5pY0IEcLzV5BZQ=
=TWxh
-----END PGP SIGNATURE-----
------------------------------
Date: 17 Sep 2004 20:06:48 -0700
From: squash@peoriadesignweb.com (Duke of Hazard)
Subject: Defining 3D array
Message-Id: <2d21b838.0409171906.4d97b9a4@posting.google.com>
I have searched google, but could not find an answer for how to define
a 3D array manually. Here is the code:
$schedule[0]= (
["0", "0", "0","0"],
["0", "0", "0","0"],
);
$schedule[1]= (
["0", "0", "0","0"],
["0", "0", "0","0"],
);
The problem is $schedule[$i][$j][$k] are all undefined for any values
of i,j, and k?
Thanks!
------------------------------
Date: Fri, 17 Sep 2004 23:34:24 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Defining 3D array
Message-Id: <4JednQ0NJvJcMdbcRVn-rw@adelphia.com>
Duke of Hazard wrote:
> I have searched google, but could not find an answer for how to define
> a 3D array manually. Here is the code:
>
> $schedule[0]= (
> ["0", "0", "0","0"],
> ["0", "0", "0","0"],
> );
>
> $schedule[1]= (
> ["0", "0", "0","0"],
> ["0", "0", "0","0"],
> );
You want to store an array reference in $schedule[0], where above you're
trying to store an array. Like this:
$schedule[0] = [
[0,0,0,0],
[0,0,0,0],
];
$schedule[1] = [
[0,0,0,0],
[0,0,0,0],
];
You could also do it all at once:
$schedule = [
[
[0,0,0,0],
[0,0,0,0],
],[
[0,0,0,0],
[0,0,0,0],
],
];
See 'perldoc perldsc' and 'perldoc perllol' for more about nested data
structures.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: 18 Sep 2004 04:32:19 GMT
From: Eric Bohlman <ebohlman@omsdev.com>
Subject: Re: Need more efficient use of the substitution operator
Message-Id: <Xns9567F0577EFB2ebohlmanomsdevcom@130.133.1.4>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in news:2r0guiF144m9kU1@uni-
berlin.de:
>> In your example you use the return value from the expression. Am I
>> right in thinking that this value will also be in $1 ?
>
> If there is a match: yes, otherwise: no. Consequently, if you want to
> work with $1, $2 etc., you need to first check if the match succeeded,
> and only use those variables if it did.
Just to amplify on this (I'm sure you know it, but many newbies won't): if
the match failed, the $digit variables will be *untouched*. Not set to ""
or undef or anything like that. In particular, if a regex succeeds once
and then fails on subsequent input, the $digit variables will still have
the values *left over from the successful match*. Failing to take this
into account can lead to extremely puzzling bugs (which often result in
plausible-looking but incorrect output).
------------------------------
Date: 17 Sep 2004 20:29:09 -0700
From: zippy@sanft.net (Theo James)
Subject: POE and Port Redirection
Message-Id: <68d2887.0409171929.10bb6cb1@posting.google.com>
Bear with me folks, I have been working with POE for about 60 minutes.
I am in need of a port redirector that works like this:
Client -> Server -> Host
The client will create many session on the same port on the Server.
For each connection, the server needs to create a redirection on one
of 20 predefined ports to the Host (call it 9600-9619). The
connections will last less than 2 seconds each and if all 20 sessions
are in use, the servers port (call it 6666) needs to be block.
I found some code and tweaked it a bit to get a single port to
redirect, but I am at a loss from where to from here. Any help would
be appreciated:
#!/usr/bin/perl -Tw
use warnings;
use strict;
use Socket;
use POSIX qw(errno_h);
# Import POE and the extra modules we'll need within it.
use POE qw( Wheel::ReadWrite Wheel::SocketFactory Filter::Stream );
# The redirection table.
my %redirects =
qw( 1.6.20.15:6666 12.1.2.135:6666
);
### This is a stream-based tcp forwarder session. It passes data
### between two sockets, and that's about all.
# Create a session that will forward data between two sockets.
sub forwarder_create {
my ( $handle, $peer_host, $peer_port, $remote_addr, $remote_port )
= @_;
POE::Session->new
( _start => \&forwarder_start,
_stop => \&forwarder_stop,
client_input => \&forwarder_client_input, # Client sent
something.
client_error => \&forwarder_client_error, # Error on
client socket.
server_connect => \&forwarder_server_connect, # Connected to
server.
server_input => \&forwarder_server_input, # Server sent
something.
server_error => \&forwarder_server_error, # Error on
server socket.
# Pass some things to forwarder_start():
# ARG0, ARG1, ARG2, ARG3, ARG4
[ $handle, $peer_host, $peer_port, $remote_addr, $remote_port
]
);
}
sub forwarder_start {
my ( $heap, $session,
$socket, $peer_host, $peer_port, $remote_addr, $remote_port
) =
@_[ HEAP, SESSION,
ARG0, ARG1, ARG2, ARG3, ARG4
];
$heap->{log} = $session->ID;
$peer_host = inet_ntoa($peer_host);
$heap->{peer_host} = $peer_host;
$heap->{peer_port} = $peer_port;
$heap->{remote_addr} = $remote_addr;
$heap->{remote_port} = $remote_port;
print "[$heap->{log}] Accepted connection from
$peer_host:$peer_port\n";
$heap->{state} = 'connecting';
$heap->{queue} = [];
$heap->{wheel_client} = POE::Wheel::ReadWrite->new
( Handle => $socket,
Driver => POE::Driver::SysRW->new,
Filter => POE::Filter::Stream->new,
InputEvent => 'client_input',
ErrorEvent => 'client_error',
);
$heap->{wheel_server} = POE::Wheel::SocketFactory->new
( RemoteAddress => $remote_addr,
RemotePort => $remote_port,
SuccessEvent => 'server_connect',
FailureEvent => 'server_error',
);
}
# The forwarder has stopped. Log that it's done.
sub forwarder_stop {
my $heap = $_[HEAP];
print "[$heap->{log}] Closing redirection session\n";
}
# The forwarder has received data from its client side. Pass the data
# through to the server if it's connected. Otherwise hold the data in
# a queue until the server connects.
sub forwarder_client_input {
my ( $heap, $input ) = @_[ HEAP, ARG0 ];
if ( $heap->{state} eq 'connecting' ) {
push @{ $heap->{queue} }, $input;
}
else {
( exists $heap->{wheel_server} ) &&
$heap->{wheel_server}->put($input);
}
}
# The forwarder has received an error from the client. Shut down both
# sides of the connection. Log the error in a manner appropriate to
# its type.
sub forwarder_client_error {
my ( $kernel, $heap, $operation, $errnum, $errstr ) =
@_[ KERNEL, HEAP, ARG0, ARG1, ARG2 ];
if ($errnum) {
print( "[$heap->{log}] Client connection encountered ",
"$operation error $errnum: $errstr\n"
);
}
else {
print "[$heap->{log}] Client closed connection.\n";
}
delete $heap->{wheel_client};
delete $heap->{wheel_server};
}
# The forwarder's SocketFactory has successfully connected to the
# server. Log the success, and create a ReadWrite wheel to interact
# with the server socket. If the client sent anything during the
# connection process, pass it through to the server now.
sub forwarder_server_connect {
my ( $kernel, $session, $heap, $socket ) = @_[ KERNEL, SESSION,
HEAP, ARG0 ];
my ( $local_port, $local_addr ) = unpack_sockaddr_in(
getsockname($socket) );
$local_addr = inet_ntoa($local_addr);
print( "[$heap->{log}] Established forward from local ",
"$local_addr:$local_port to remote ",
$heap->{remote_addr}, ':', $heap->{remote_port}, "\n"
);
# Replace the SocketFactory wheel with a ReadWrite wheel.
$heap->{wheel_server} = POE::Wheel::ReadWrite->new
( Handle => $socket,
Driver => POE::Driver::SysRW->new,
Filter => POE::Filter::Stream->new,
InputEvent => 'server_input',
ErrorEvent => 'server_error',
);
$heap->{state} = 'connected';
foreach my $pending ( @{ $heap->{queue} } ) {
$kernel->call( $session, 'client_input', $pending );
}
$heap->{queue} = [];
}
# The forwarder has received data from its server side. Pass that
# through to the client.
sub forwarder_server_input {
my ( $heap, $input ) = @_[ HEAP, ARG0 ];
exists( $heap->{wheel_client} ) and
$heap->{wheel_client}->put($input);
}
# The forwarder has received an error from the server. Shut down both
# sides of the connection. Log the error in a manner appropriate to
# its type.
sub forwarder_server_error {
my ( $kernel, $heap, $operation, $errnum, $errstr ) =
@_[ KERNEL, HEAP, ARG0, ARG1, ARG2 ];
if ($errnum) {
print( "[$heap->{log}] Server connection encountered ",
"$operation error $errnum: $errstr\n"
);
}
else {
print "[$heap->{log}] Server closed connection.\n";
}
delete $heap->{wheel_client};
delete $heap->{wheel_server};
}
### This is a stream-based forwarder server. It listens on TCP ports,
### and it spawns new forwarders to redirect incoming connections.
# Create a session that acts as the forwarder server.
sub server_create {
my ( $local_address, $local_port, $remote_address, $remote_port )
= @_;
POE::Session->new
( _start => \&server_start,
_stop => \&server_stop,
accept_success => \&server_accept_success,
accept_failure => \&server_accept_failure,
# Pass this function's parameters to the server_start().
# ARG0, ARG1, ARG2, ARG3
[ $local_address, $local_port, $remote_address, $remote_port ]
);
}
# Start the server. This records where the server should connect, and
# it creates the listening socket factory.
sub server_start {
my ( $heap, $local_addr, $local_port, $remote_addr, $remote_port )
=
@_[ HEAP, ARG0, ARG1, ARG2, ARG3 ];
print "+ Redirecting $local_addr:$local_port to
$remote_addr:$remote_port\n";
$heap->{local_addr} = $local_addr;
$heap->{local_port} = $local_port;
$heap->{remote_addr} = $remote_addr;
$heap->{remote_port} = $remote_port;
$heap->{server_wheel} = POE::Wheel::SocketFactory->new
( BindAddress => $local_addr, # bind to this address
BindPort => $local_port, # and bind to this port
Reuse => 'yes', # reuse immediately
SuccessEvent => 'accept_success', # generate this event on
connection
FailureEvent => 'accept_failure', # generate this event on
error
);
}
# The server is stopping. Log that fact.
sub server_stop {
my $heap = $_[HEAP];
print( "- Redirection from $heap->{local_addr}:$heap->{local_port}
to ",
"$heap->{remote_addr}:$heap->{remote_port} has stopped.\n"
);
}
# The server has accepted a client connection. Pass the details about
# it to the function that creates a new forwarder. This is as
# unnecessary step. The contents of forwarder_create() could have
# been placed directly into server_accept_success().
sub server_accept_success {
my ( $heap, $socket, $peer_addr, $peer_port ) = @_[ HEAP, ARG0,
ARG1, ARG2 ];
&forwarder_create( $socket, $peer_addr, $peer_port,
$heap->{remote_addr}, $heap->{remote_port}
);
}
# The server encountered an error. Log the error. If we've run out
# of file descriptors, we'll have to shut down the server. A serious
# port redirector should just restart the server here.
sub server_accept_failure {
my ( $heap, $operation, $errnum, $errstr ) = @_[ HEAP, ARG0, ARG1,
ARG2 ];
print( "! Redirection from $heap->{local_addr}:$heap->{local_port}
to ",
"$heap->{remote_addr}:$heap->{remote_port} encountered
$operation ",
"error $errnum: $errstr\n"
);
delete $heap->{server_wheel} if $errnum == ENFILE or $errnum ==
EMFILE;
}
### Main loop. Create a new server for each record in %redirects.
### Run POE until all the servers (and their forwarders) shut down.
while ( my ( $from, $to ) = each %redirects ) {
my ( $from_address, $from_port ) = split ( /:/, $from );
my ( $to_address, $to_port ) = split ( /:/, $to );
&server_create( $from_address, $from_port, $to_address, $to_port
);
}
$poe_kernel->run();
------------------------------
Date: Sat, 18 Sep 2004 04:58:26 GMT
From: Rocco Caputo <troc@pobox.com>
Subject: Re: POE and Port Redirection
Message-Id: <slrnckng4i.hdf.troc@eyrie.homenet>
On 17 Sep 2004 20:29:09 -0700, Theo James wrote:
> Bear with me folks, I have been working with POE for about 60 minutes.
> I am in need of a port redirector that works like this:
>
> Client -> Server -> Host
>
> The client will create many session on the same port on the Server.
> For each connection, the server needs to create a redirection on one
> of 20 predefined ports to the Host (call it 9600-9619). The
> connections will last less than 2 seconds each and if all 20 sessions
> are in use, the servers port (call it 6666) needs to be block.
>
> I found some code and tweaked it a bit to get a single port to
> redirect, but I am at a loss from where to from here. Any help would
> be appreciated:
Here's a version that accepts connections on one port and forwards them to a
range of ports on another machine. It's untested, but I have verified that it
passes "perl -T -c".
--
Rocco Caputo - http://poe.perl.org/
#!/usr/bin/perl -Tw
use warnings;
use strict;
use Socket;
use POSIX qw(errno_h);
# Import POE and the extra modules we'll need within it.
use POE qw( Wheel::ReadWrite Wheel::SocketFactory Filter::Stream );
# Some aspects of redirection.
use constant LOCAL_ADDRESS => "1.6.20.15";
use constant LOCAL_PORT => 6666;
use constant REMOTE_ADDRESS => "12.1.2.135";
my @open_redirects = (9600..9619);
# Create a session that will forward data between two sockets.
sub forwarder_create {
my ($handle, $port) = @_;
POE::Session->create(
inline_states => {
_start => \&forwarder_start,
_stop => \&forwarder_stop,
client_input => \&forwarder_client_input,
error => \&forwarder_error,
server_connect => \&forwarder_server_connect,
server_input => \&forwarder_server_input,
},
args => [ $handle, $port ]
);
}
# The forwarder is actually starting. Begin interacting with the
# client, and begin connecting to the server.
sub forwarder_start {
my ($heap, $socket, $remote_port) = @_[HEAP, ARG0, ARG1];
$heap->{state} = 'connecting';
$heap->{queue} = [];
$heap->{port} = $remote_port;
$heap->{wheel_client} = POE::Wheel::ReadWrite->new(
Handle => $socket,
Filter => POE::Filter::Stream->new,
InputEvent => 'client_input',
ErrorEvent => 'error',
);
$heap->{wheel_server} = POE::Wheel::SocketFactory->new(
RemoteAddress => REMOTE_ADDRESS,
RemotePort => $remote_port,
SuccessEvent => 'server_connect',
FailureEvent => 'error',
);
}
# The forwarder has stopped. Put its port at the end of the open
# redirects list so it can be reused.
sub forwarder_stop {
push @open_redirects, $_[HEAP]->{port};
}
# The forwarder has received data from its client side. Queue the
# data if the server connection hasn't been established yet.
# Otherwise send it through to the server.
sub forwarder_client_input {
my ( $heap, $input ) = @_[ HEAP, ARG0 ];
if ( $heap->{state} eq 'connecting' ) {
push @{ $heap->{queue} }, $input;
return;
}
return unless exists $heap->{wheel_server};
$heap->{wheel_server}->put($input);
}
# A server connection was successfully made. Send any pending data to
# it.
sub forwarder_server_connect {
my ( $kernel, $session, $heap, $socket ) = @_[ KERNEL, SESSION, HEAP, ARG0 ];
# Replace the SocketFactory wheel with a ReadWrite wheel, so we can
# interact with the server.
$heap->{wheel_server} = POE::Wheel::ReadWrite->new(
Handle => $socket,
Filter => POE::Filter::Stream->new,
InputEvent => 'server_input',
ErrorEvent => 'server_error',
);
# Send pending data to the server.
if (@{$heap->{queue}}) {
$heap->{wheel_server}->put( @{$heap->{queue}} );
$heap->{queue} = [];
}
}
# The forwarder has received data from its server side. Pass that
# through to the client.
sub forwarder_server_input {
my ( $heap, $input ) = @_[ HEAP, ARG0 ];
return unless exists $heap->{wheel_client};
$heap->{wheel_client}->put($input);
}
# The forwarder has received an error from either the client or
# server. Shut it all down.
sub forwarder_error {
my $heap = $_[HEAP];
delete $heap->{wheel_client};
delete $heap->{wheel_server};
}
###--------------------------------------------------------------
### This is the listening part of the redirector.
# Create a session that acts as the forwarder server.
sub server_create {
POE::Session->new(
_start => \&server_start,
_child => \&forwarder_status,
accept_success => \&server_accept_success,
accept_failure => \&server_accept_failure,
);
}
# Start the server.
sub server_start {
my $heap = $_[HEAP];
$heap->{server_wheel} = POE::Wheel::SocketFactory->new(
BindAddress => LOCAL_ADDRESS,
BindPort => LOCAL_PORT,
Reuse => 'yes',
SuccessEvent => 'accept_success',
FailureEvent => 'accept_failure',
);
}
# The status of a forwarder has changed. If a forwarder is going
# away, it means we have one more redirect port open. Check to see if
# the server should resume accepting connections.
sub forwarder_status {
my $op = $_[ARG0];
return unless $op eq "lose";
$_[HEAP]->resume_accept() if @open_redirects == 1;
}
# The server has accepted a client connection. Start forwarding.
sub server_accept_success {
my ( $heap, $socket, $peer_addr, $peer_port ) = @_[ HEAP, ARG0, ARG1, ARG2 ];
# Grab the next open redirect port in our list.
my $next_remote_port = shift @open_redirects;
forwarder_create($socket, $next_remote_port);
# Temporarily stop accepting connections if there are no more
# redirect ports.
$heap->{server_wheel}->pause_accept() unless @open_redirects;
}
# The server encountered an error. Shut it down if we've run out of
# file descriptiors. A serious port redirector would handle this more
# gracefully.
sub server_accept_failure {
my ( $heap, $operation, $errnum, $errstr ) = @_[ HEAP, ARG0, ARG1, ARG2 ];
delete $heap->{server_wheel} if $errnum == ENFILE or $errnum == EMFILE;
}
# Main loop. Create a single listening socket that redirects
# connections to one of a pool of remote sockets.
server_create();
POE::Kernel->run;
exit;
------------------------------
Date: Sat, 18 Sep 2004 01:46:10 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Repeatedly parsing a file to "clean" it.
Message-Id: <slrncknmdi.2g6.tadmc@magna.augustmail.com>
[ Please do not top-post. It is seen as being rude.
Text rearranged into a more conventional order.
]
Graeme Stewart <g_stewart@hotmail.com> wrote:
> Tad McClellan <tadmc@augustmail.com> wrote in message news:<slrnck43l5.9vh.tadmc@magna.augustmail.com>...
>> Wolfgang Hommel <wolf@code-wizards.com> wrote:
>>
>> >> can I do this
>> >> in a better / more efficient way?
>> >
>> > Not sure what exactly you consider as "efficient",
>> As Wolfgang said, "efficient" doesn't help us help the OP.
>>
>> Tell us what you want to "optimize".
>>
>> Optimize performance? Optimize for labor? Optimize memory usage? ...
> P.S I was very careful in my original post to NOT use the word
> "optimize". Efficient to me = the readability of the code!
^^^^^
^^^^^
Then when you are talking to yourself, use "efficient".
When you are writing to other people, you should use universally
accepted meanings for words, we can't read your mind so we are
unlikey to assume your definition (unless you tell it to us).
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 17 Sep 2004 22:23:54 -0400
From: "yusufdestina" <joericochuyt@msn.com>
Subject: Write to memory error
Message-Id: <b81bc541ecaa932691f5abe24f8f1e01@localhost.talkaboutprogramming.com>
I Have a small Tk/Perl app that makes some backups of MySQl databases.
This is the code..
my $dsn = "DBI:mysql:host=$dbhost";
my $dbh = DBI->connect($dsn,$dbuser,$dbpass,{RaiseError => 0})or die
&MySQL_error_login;
foreach my $ref(@db) {
print"Backup $ref at $dbhost\n";
sleep(1);
my @bp = 'mysqldump --user=$dbuser --password=$dbpass
--add-drop-table $ref > $savepath/$ref.$date.$ext';
}
-----------------------------------------------------------
When I execute this sometimes the appl just quit's without any warnings. I
know that it quits when trying to execute the mysqldump. On another system
I got a read write error on memory. Is my method incorrect? What can I do
to improve it?
tnx for ur time and help!
------------------------------
Date: 18 Sep 2004 06:41:48 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Write to memory error
Message-Id: <Xns95681142D2DB4castleamber@130.133.1.4>
"yusufdestina" <joericochuyt@msn.com> wrote in
news:b81bc541ecaa932691f5abe24f8f1e01@localhost.talkaboutprogramming.com:
> I Have a small Tk/Perl app that makes some backups of MySQl databases.
> This is the code..
Sure?
[snip]
> my @bp = 'mysqldump --user=$dbuser --password=$dbpass
> --add-drop-table $ref > $savepath/$ref.$date.$ext';
What do you think that line does?
--
John MexIT: http://johnbokma.com/mexit/
personal page: http://johnbokma.com/
Experienced programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: Sat, 18 Sep 2004 06:57:27 GMT
From: Zebee Johnstone <zebee@zip.com.au>
Subject: Re: Write to memory error
Message-Id: <slrncknmn9.p3c.zebee@zeus.zipworld.com.au>
In comp.lang.perl.misc on Fri, 17 Sep 2004 22:23:54 -0400
yusufdestina <joericochuyt@msn.com> wrote:
> I Have a small Tk/Perl app that makes some backups of MySQl databases.
> This is the code..
> my $dsn = "DBI:mysql:host=$dbhost";
> my $dbh = DBI->connect($dsn,$dbuser,$dbpass,{RaiseError => 0})or die
> &MySQL_error_login;
> foreach my $ref(@db) {
> print"Backup $ref at $dbhost\n";
> sleep(1);
> my @bp = 'mysqldump --user=$dbuser --password=$dbpass
> --add-drop-table $ref > $savepath/$ref.$date.$ext';
> }
Why are you connecting to a database when you do nothing with the
connection?
The backup's being done by a call to mysqldump, the first 3 lines appear
totally redundant.
mysqldump can fail for a number of reasons, you aren't doing anything
with the STDERR.
So you are redirecting STDOUT to a file, redirect STDERR as well, and
see what it says.
Unless there's a very good reason to do it in perl, may as well do it in
shell...
Zebee
------------------------------
Date: 17 Sep 2004 23:10:27 -0700
From: Patrick Scheible <kkt@drizzle.com>
Subject: Re: Xah Lee's Unixism
Message-Id: <tqmhdpwqf8s.fsf@drizzle.com>
Alan Balmer <albalmer@att.net> writes:
> On 14 Sep 2004 10:15:27 -0700, Patrick Scheible <kkt@drizzle.com>
> wrote:
>
> >Chuck Dillon <spam@nimblegen.com> writes:
> >
> >> Coby Beck wrote:
> >>
> >> >>
> >> >>And, of course, entertaining the possibility that his agenda is just
> >> >>what he says it is, is completely out of the question.
> >> > Not out of the question, be obviously untrue.
> >>
> >> Again, I'll point out that it is naive to put this entirely on the
> >> administration. We're in Iraq because we effectively declared
> >> war. The dance with the U.N. went on for some 3 months. It was clear
> >> where we were headed. Our congress, including Kerry and all of the
> > ^^^
> >Not all. I'm happy to say my representative and one of my senators
> >voted against the resolution authorizing the war.
> >
> >Congress doesn't have its own intelligence service. If the
> >administration claims to have clear evidence that a country has WMD
> >there's only so much that a minority party in congress can do to find
> >out if the administration is lying or engaged in wishful thinking.
>
> http://intelligence.house.gov/
> http://intelligence.senate.gov/
They have committees, they don't have independent
intelligence-gathering ability.
-- Patrick
------------------------------
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 7155
***************************************