[17301] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4723 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 25 14:15:36 2000

Date: Wed, 25 Oct 2000 11:15:18 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <972497718-v9-i4723@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 25 Oct 2000     Volume: 9 Number: 4723

Today's topics:
        numbering matches drtsq@my-deja.com
        numbering matches drtsq@my-deja.com
    Re: numbering matches (Tad McClellan)
    Re: numbering matches (Chris Fedde)
    Re: Object destructors not working properly? <lesley@natric.demon.co.uk>
        Oracle Script File <barry.ballard@autodesk.com>
    Re: Oracle Script File <newsposter@cthulhu.demon.nl>
        Passing data to a script(from a form) gopringle@my-deja.com
        Perl question no on form results (Liam)
    Re: Perl question no on form results <anders@wall.alweb.dk>
    Re: Perl question no on form results <james@NOSPAM.demon.co.uk>
    Re: Removing line breaks from a string - HELP! (Al)
    Re: renaming local() <epa98@doc.ic.ac.uk>
    Re: simple counter in a text file (Helgi Briem)
        socket flushing problem <bomr@lin01.triumf.ca>
    Re: System Calls from Perl Help??? nobull@mail.com
    Re: use strict; with eval:: error messages to stderr <bbrown@addtoit.com>
    Re: use strict; with eval:: error messages to stderr (Sean McAfee)
        Workspace-1.48.tar.gz <rkiesling@mainmatter.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 25 Oct 2000 16:15:47 GMT
From: drtsq@my-deja.com
Subject: numbering matches
Message-Id: <8t70vc$gtd$1@nnrp1.deja.com>

I am trying to number matches in a string, by that I mean I want to insert a
number prior to each match. So, given $animals="dog cat rat cat mouse llama
cat cat rat", and if I want to number each "cat" I'd end up with
$animals="dog 1) cat rat 2) cat mouse llama 3) cat 4) cat rat". The nearest
FAQs I could find was in  perlfaq4 was "How do I change the Nth occurrence of
something?" and "How can I count the number of occurrences of a substring
within a string?" but thats not really what I want. Any suggestions?
Thanks...


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Wed, 25 Oct 2000 16:15:48 GMT
From: drtsq@my-deja.com
Subject: numbering matches
Message-Id: <8t70ve$gtf$1@nnrp1.deja.com>

I am trying to number matches in a string, by that I mean I want to insert a
number prior to each match. So, given $animals="dog cat rat cat mouse llama
cat cat rat", and if I want to number each "cat" I'd end up with
$animals="dog 1) cat rat 2) cat mouse llama 3) cat 4) cat rat". The nearest
FAQs I could find was in  perlfaq4 was "How do I change the Nth occurrence of
something?" and "How can I count the number of occurrences of a substring
within a string?" but thats not really what I want. Any suggestions?
Thanks...


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Wed, 25 Oct 2000 12:39:28 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: numbering matches
Message-Id: <slrn8ve360.bum.tadmc@magna.metronet.com>

On Wed, 25 Oct 2000 16:15:48 GMT, drtsq@my-deja.com <drtsq@my-deja.com> wrote:

>I am trying to number matches in a string, by that I mean I want to insert a
>number prior to each match.


--------------------
#!/usr/bin/perl -w
use strict;

$_ = "dog cat rat cat mouse llama cat cat rat\n";

my $num = 0;

s/cat/
   $num++; 
   "$num) cat"
 /ge;

print;
--------------------


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

Date: Wed, 25 Oct 2000 17:43:18 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: numbering matches
Message-Id: <WYEJ5.144$7rc.170962432@news.frii.net>

