[10096] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3689 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 11 05:07:22 1998

Date: Fri, 11 Sep 98 02:00:19 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 11 Sep 1998     Volume: 8 Number: 3689

Today's topics:
        DB_File Object <bsilva@gladstone.uoregon.edu>
    Re: DB_File Object <ajohnson@gpu.srv.ualberta.ca>
        determine the length of a formatted string? (Yip Hoi Man)
        getc function from STDIN <"abbas "@ikorn.ee.unsw.edu.au>
        Getting diagnostic messages with Solaris and perl5.004_ <Tim.Potter@anu.edu.au>
    Re: How do you hide the definition of a subroutine? (David A. Black)
    Re: max function in perl jasjeet14@my-dejanews.com
    Re: max function in perl <sam@peritas.com>
        Mem info <rajan@cadence.com>
    Re: mod_perl configuration (Alan E. Derhaag)
        perl syntax book? <yu207526@yorku.ca>
    Re: perl syntax book? <ajohnson@gpu.srv.ualberta.ca>
    Re: Question about Perl/mysql (charles lin)
        question about regular expr... (GEMINI)
    Re: question about regular expr... <ajohnson@gpu.srv.ualberta.ca>
        Redirect output to perl variable kuhnerts@my-dejanews.com
    Re: Returning objects? Is it possible? (David A. Black)
        Search/Replace but Not under certain conditions. HOW? (Ron Bennett)
    Re: Search/Replace but Not under certain conditions. HO <news@paintbot.com>
    Re: Search/Replace but Not under certain conditions. HO <dgris@rand.dimensional.com>
        Socket.pm & print <dadman@brainsys.cz>
    Re: Socket.pm & print (Larry Rosler)
        SQL-Retrivers - Informix server won't start (Paul Mahoney)
        TCP sockets and broken pipes ashtar@my-dejanews.com
    Re: Where to start? <yu207526@yorku.ca>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Thu, 10 Sep 1998 23:58:41 -0700
From: "Brian L. Silva" <bsilva@gladstone.uoregon.edu>
Subject: DB_File Object
Message-Id: <Pine.GSO.3.96.980910234749.20854A-100000@gladstone.uoregon.edu>


I saw somewhere a line like this:

$db_object = tie( @file, 'DB_File', "../data.db", O_RDWR, 0600, $DB_RECNO );
$db_object->push( @file, $data );

Where @file is an array that's been tied with DB_File. I thought that the 
interface for tied arrays did not include functions like push, pop, shift,
unshift, or splice. Does anyone know if the object returned from a tie
provides these methods?

While on the same subject, does anyone have documentation on all the
methods and instance variables of the $DB_RECNO object? (such as
$DB_RECNO->{cache}, etc.)

Thanks!

 - BLS



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

Date: Fri, 11 Sep 1998 02:22:25 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: DB_File Object
Message-Id: <35F8CFB1.2E878BB2@gpu.srv.ualberta.ca>

Brian L. Silva wrote:
> 
> I saw somewhere a line like this:
> 
> $db_object = tie( @file, 'DB_File', "../data.db", O_RDWR, 0600, $DB_RECNO );
> $db_object->push( @file, $data );
> 
> Where @file is an array that's been tied with DB_File. I thought that the
> interface for tied arrays did not include functions like push, pop, shift,
> unshift, or splice. Does anyone know if the object returned from a tie
> provides these methods?

DB_File had these methods when tie'ing arrays with DB_RECNO, and
now Perl5.005 has complete tied arrays with Tie::Array.

> While on the same subject, does anyone have documentation on all the
> methods and instance variables of the $DB_RECNO object? (such as
> $DB_RECNO->{cache}, etc.)

its all included in the DB_File.pm documentation, 
'perldoc DB_File'

hope this helps
regards
andrew


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

Date: 11 Sep 1998 07:27:54 GMT
From: hmyip@mae.cuhk.hk (Yip Hoi Man)
Subject: determine the length of a formatted string?
Message-Id: <6tajdq$2jj@eng-ser1.erg.cuhk.edu.hk>