In article <8t70ve$gtf$1@nnrp1.deja.com>,  <drtsq@my-deja.com> wrote:
>I am trying to number matches in a string, by that I mean I want to insert a
>number prior to each match. So, given $animals="dog cat rat cat mouse llama
>cat cat rat", and if I want to number each "cat" I'd end up with
>$animals="dog 1) cat rat 2) cat mouse llama 3) cat 4) cat rat". The nearest
>FAQs I could find was in  perlfaq4 was "How do I change the Nth occurrence of
>something?" and "How can I count the number of occurrences of a substring
>within a string?" but thats not really what I want. Any suggestions?
>Thanks...
>

$animals="dog cat rat cat mouse llama cat cat rat\n";
$animals =~ s/(cat)/++$i.") $1"/eg;
print $animals;

yealds

dog 1) cat rat 2) cat mouse llama 3) cat 4) cat rat

hth
-- 
    This space intentionally left blank


------------------------------

Date: Wed, 25 Oct 2000 15:35:29 +0100
From: "Lesley Withall" <lesley@natric.demon.co.uk>
Subject: Re: Object destructors not working properly?
Message-Id: <972484506.15270.0.nnrp-02.9e989efa@news.demon.co.uk>

Thank you very much. You've exactly described the problem I've been seeing.
I'm glad I'm not going mad!

However, in my case I am implementing a class as an interface to a system.
This object can end up as a super-container... with many arrays of nested
object references. The process that calls my class to create the object for
itself  will do so from the main package and is likely to be holding the
reference in a global. This will inevitably not go out of scope until the
process exits. Are we saying that a class like this can never work without
the user having to deal with preventing garbage collection problems? This
doesn't seem 'right' to me.



"Michael Balenger" <MBalenger@worldnet.att.net> wrote in message
news:bupJ5.5137$MR3.273766@bgtnsc04-news.ops.worldnet.att.net...
> I had a problem relating to garbage collection (GC).  Maybe you can
> benefit from the hours I spent tracking it down.
>
> Summary: There are two levels of GC.  The first one runs during the
> program.  The second one runs after exit to get whatever the first one
> couldn't get.  I was seeing the effects of this.
>
> *Most* discussions of GC deal with the first phase: objects get GC'd
> when the reference count goes to zero.  This is typical at end of
> scope, usually at a closing brace.  My problem dealt with the second
> phase: what happens after a program exits, but before the process
> exits?
>
> What?
>
> Here's a simple example from "Programming Perl", Section 5.3.9 - A
> Note on Garbage Collection.
>
> {               # make $a point to itself
>     my $a;
>     $a = \$a;
> }
>
>
> The reference count to $a never goes to zero, even outside of the
> block.  It will not be GC'd during the lifetime of the program.  It
> will get GC'd during the second phase.  This insight was the key to
> solving my problem.
>
> This section contained the answer to my problem.  Unfortunately, I
> hadn't yet formulated my question in the correct form to get the
> answer from this section.  Seems that a good question leads to a good
> answer.  A bad question leads to confusion.  (e.g. Have you stopped
> beating your spouse yet?)
>
> My original question was: Why don't my contained objects get GC'd
> *after* the container?
>
> It seemed to me that the contained objects would be referenced by the
> container.  Therefore, the container would have to get GC'd first,
> releasing the references to the contained objects, which would then
> get GC'd.  I *should* be able to place a freeze operation in the
> container's DESTROY method.
>
> My observation was different.  The freeze operation was noticing that some
> of the contained objects had already been GC'd.
>
> Placing "goodbye" messages in each destructor showed a (seemingly)
> random order of destruction between containers and contained objects.
>
> Then I placed a "goodbye" message before the exit.
>
> Viola.  I noticed that all the GC happened after exit.  After exit?
>
> My better question became:  Why are all my objects getting GC'd after
exit?
>
> That had a better answer: Because the containing object was actually
> contained by another object.  I had created a module level cache to
> speed up subsequent lookups.  The cache was held in a file scoped
> hash.  That hash referenced my containers.  Because the cache had a
> lifetime of the entire process, it didn't get GC'd during the process.
> It's lifetime was the key here.  The scope was limited, but the
> lifetime was not.  Anything referenced by that cache had its reference
> count stay non-zero for the duration of the process.  After exit, the
> GC mechanism doesn't give a rats ass what order it uses.  It assumes
> that the program would have done whatever it wanted to do before it
> exited.
>
> Fair enough.  Obscure at the time, but fair enough.  Now that the GC's
> not random, I can work with it.
>
> Solution: Kill the things on *my* time, during the process.  That's a
> simple undef in an END block.  Once I undef'd the cache, the
> containers could be GC'd, then the contianed objects were GC'd.  Just
> how I wanted.
>
> Lesson: Beware of unanticipated references.  They prevent GC a the
> "obvious" end of scope time.
>
>
> Cross-lesson: There's a thread on subroutine references that's
> probably got the same kinds of issues.
>
> I've found that drawing pictures on white boards helps a lot.
>
>
> Here's the comments I pulled directly from that module.
>
>
> # ================================================================
> # Declare an object cache to be used by new().
>
> use vars qw(%_cache);
>
> END {
>     # The cache *must* get garbage-collected while the program is
>     # active.  Allowing GC to happen after exit() leaves the order up
>     # to chance -- contained and referenced objects can be GC'd before
>     # the container, preventing the freeze from capturing the entire
>     # hierarchy.
>
>     # In short -- undef here makes sure that the garbage collection
>     # order is predictable.
>     undef %_cache;  # Very necessary!!!
> }
>
> BEGIN {
>     %_cache = ();  # Not strictly necessary.
> }
>
>
>




------------------------------

Date: Wed, 25 Oct 2000 10:16:39 -0600
From: "Barry D. Ballard" <barry.ballard@autodesk.com>
Subject: Oracle Script File
Message-Id: <39F70767.88228EC4@autodesk.com>

Does anyone know how to get the DBI module with the DBD for Oracle to
run an Oracle script file?  I've tried a number of time and a number of
different ways, but so far it errors out with an invalid SQL statement
on the execute command when I try running the script.

Is the only way to open the script separately and run line by line?

Anyone run into this?  Any help would be greatly appreciated.

Barry Ballard
barry.ballard@autodesk.com



------------------------------

Date: 25 Oct 2000 16:52:07 GMT
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: Oracle Script File
Message-Id: <8t733n$p5l$1@internal-news.uu.net>

In comp.lang.perl.misc Barry D. Ballard <barry.ballard@autodesk.com> wrote:
> Does anyone know how to get the DBI module with the DBD for Oracle to
> run an Oracle script file?  I've tried a number of time and a number of
> different ways, but so far it errors out with an invalid SQL statement
> on the execute command when I try running the script.

> Is the only way to open the script separately and run line by line?

  You can only run one statement at a time. You might be able to wrap
your script in an PL/SQL block, which can be executed as a whole. See
the DBI and DBD::Oracle documentation for more information.

Erik



------------------------------

Date: Wed, 25 Oct 2000 17:14:20 GMT
From: gopringle@my-deja.com
Subject: Passing data to a script(from a form)
Message-Id: <8t74d5$k3s$1@nnrp1.deja.com>

Hello Everybody.

I was wondering if you all could help me see the light.

I'm testing a script that receives and argument(computer/server name)
from the command line and outputs the "APPLICATION" log of that machine.

c:>Inetpub\cgi-local>perl showevt.pl kp-papers03

-------------------------------------------------------------
 Thu Oct 19 17:06:39 2000 MSDTC 4 KP-GAM-W098
-------------------------------------------------------------
 Thu Oct 19 17:06:39 2000 MSDTC 4 KP-GAM-W098
-------------------------------------------------------------
 Thu Oct 19 17:06:40 2000 MSDTC 4 KP-GAM-W098
                     .
                     .
                     .

***(If the machine name is not specified the log of the current machine
is dumped.)***

Up to this point everything works fine. The problem that I'm having
is that I get a blank page whenever I try to pass the name of the server
to the script from a webpage/form.