Hi,

My problem is to determine the length(in points) of a string which is
formatted in fonts say times-roman. Would anybody please tell me
if there is any tool or perl module to do that?

Thanks in advance.

--
Johnny YIP


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

Date: Fri, 11 Sep 1998 16:24:52 +1000
From: Abbas Imani <"abbas "@ikorn.ee.unsw.edu.au>
Subject: getc function from STDIN
Message-Id: <35F8C233.219DBFFB@ikorn.ee.unsw.edu.au>

Hello everybody,

I am trying to have one character input and am using getc function.

I have two problems:

1. I would like the program to continue when one key is hit. In other

words, I do not want the user to have to hit enter key after s/he

hits a key.

2. After I use getc(STDIN) in my code, I can not use the command

for the second time in the same code. The program doesn't wait for

the user to hit any key. How can I fix this.

Cheers,

Abbas

________________________________________________________________
Abbas Imani                         A.Imani@unsw.edu.au
Computer Networks Laboratory        http://ikorn.ee.unsw.edu.au
School of Electrical Engineering    Phones: 9385-4055, 9385-4070
UNSW, Sydney NSW 2052 AUSTRALIA     Fax:    9385-5993
----------------------------------------------------------------
My programs don't have bugs, they just develope random features.





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

Date: Fri, 11 Sep 1998 06:34:10 GMT
From: Tim Potter <Tim.Potter@anu.edu.au>
Subject: Getting diagnostic messages with Solaris and perl5.004_04
Message-Id: <6yn2879mzo.fsf@acronym.anu.edu.au>

Hi everyone.  I've been working on a perl script and all of a sudden I
am now getting diagnostic messages (Chapter 9 in the camel book).

The first one was "Bizarre copy of ARRAY in leave at /dev/fd/4 line
1146." after writing a bit of Perl to replace a list of group id
numbers with their names using getgrgid() and just recently "Bad
free() ignored at /dev/fd/4 line 229."  The diag messages occur at
perfectly valid code (unfortunately I trashed the group id code
fragment and the bad free occurs at an assignment statement )-:).

The only weird thing I have done recently is install a whole lot of
recommended and security patches on the Solaris 2.5.1 machine that the
script is running on.

Has anyone else been having any similar problems?  


Tim.


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

Date: Thu, 10 Sep 1998 21:12:21 EDT
From: dblack@saturn.superlink.net (David A. Black)
Subject: Re: How do you hide the definition of a subroutine?
Message-Id: <6t9tdl$90l$1@earth.superlink.net>

Hello -

By handing around entire typeglobs, you can avoid the
problem of aliases that won't go away when you want them to.
Here's a two-file modified version of your example along
those lines:


--- file 'hidee' ---
#!/usr/local/bin/perl -w

sub orig { print "I am the original subroutine!\n" }

print "orig() in hidee: ";
orig();
require "hide";
print "orig() after requiring hide: ";
orig();

# End

--- file 'hide' ----
sub unorig { print "I am the new one!\n" };

*backup = *orig;
*orig   = *unorig;

print "backup() in hide: "; &backup;

# End

Sample run:

candle:~/hacking/perl$ perl hidee
orig() in hidee: I am the original subroutine!
backup() in hide: I am the original subroutine!
orig() after requiring hide: I am the new one!


I think that what happens in your (second) example is that
the first assignment establishes a typeglob alias, but the undef
doesn't undo that alias - so the second assignment still
affects *origfcn.  By using the whole typeglob, my version
lets *orig be redefined without taking *backup with it.

Note that if you change "undef &fcn" to "undef *fcn", yours
will work too.

David Black
dblack@saturn.superlink.net

 
bernie@fantasyfarm.com (Bernard Cosell) writes:

>The kind of thing I'd like to do is have a 'require' file that
>includes definitions that "intercept" calls to a few routines in an
>already-existing program.  I've been trying to do something like:
>   *origfcn = \&fcn ;
>   *fcn = \&newfcn;
>That doesn't work [it gets me the proper result, but gets me a warning
>about redefining &fcn].  so I tried:
>   *origfcn = \&fcn ;
>   undef &fcn ;
>   *fcn = \&newfcn ;
>and that made the error go away, but also clobbered the value of
>&origfcn [so that both vars get me &newfcn now].


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

Date: Fri, 11 Sep 1998 05:58:41 GMT
From: jasjeet14@my-dejanews.com
Subject: Re: max function in perl
Message-Id: <6tae6h$ega$1@nnrp1.dejanews.com>

In article <35F7C3FD.41642E6D@peritas.com>,
  sam@peritas.com wrote:
> jasjeet14@my-dejanews.com wrote:
> >
> > How do we calculate the max or min value on particular field records in a
> > database ie. if wish to display the maximum value of a field say rate in a
> > database. Please help me on this.
>
> An easy way to do this is when you get the data back from your database
> use the SQL MAX function to get the data
>
> Hope this helps
>
> SAM
>


Iam reading records from a text file, so how do we go about displaying the max
or min value, from the data that we get after reading a text file.

jasjeet

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Fri, 11 Sep 1998 08:24:08 +0100
From: Simon Matthews <sam@peritas.com>
Subject: Re: max function in perl
Message-Id: <35F8D018.74C3D104@peritas.com>

jasjeet14@my-dejanews.com wrote:
> 
> In article <35F7C3FD.41642E6D@peritas.com>,
>   sam@peritas.com wrote:
> > jasjeet14@my-dejanews.com wrote:
> > >
> > > How do we calculate the max or min value on particular field records in a
> > > database ie. if wish to display the maximum value of a field say rate in a
> > > database. Please help me on this.
> >
> > An easy way to do this is when you get the data back from your database
> > use the SQL MAX function to get the data
> >
> > Hope this helps
> >
> > SAM
> >
> 
> Iam reading records from a text file, so how do we go about displaying the max
> or min value, from the data that we get after reading a text file.
> 
my $max = 0;

while (<>) {
 #sort out your data here
$max = $data if $data > $max;

}

print "Max is [$max]\n";

Hope this helps.

SAM


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

Date: Thu, 10 Sep 1998 13:21:18 -0700
From: rajan <rajan@cadence.com>
Subject: Mem info
Message-Id: <35F834BE.5E87@cadence.com>

Hi ,

   Is there a perl function which can tell u about 
   the physical memory on the system on which it is 
   executing ..

kanwar


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

Date: 11 Sep 1998 06:59:33 +0000
From: bitbucket@wolfenet.com (Alan E. Derhaag)
Subject: Re: mod_perl configuration
Message-Id: <zpc7m8x6.fsf@AlanNet.wolfenet.com>

--Multipart_Fri_Sep_11_06:59:33_1998-1
Content-Type: text/plain; charset=US-ASCII

marad@usa.net writes:

> First, many thanks to everyone who is assisting me.
> 
> >  comdog@computerdog.com (brian d foy) wrote:
> > In article <6s72au$7gi$1@nnrp1.dejanews.com>, marad@usa.net posted:
> >[snip]
> > >Alias /perl/ /usr/apache/share/perl/
> > ><Location /perl>
> > >SetHandler perl-script
> > >PerlHandler Apache::Registry
> > >Options ExecCGI
> > ></Location>
> 
> >Try to include "PerlSendHeader On" within that <Location>.
> 
> Changing this setting didn't seem to do anything. It's hard to tell what's
> going on because no error messages are reported in the log; the page just
> comes up showing the source, not running it. If I activate CGI, the test-cgi
> script (running in the cgi-bin directory, not ../perl), says Apache/1.3.1
> (Unix) mod_perl/1.15, so I'm pretty sure the compile went okay.

Seems to me I remember a configuration string for the mod_perl of
PERL_LOG_API to allow debug output of various perl libraries loading
as required.  I might put a little light on the situation.


--Multipart_Fri_Sep_11_06:59:33_1998-1
Content-Type: text/plain; charset=US-ASCII

 Alan E. Derhaag                     Omnifax/Danka Industries
 phone: +1 425 643 7126           1800 136th Place NE Unit #3
  http://www.wolfenet.com/~aderhaag/       Bellevue, WA 98053
             email: --aderhaag@wolfenet.com