According to what I have read so far I can pass an argument to a script
from a form by inseting a "?" and the argument after the url that
contains the script on the html code.

<a HREF="http://localhost/inetpub/cgi-local/showevt.pl?server">


I would appreciate any help regarding this matter. I'm
attaching the perl and html code to see if you can catch any errors
that I might be making.

***************************************************
HTML
***************************************************

<html>

<head>
<title>SHOW EVENT LOG(ALPHA)</title>
</head>

<body>

<form METHOD="POST"
ACTION="http://localhost/Inetpub/cgi-local/showevt.pl?server">
  <p>This is a Test page of the &quot;showevnt.pl&quot; script. </p>
  <p>Enter the name of the machine to monitor: <input NAME="server"
VALUE=" " size="20"> </p>
  <p>. </p>
  <p><input TYPE="SUBMIT" NAME="SUBMIT" VALUE="Execute the Script"> </p>
</form>
</body>
</html>

******************************************************


******************************************************
PERL CODE
******************************************************

use CGI;
use strict;
use Win32::EventLog;

print "Content-type: text/plain\n\n";

my $server = shift;


\&GetEvents($server,"Application");

sub GetEvents {
	my($server,$log) = @_;
	my ($evt,$total,$oldest,$evtHashRef);
	my $start = 0;

	$evt = Win32::EventLog->new($log,$server) ||
		die "Could not open $log log on $server: $!\n";
	$evt->GetNumber($total) || die "Can't get number of
EventLog records: $!\n";
	$evt->GetOldest($oldest) || die "Can't get number of
oldest EventLog record: $!\n";

	while ($start < $total) {

$evt->Read(EVENTLOG_FORWARDS_READ|EVENTLOG_SEEK_READ,$oldest+$start,$evt
HashRef)

  			or die "Can't read EventLog entry #$start\n";




	print "-" x 75; print "\n";

	my $id = (${$evtHashRef}{EventID} & 0xffff);
  	my $sid = unpack("H" . 2 * length(${$evtHashRef}{User}),
${$evtHashRef}{User});

	print " ".localtime(${$evtHashRef}{TimeGenerated})."
".${$evtHashRef}{Source}.
	      " ".${$evtHashRef}{EventType}."
".${$evtHashRef}{Computer}."\n";

  	#Win32::EventLog::GetMessageText($evtHashRef);
  	#my $msg = $evtHashRef->{Message};
  	#print "Message: $msg\n";



	#print "\n";
  	$start++;
	}
}

**************************************************



Thanks,


Glenn





Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Wed, 25 Oct 2000 13:11:13 GMT
From: lkenny@fisheries.org (Liam)
Subject: Perl question no on form results
Message-Id: <39f6d91d.4752135@news.volocom.net>

This script is used as a CGI script, but the question I have is for
the perl end.
The value of the variables returned is set up in the following format

$FORM{$name} = $value


e.g.:

print "$Form{'FirstName'}\n";
#would return whatever the user entered for the first name blank

I have several variables returned that are named 'Sub..' and are
followed by 2 digits.  What I want is to identify any name that is
'Sub..' followed by 2 numbers.

I was trying to use:

if ($FORM{$name} ne $FORM{'sub(.{2})') {
	#run command
}

I obviously have something wrong.

Can anyone lend a hand?

Any and all help is much appreciated.

LK




------------------------------

Date: Wed, 25 Oct 2000 15:34:21 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: Perl question no on form results
Message-Id: <ykBJ5.352$Uq1.41970@news000.worldonline.dk>

Liam wrote:

> This script is used as a CGI script, but the question I have is for
> the perl end.
> The value of the variables returned is set up in the following format
> 
> $FORM{$name} = $value
> 
> 
> e.g.:
> 
> print "$Form{'FirstName'}\n";
> #would return whatever the user entered for the first name blank
> 
> I have several variables returned that are named 'Sub..' and are
> followed by 2 digits.  What I want is to identify any name that is
> 'Sub..' followed by 2 numbers.
> 
> I was trying to use:
> 
> if ($FORM{$name} ne $FORM{'sub(.{2})') {
> #run command
> }
> 
> I obviously have something wrong.
> 
> Can anyone lend a hand?
> 
> Any and all help is much appreciated.
> 
> LK
> 
> 

Use a regexp. Read your perl documentation, for regesps
$ perldoc perlre

Supposing that you want to test $FORM{$name} for beeing Sub<number><number>:

if ($FORM{$name} =~ m/^Sub\d\d$/) {
  # A match!
  &$FORM{$name}; # critiqueless run that, not clever!
}

Before running a sub which was selected by user input, you'd want to tjeck 
if it's valid!

my %validsubs = (
   Sub11 => 1,
   Sub45 => 1
   #...
);

if ($FORM{$name} =~ m/^Sub\d\d$/) {
  # A match!
  &$FORM{$name} if $validsubs{$FORM{$name}}; # only run if known
}

Frankly,
The usage of $FORM{$name} indicates that you are using oldish perl4 style 
CGI programs, which is silly considering the power of the CGI module!
Look up the CGI module in oyur docs
$ perldoc CGI
to get started!

-anders



-- 
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]


------------------------------

Date: Wed, 25 Oct 2000 16:16:44 +0100
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: Perl question no on form results
Message-Id: <ant2515441cbfNdQ@oakseed.demon.co.uk>

In article <39f6d91d.4752135@news.volocom.net>, Liam
<URL:mailto:lkenny@fisheries.org> wrote:
> 
> I have several variables returned that are named 'Sub..' and are
> followed by 2 digits.  What I want is to identify any name that is
> 'Sub..' followed by 2 numbers.

I'm not quite sure what you mean when you say *named* 'Sub..'.
If you mean $FORM{name} has value 'Sub..' then Anders Lund's
reply is everything you need to know, but if you mean that
you want to process each parameter that has a name of the
form 'Sub..' (where the dots represent digits) then try this:

foreach my $key (grep /^Sub\d\d$/, keys %FORM) {
    print "\$FORM{$key} = $FORM{$key}\n";
}

-- 
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02



------------------------------

Date: Wed, 25 Oct 2000 15:40:14 GMT
From: nospamapgraham@ispchannel.com--- (Al)
Subject: Re: Removing line breaks from a string - HELP!
Message-Id: <39fafbc9.95366047@news.ispchannel.com>

On Sat, 21 Oct 2000 10:04:50 -0700, "Godzilla!"
<godzilla@stomp.stomp.tokyo> wrote:

>
>
>
>Your inherent ignorance beguiles your own malice intent

inherent-adj.Existing as an essential constituent or characteristic;
intrinsic.
**Ignorance can be a quality inherent in something, but it can't be
said to be inherent in and of itself. 

be·guile-v. tr. 
        1.To deceive by guile; delude. See Synonyms at deceive. 
        2.To take away from by or as if by guile; cheat: a disease
that has beguiled me of strength. 
        3.To distract the attention of; divert: “to beguile you from
the grief of a loss so overwhelming”
           (Abraham Lincoln). 
        4.To pass (time) pleasantly. 
        5.To amuse or charm; delight. See Synonyms at charm. 
**I don't understand your use of this word at all.
**"Malice" is a noun. I believe you ment "malicious intent." 
>and significant degree of illiteracy, consistently.
**"significant degree of illiteracy"??? Is the pot calling the kettle
black?
>Mine is not a solution but rather a demonstration,
>using this author's previous statements and givens,
>to clearly show, you as the original author, are nothing
>more than an ignorant illiterate troll using myriad
>fake names with psychotic malice intent.
**Neurotic, perhaps, but, by definition, a psychosis prevents a person
from functioning in society.
**Again, "malicious intent".
**Intent can't be psychotic. Only people/illnesses.
>
>
>* sprinkles a few more seeds *
>
>Godzilla!

Please quit trying to speak over your own head. It invalidates your
position no matter how valid it is otherwise.

-Al-



------------------------------

Date: 25 Oct 2000 14:33:34 +0100
From: Edward Avis <epa98@doc.ic.ac.uk>
Subject: Re: renaming local()
Message-Id: <xn93dhlkpu9.fsf@sync27.doc.ic.ac.uk>

darkon@one.net (David Wall) writes:

>I just finished reading Larry Wall's speech at 
>http://archive.develooper.com/perl6-meta@perl.org/msg00427.html.  In it, he 
>mentions the possibility of renaming local() (in the paragraph beginning 
>'Rename the local operator?'). If you'll listen to a suggestion from 
>someone who knows nothing about Perl internals, then what about renaming it 
>to 'this'?  

That would confuse C++ programmers.  You should never do that :-)