--Multipart_Fri_Sep_11_06:59:33_1998-1--


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

Date: 11 Sep 1998 03:45:24 GMT
From: "Dmytry Khodorkovsky" <yu207526@yorku.ca>
Subject: perl syntax book?
Message-Id: <01bddd36$a7d887c0$cb7a3f82@warez.ibm.net>

Hello,
I want to study perl, and have read two books,
both not bad, but mostly telling you that perl is good language and
there are several interesting things that can be done with.
I need a book with syntaxis -- smth like manual of style
where I'd find explanation of all special variables, functions and data =
structures
in Perl.
		=09
Thanks ahead.
			Dmytry Khodorkovsky

dmkhodor@yucc.yorku.ca	=09
http://www.yucc.yorku.ca/~dmkhodor



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

Date: Fri, 11 Sep 1998 01:56:00 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: perl syntax book?
Message-Id: <35F8C980.773F66DC@gpu.srv.ualberta.ca>

Dmytry Khodorkovsky wrote:
!
! Hello,
! I want to study perl, and have read two books, both not bad, but
! mostly telling you that perl is good language and there are several
! interesting things that can be done with.  I need a book with
! syntaxis -- smth like manual of style where I'd find explanation of
! all special variables, functions and data structures in Perl.

"Programming Perl", 2nd ed. is the essential reference book for the
Perl language (by Larry Wall, Tom Christiansen, and Randal Schwartz
--- published by O'Reilly and Associates).

However, if you have Perl, you have all the reference material 
you need included with the distribution, see the perl manpage
('perldoc perl' or 'man perl') for an overview of the documentation.

for example, the info you mentioned above can be found in:

special variables  =>  perldoc perlvar
functions:         =>  perldoc perlfunc
data structures:   =>  perldoc perldata
                   =>  perldoc perldsc
                   =>  perldoc perllol
                   =>  perldoc perlref

and there's much, much more, and it is more up to date than
any printed manual.

regards
andrew


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

Date: Fri, 11 Sep 1998 07:20:12 GMT
From: charles@ix.netcom.com (charles lin)
Subject: Re: Question about Perl/mysql
Message-Id: <35f8ceb7.25219701@NNTP.ix.netcom.com>

Michael,

Thank you so much! You pointed me to the right place and now the
problem is solved.

Thanks again!

Charles,

On Fri, 11 Sep 1998 04:21:33 GMT, mfuhr@dimensional.com (Michael Fuhr)
wrote:

>charles@ix.netcom.com (charles lin) writes:
>
>> I am studing how to use Perl with mysql. But I keep getting the
>> following error message:
>>
>> Can't call method "do" without a package or object reference at ...
>>
>> Can anyone explain to me what happened?
>>
>> The code is like:
>>
>> use DBD::mysql;
>> $db = 'db';
>> $dbh = DBI->connect("DBI:mysql:$db"); 
>> $rc = $dbh->do("create table .....
>
>You're not checking the value returned by DBI->connect.  See the
>DBI documentation for how to print the result of a failed connection.
>
>-- 
>Michael Fuhr
>http://www.fuhr.net/~mfuhr/



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

Date: 11 Sep 1998 06:51:09 GMT
From: dennis@info4.csie.nctu.edu.tw (GEMINI)
Subject: question about regular expr...
Message-Id: <6tah8t$sfs$1@netnews.csie.NCTU.edu.tw>

hi all,
  could anybody tell me how to express 
"any semicolumn ';' that doesn't enclosed by { and }" in 
regular expression?
for eg.
 in string $_="field1;field2;{ ex1; ex2; };field3"
I want to split the string into array
  ('field1','field2','{ ex1; ex2; }','field3')
so how should I use split(/????/) for this purpose?
thanks in advance.


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

Date: Fri, 11 Sep 1998 02:03:36 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: question about regular expr...
Message-Id: <35F8CB48.7483B4FA@gpu.srv.ualberta.ca>

GEMINI wrote:
> 
> hi all,
>   could anybody tell me how to express
> "any semicolumn ';' that doesn't enclosed by { and }" in
> regular expression?
> for eg.
>  in string $_="field1;field2;{ ex1; ex2; };field3"
> I want to split the string into array
>   ('field1','field2','{ ex1; ex2; }','field3')
> so how should I use split(/????/) for this purpose?
> thanks in advance.

perhaps perlfaq4 will be of some assistance:

perlfaq4.pod:=head2 How can I split a [character] delimited string
except when inside [character]? (Comma-separated files)

the example therein involves splitting on commas except
when inside quotes, but the problem is the same.

regards
andrew


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

Date: Fri, 11 Sep 1998 07:35:25 GMT
From: kuhnerts@my-dejanews.com
Subject: Redirect output to perl variable
Message-Id: <6tajrt$m4u$1@nnrp1.dejanews.com>

Hello,

I want to redirect an output from a system command to a perl variable.

system ( "echo Hello" );

How do I get the output "Hello" into a perl variable ?

Thanks,
  Stefan

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Thu, 10 Sep 1998 20:41:47 EDT
From: dblack@saturn.superlink.net (David A. Black)
Subject: Re: Returning objects? Is it possible?
Message-Id: <6t9rkb$5di$1@earth.superlink.net>

Hello -

Mark Lehrer <mark@satch.markl.com> writes:

>Hello.  I am trying to write a routine that returns an object, like
>so (simplified example):

>sub pick_shape {
>  if ($_[0] eq "square") {
>    return new square();
>  } else {
>    return new triangle();
>  }
>}


>So, if I call this:

>$foo=pick_shape("square");

>I cannot call methods of this object; for example, if I were to say:

>print STDOUT $foo->area();

>It gives me an error:

>Can't call method "area" without a package or object reference at ./test.pl line 11.


Well, you could do something like that, but why would you want to?
Anywhere you can say pick_shape("square"), you can say "new square"
(or Square, if you want to get all conventional).  What would be the
point of laundering the name of the class through a subroutine, instead
of just calling a constructor?

In case you want a demo:

#!/usr/local/bin/perl -w

package Square;
use strict;

sub new { bless {}, shift }
sub area { "Placeholder routine for area calculator\n" }

package main;

sub pick_shape { shift->new }

my $s = pick_shape("Square");
print $s->area;

__END__


but ... well, see above.  Incidentally, in a broader sense, returning
objects is not only possible but at the heart of the whole thing -
that's what constructors do, for example.
 

David Black
dblack@saturn.superlink.net


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

Date: 11 Sep 1998 06:26:16 GMT
From: rb1000@ix.netcom.com (Ron Bennett)
Subject: Search/Replace but Not under certain conditions. HOW?
Message-Id: <6tafq8$ktu$1@news1.epix.net>

I've read the groups, faqs, etc and am still mystified as to how to do this:

$body =~ s|(http://\S+)|<a href="$1">$1</a>|g;

Converts all strings begining with 'http://' to actual hypertext links and 
works fine.

BUT how do I code it so it does NOT match if the http://whatever address 
contains any '@' characters in it??

Ron Bennett



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

Date: Fri, 11 Sep 1998 02:58:03 -0400
From: "Paintbot" <news@paintbot.com>
Subject: Re: Search/Replace but Not under certain conditions. HOW?
Message-Id: <6tahm3$cki$1@ash.prod.itd.earthlink.net>

You know, I've had this problem a while and never really found an elegant
solution to do an "and not".  My kluge went something like this

$body=~/\@/ || $body=~s|(http://\S+)|<a href="$1">$1</a>|g;

So if it found the @, it would short circuit and not do the second half.  If
there's no at, then the first part is false, so the second part is
performed.  Ugly, but I couldn't figure out another way other than to use an
explicit "unless".  Which does the same thing...

unless ($body=~/\@/) {$body=~s|(http://\S+)|<a href="$1">$1</a>|g};

But you probably knew that.  I don't know the elegant solution.

Van


Ron Bennett wrote in message <6tafq8$ktu$1@news1.epix.net>...
>I've read the groups, faqs, etc and am still mystified as to how to do
this:
>
>$body =~ s|(http://\S+)|<a href="$1">$1</a>|g;
>
>Converts all strings begining with 'http://' to actual hypertext links and
>works fine.
>
>BUT how do I code it so it does NOT match if the http://whatever address
>contains any '@' characters in it??
>
>Ron Bennett
>




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

Date: Fri, 11 Sep 1998 07:34:53 GMT
From: Daniel Grisinger <dgris@rand.dimensional.com>
Subject: Re: Search/Replace but Not under certain conditions. HOW?
Message-Id: <6taj4o$6gd$1@rand.dimensional.com>

[posted to comp.lang.perl.misc and mailed to the cited author]

[note- comp.lang.perl is a dead group, please inform your admin]
In article <6tafq8$ktu$1@news1.epix.net>
rb1000@ix.netcom.com (Ron Bennett) wrote:

>$body =~ s|(http://\S+)|<a href="$1">$1</a>|g;

>BUT how do I code it so it does NOT match if the http://whatever address 
>contains any '@' characters in it??

s|(http://[^\s@]+)|<a href="$1">$1</a>|g;

dgris
-- 
Daniel Grisinger           dgris@perrin.dimensional.com
`Bangladesh.  Because life is too short to run bad code.'
                               Jon Orwant


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

Date: Fri, 11 Sep 1998 08:20:43 +0200
From: "Jakub Dadak" <dadman@brainsys.cz>
Subject: Socket.pm & print
Message-Id: <6tafvs$qf4$1@adis.cesnet.cz>

Hi,
    i need write simple TCP clinet and server in perl but i have
problem with print function. When client write with print function
line such as
$line = "ahoj\n"; print SOCK, $line
the server doesn't receive line ($line = <Client>) but when i use
syswrite SOCK, $line , 5
all goes all right. I think that print doesn't make flush output buffer.
But i don't know how to make it. Platform Linux.

Where is a problem ?
        Thank for answer


--
  ,{(~)~(},       Dadak Jakub             Brain Systems s.r.o.
,( ((~) ){){}     dadman at brainsys.cz   Rybkova 1
())~{)}{{}~()}    http://www.brainsys.cz  Brno 602 00
`~^    ^~{()}     Tel. +420 5 41148704    Fax. +420 5 41148852
           ~~     Motto:                  Things are different !

PS: Code for server is here.


Server :

#!/usr/bin/perl -Tw
require 5.002;
use strict;
use Socket;
use Carp;

my $port = shift || 6666;
my $proto = getprotobyname('tcp');
$port = $1 if $port =~ /(\d+)/; # untaint port number

socket(Server, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
setsockopt(Server, SOL_SOCKET, SO_REUSEADDR, pack("l", 1)) or die
"setsockopt: $!";
bind(Server, sockaddr_in($port, INADDR_ANY))        || die "bind: $!";
listen(Server,SOMAXCONN)                            || die "listen: $!";
print "Server started on port $port\n";

  my $paddr;

$SIG{CHLD} = \&REAPER;

for ( ; $paddr = accept(Client,Server); close Client) {
    print "Connected\n";
    my $line;
    $line = <Client>;
    print Client $line;
}


Client:

#!/usr/bin/perl -w
require 5.002;
use strict;
use Socket;
my ($remote,$port, $iaddr, $paddr, $proto, $line);

$remote  = shift || 'localhost';
$port    = shift || 6666;  # random port
$iaddr   = inet_aton($remote)               || die "no host: $remote";
$paddr   = sockaddr_in($port, $iaddr);

$proto   = getprotobyname('tcp');
socket(SOCK, PF_INET, SOCK_STREAM, $proto)  || die "socket: $!";
connect(SOCK, $paddr)    || die "connect: $!";
$line = "ahoj\n";
# syswrite(SOCK, $line, 5);            # FAIL
print SOCK "$line\n";                  # OK

$line = <SOCK>;
print "Vysledek = $line\n";

close (SOCK) || die "close: $!";







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

Date: Thu, 10 Sep 1998 23:58:21 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Socket.pm & print
Message-Id: <MPG.106269e8190516c6989844@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <6tafvs$qf4$1@adis.cesnet.cz> on Fri, 11 Sep 1998 08:20:43 
+0200, Jakub Dadak <dadman@brainsys.cz> says...
 ...
> When client write with print function line such as
> $line = "ahoj\n"; print SOCK, $line
> the server doesn't receive line ($line = <Client>) but when i use
> syswrite SOCK, $line , 5
> all goes all right. I think that print doesn't make flush output buffer.

See perlfaq5: "How do I flush/unbuffer a filehandle? Why must I do this?"

Before printing to the socket, try:

my $old_fh = select SOCK; # Save current default output fh & set to SOCK.
$| = 1;                   # Disable buffering on fh SOCK.
select $old_fh;           # Restore previous default output fh.

Alternatively, you can just do:

select SOCK;
$| = 1;

and the succeeding 'print's by default will go to SOCK instead of 
whatever it was previously (presumably STDOUT).

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 11 Sep 1998 06:19:47 GMT
From: ptm@xact.co.uk (Paul Mahoney)
Subject: SQL-Retrivers - Informix server won't start
Message-Id: <6tafe3$ftk$1@xact.xact.co.uk>

I've broken something 'cos sqlr.inf40.d used to start and work. But now, 
having enabled debugging I see the following in the debug trace.

Sep  10 23:17:58: [8137] sqlr.inf40.d: g_Argc=3, g_NSM=1, g_PortNumber=0
Sep  10 23:17:58: [8137] sqlr.inf40.d: findNS(bcast = 0)
Sep  10 23:17:58: [8137] sqlr.inf40.d: presetNS(4505260, 0)
Sep  10 23:17:58: [8137] sqlr.inf40.d: presetNS: returning override NULL
Sep  10 23:17:58: [8135] pclist: createClientSocket:
  connect(193.195.28.204 (210 1)) errno 115
Sep  10 23:17:58: [8137] sqlr.inf40.d:
  usptcp_RegisterUspName: (\\xact\sqlrinf,0.0.0.0 (2225)) returning 33
Sep  10 23:17:58: [8137] sqlr.inf40.d:
  createServerSocket: usptcp_RegisterUspName(\\xact\sqlrinf) failed, errno 9
Sep  10 23:17:58: [8137] sqlr.inf40.d:
  svcvw_initialize: createServerSocket failed (errno 9)

I just can't figure out what's it's complaining about...

--
---
Paul Mahoney, X-Act Solutions Limited
smail: Owlsmead, Meads Road, Little Common, Bexhill-on-Sea, East Sussex TN39 4SY
email: ptm@xact.co.uk -- phone: [+44/0] 1424 847800 -- fax: [+44/0] 1424 847801


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

Date: Fri, 11 Sep 1998 06:33:56 GMT
From: ashtar@my-dejanews.com
Subject: TCP sockets and broken pipes
Message-Id: <6tag8l$h4d$1@nnrp1.dejanews.com>

How can my client test if it is still connected to
my server?

I tried

if (print SOCK "\n") {
	stuff;
}

but when the server dies, the client does too.
'Broken pipe' it say!

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 11 Sep 1998 03:28:54 GMT
From: "Dmytry Khodorkovsky" <yu207526@yorku.ca>
Subject: Re: Where to start?
Message-Id: <01bddd34$59b64fc0$cb7a3f82@warez.ibm.net>

Hi Chris,
I use IE 3.02 at home and found the same problem
Also I discovered that some servers use extension "*.cgi" for
perl program. I use it for my cgi programming.
I'm beginner in Perl, but do some steps ahead.


						Dmytry Khodorkovsky
e-mail: dmkhodor@yucc.yorku.ca
url:      www.yucc.yorku.ca/~dmkhodor





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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 3689
**************************************

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