How about 'dynamically_scoped'?  Hmm, too verbose.  'dynamic'?

-- 
Ed Avis
epa98@doc.ic.ac.uk


------------------------------

Date: Wed, 25 Oct 2000 14:17:49 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: simple counter in a text file
Message-Id: <39f6e97c.2439269954@news.itn.is>

On Tue, 24 Oct 2000 19:10:06 GMT, "kbent"
<workmonster2@home.com> wrote:

>I'm looking for a simple perl script to count pages, as incremented in a
>separate text file.  Every time the browser refreshes, I would like the
>script to increment the data in the text file, and save it.
>
This is not the right place to ask questions about CGI.
Try comp.infosystems.www.authoring.cgi . What
the hell, I'm a sucker.  I'll give your problem a shot 
anyway.

>#!c:\perl\bin\perl.exe
>
That should be
#!c:\perl\bin\perl.exe -wT
while debugging.

>use CGI qw(:standard);
>
Good start.
>print header;
>print start_html;
>
>open (BAG, "file.txt");    #supposed to open the file handle BAG and link it
>to a text file.
That should be:
open (BAG, ">file.txt") or die "Cannot open file.txt:$!";

The chances are better than 99.99999% that if you had
done this you would already have discovered the
reason for your failure.  httpd or IUSR does not
have write access to the directory your script is
residing in /and rightly so).  You were also missing
the ">" operator that opens the file for writing.

<SNIP STUFF>

>close BOX;
That should be:
close BAG or die "Cannot close BAG:$!\n";
There is no BOX filehandle in your script.

Regards,
Helgi Briem


------------------------------

Date: 25 Oct 2000 17:38:15 GMT
From: "Rod B. Nussbaumer" <bomr@lin01.triumf.ca>
Subject: socket flushing problem
Message-Id: <8t75q7$2oh$1@nntp.itservices.ubc.ca>

Okay, I've read loads of stuff about doing TCP socket IO in perl, 
and have a fair grasp of the basic concepts.  I've managed to
write/modify some simple client & server testbeds, and now that 
I'm trying to do something useful, I've bumped into a problem
I can't solve for myself.  

I'm trying to send non line-oriented data (a struct created
by pack() ) as a packet to a TCP server.  My problem
is that the struct is not terminated with any kind of newline,
and hence the output buffer is not flushed.  I have tried
applying the autoflush technique on the socket, but this
seems to fail silently.

The pertinent code fragments follow...

While we're in the neighbourhood, can someone please explain
the semantics behind 'print SOCK', 'send( SOCK,..)', and
'syswrite( SOCK, ... )'?  As you can see from the enclosed
code fragments, I've tried all three methods, but from 
this test, they all seem to behave identically.

FWIW, this is basically a rewrite of a working C code library, 
that runs correctly under Solaris and VxWorks.  I want to have 
a Perl version that I can use for faster prototyping and
similar hacking.

#======================================================================
#
#    Create a connected socket for use by this application.
#
sub     TcpOpen(){

my  ($Address,$Port) = @_;

my  $Sock;

    print "Addr : $Address\n";
    print "Port : $Port\n";

my  $Protocol = getprotobyname( 'tcp' );
    print "Protocol : $Protocol\n";
    socket( SOCK, AF_INET, SOCK_STREAM, $Protocol );

    #
    #  Enforce autoflushing on this socket.
    #
    select( SOCK ); $| = 1; select( STDOUT );
    print "Socket created\n";                  

my  $Dest   = sockaddr_in( $Port, inet_aton( $Address ) );
    connect( SOCK, $Dest ) || die "Cannot connect : $!\n";
    print "Socket connected\n";

    $Sock = \*SOCK;
    return( $Sock );
}




#======================================================================
#
#   How to cause the packets to be flushed immediately?
#
sub     TcpWrite(){

my  ($Sock, $Buffer) = @_;

my  $TestString1 = "Hello world...";     # No flush...
my  $TestString2 = "Hello world.\n";     #    ...flush...

#
#   Send a test string one of three ways...
#
    syswrite( $Sock, $TestString1, length( $TestString1 ) );
#    send( $Sock, $TestString1, 0 );
#    print $Sock $TestString1;

#    syswrite( $Sock, $Buffer, length( $Buffer ) );
    return 0;

}


Thanks,

    ---   rod.

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Rod Nussbaumer, Programmer/Technologist       E-mail: bomr@triumf.ca  
 TRIUMF --- University of British Columbia,     Phone: (604)222-7449
 Vancouver, BC, Canada.                           FAX: (604)222-7307
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


------------------------------

Date: 25 Oct 2000 17:57:21 +0100
From: nobull@mail.com
Subject: Re: System Calls from Perl Help???
Message-Id: <u93dhkluz2.fsf@wcl-l.bham.ac.uk>

gary.lefko@usafa.af.mil writes upside down:

> I just love all the extra commentary  (by some users) one gets when
> posting a question for help in discussion groups! 

Wierd that, you post question to a _discussion_ group as an
alternative to spending 5 minuites reading the manual and you get all
this totally undeserved sarcastic commentry!  I guess that all us
regulars here need the learn that the purpose of a language discussion
group is to replace manuals for newbies.

Get real!  This is a discussion group not a helpdesk.  You post
something we discuss it's implications.  If the discussion happens to
answer a question you've asked that's incidental.  If you post a
question that implies that you've got a problem finding answers to
trivial questions in the manual then it is perfectly reasonable for us
to discuss how to do that.

> "Maybe some day I'll get REAL smart, too!"

Or at least learn some basic netiquette - like how to qoute the
message you are responding to.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


------------------------------

Date: Wed, 25 Oct 2000 10:43:29 -0400
From: William Lewis Brown <bbrown@addtoit.com>
Subject: Re: use strict; with eval:: error messages to stderr
Message-Id: <39F6F191.588749F@addtoit.com>

Mr. NoBull,
	Thanks for you help Mr. NoBull.  I am using mod_perl/apache/perl so I will be
upgrading these tools as a matched set up to Perl 5.6.  I hear from good sources
that if I pick the right versions, they will all play nicely together.  I assume
that $@ will include my "use strict;" errors in this new environment.
	Thanks very much for your help.

					Bill

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
nobull@mail.com wrote:
> 
> William Lewis Brown <bbrown@addtoit.com> writes:
> 
> >       Unfortunately, it seems as if any errors associated with "use strict" are spit
> > out on stderr and do not appear as part of $@.
> 
> Fortunately this bug has been fixed in 5.6.
> 
> --
>      \\   ( )
>   .  _\\__[oo
>  .__/  \\ /\@
>  .  l___\\
>   # ll  l\\
>  ###LL  LL\\

-- 
William L. Brown
Work:  603-465-2114
Fax:   603-465-2114
Cell:  617-803-9156
Email: bbrown@addtoit.com
Home:  603-465-2948


------------------------------

Date: Wed, 25 Oct 2000 17:43:52 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: use strict; with eval:: error messages to stderr
Message-Id: <sZEJ5.8325$O5.176115@news.itd.umich.edu>

In article <39F623F2.2A9486A3@addtoit.com>,
William Lewis Brown  <bbrown@addtoit.com> wrote:
>Hi,
>    I am using eval to compile and run code at runtime.  Due to the nature of my
>environment, this code may at times be incorrect.  I do the standard thing and
>check $@ after an eval to see if the code compiled and ran successfully.  I
>always run with "use strict" and so the code that I am evaling is subject to the
>"use strict" rules.
>    Unfortunately, it seems as if any errors associated with "use strict" are spit
>out on stderr and do not appear as part of $@.  The error messages I do get in
>$@ are often very cryptic due to the code not passing the "use strict;" tests.
>    What is the best way for me to work around this problem?  It would be ideal if
>I could get my "use strict;" errors placed in a variable.

As mentioned, this is a bug in versions of Perl prior to 5.6.  I got
around it in earlier versions by doing this:

{
    local $SIG{__WARN__} = \&promote_strictness_warnings;
    eval "whatever";
    error_out() if $@;
}

sub promote_strictness_warnings {
    local $_ = shift;
    /^Global symbol ".*" requires explicit package name/
        ||
    /^Variable ".*" is imported/
        ||
    /^Bareword ".*" not allowed while "strict subs" in use/
        ||
    /^Can't use string (".*") as .* ref while "strict refs" in use/
        ||
    /^Can't use bareword (".*") as .* ref while "strict refs" in use/
        and
    die $_;
}

-- 
Sean McAfee                                                mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!


------------------------------

Date: Wed, 25 Oct 2000 00:47:38 GMT
From: Robert Kiesling <rkiesling@mainmatter.com>
Subject: Workspace-1.48.tar.gz
Message-Id: <sve0gf4f1hg71a@corp.supernews.com>


While waiting for CPAN's upload server and my browser to cooperate,
the most recent release of the Tk::Workspace package is available at:

http://www.mainmatter.com/workspace/Workspace-1.48.tar.gz

And hopefully, it will be available soon on CPAN, at:

http://www.cpan.org/authors/id/R/RK/RKIES/Workspace-1.48.tar.gz

and on metalab.unc.edu, at:

ftp://metalab.unc.edu/pub/Linux/apps/editors/Workspace-1.48.tar.gz

as soon as maintainers move it from the pub/Linux/Incoming directory.


WHAT'S NEW:

- Improved shell capabilities: I/O blocking problems have been greatly
  reduced (although not eliminated), and a broken pipe will not cause
  a workspace to terminate.  Improved interpretation of shell prompt
  variables.

- Better window update response, even during shell processing,
  and use of WMDeleteWindow X protocol request to exit the 
  program, which should eliminate (one) source of core dumps
  under Solaris. 

- Save/restore of the insertion cursor's location, and text wrap and
  scroll bar configuration.  The text widget automatically receives
  focus on opening.

- Use of the Tk::ColorEditor to set colors.  

- More reliable (hopefully) handling of the help text, which no
  longer relies on the __FILE__ variable.

- More consistent option handling, for the moment via the new()
  constructor only.


These changes have caused Workspace.pm to be less compatible with MS
Windows environments.  Since I don't have MS Windows here, if anyone
would like to attempt the MS Windows modifications, they are more
than welcome.

As usual, please send suggestions, bug reports, and hate mail, to
me at the address in the .sig.

Thanks!

-- 
Robert Kiesling
Linux FAQ Maintainer 
rkiesling@mainmatter.com
http://www.mainmatter.com/linux-faq/toc.html  http://www.mainmatter.com/




------------------------------

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 V9 Issue 4723
**************************************


home help back first fref pref prev next nref lref last post