[12785] in Perl-Users-Digest
Perl-Users Digest, Issue: 195 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 20 00:07:22 1999
Date: Mon, 19 Jul 1999 21:05:09 -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 Mon, 19 Jul 1999 Volume: 9 Number: 195
Today's topics:
Re: A Query about Remote Commands/Xterms/Displays and S (Anno Siegel)
Re: a thread on threads <onecor@hotmail.com>
Re: Any idea why this won't work? <laughingotter@foxinternet.net>
C & Perl... <richj@home.com>
Re: C & Perl... <richj@home.com>
Re: DBM problem: very weird! (Anno Siegel)
Re: how to execute aliased command from Perl script?(+) (Anno Siegel)
Re: How to remove a char from end of file <laughingotter@foxinternet.net>
Re: Listing Files <cmd@maths.uq.edu.au>
Re: Listing Files <cmd@maths.uq.edu.au>
Re: Listing Files (Abigail)
Re: Listing Files (Abigail)
Re: Listing Files <rra@stanford.edu>
Re: Listing Files <kmsproule@worldnet.att.net>
Need help with socket loop! <dbohling@pacbell.net>
Need help with socket loop! <dbohling@pacbell.net>
Need help with socket loop? <dbohling@pacbell.net>
PERL & SQL ether_nut@my-deja.com
Re: PERL & SQL <cmd@maths.uq.edu.au>
Re: PERL & SQL (Abigail)
Re: PERL & SQL <rereidy@uswest.net>
Re: Programming problem (Randal L. Schwartz)
Re: runs okay in shell, not in browser (Tad McClellan)
Re: runs okay in shell, not in browser <attapola@hotmail.com>
Simple Question: how to add another element to an array <rriley@umd5.umd.edu>
Re: Simple Question: how to add another element to an a (Anno Siegel)
Re: Simple Question: how to add another element to an a <bwalton@rochester.rr.com>
Re: Simple Question: how to add another element to an a (Larry Rosler)
Re: symbolic ref or hard ref? (Anno Siegel)
weird getc behaviour (Anno Siegel)
Re: weird getc behaviour (Anno Siegel)
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 20 Jul 1999 03:13:57 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: A Query about Remote Commands/Xterms/Displays and Such
Message-Id: <7n0phl$pl0$1@lublin.zrz.tu-berlin.de>
Robert R. Jackson <jackrr@aud.alcatel.com> wrote in comp.lang.perl.misc:
>Folks,
>
>I'm planning to design a tool will execute remote commands from a script.
>
>The idea here is I write some commands and tell them which machines to run on.
>
>So far, so good right.
>
>Now what if one of those commands launched an xterm window
>
>on another machine and I know what to send more commands through that XTERM (setting
>the Display, etc..). Is this doable?
Not a sentence, and not a perl question by any interpretation. But no,
the display must be set when the xterm is started, via the DISPLAY variable
or otherwise. You can't change it after the fact.
>And??? Could that "sub process" working with the xterm window launch a remote command on a
>
>another machine?
Sure. You type an rsh command into the window.
>Can the Perl "NET" module handle this kind of stuff?
You mean, can the Net (not NET) module pretend someone is typing
into an xterm window (not clear on what machine)? I don't think so.
Oh, and make your lines a little shorter. 72 characters is a useful
length.
Anno
------------------------------
Date: Tue, 20 Jul 1999 04:03:12 GMT
From: "Tiro Verus" <onecor@hotmail.com>
Subject: Re: a thread on threads
Message-Id: <932443392.529492@router1.nyct.net>
> :I definitely agree. Yesterday, I went hunting for some old post with
> :benchmarks. I gave up. Having to loadi over 50k for each and every
> :article is total and utter nonsense. Slow as mail.
Try the below:
http://www.webnexus.com/users/paik/search.html
http://www.exit109.com/~jeremy/news/deja.html Deja Power Search
If I only had to fill out their questionnaire, say, once a day,
I could live with the changes better. But all that extraneous
matter for each back post is hard to take.
--
your deed of goodness and kindness will hasten the redemption
http://www.universalperfection.org
------------------------------
Date: Mon, 19 Jul 1999 19:22:43 -0700
From: Steve Laybourn <laughingotter@foxinternet.net>
Subject: Re: Any idea why this won't work?
Message-Id: <3793DD73.574D032C@foxinternet.net>
Hello, John:
This is an easy one. You cannot include a postfix on a form tag, so:
<form method="GET" action="/cgi-bin/example.cgi?input=test">
will not work. But, however, if you do this:
<form method="GET" action="/cgi-bin/example.cgi">
<input type=hidden name="input" value="test">
it will work. The same thing applies to using internal hyperlinks on a web
page (the # sign after a URL).
I'll have to agree with Mr Flavell's opinion, though. This is an HTML
question, not a Perl question. I just answered it because we're cooler (by
simple definition) than the HTML filk.
Hope this will help!
Be seeing you...
Steve Laybourn, Occasionally Coherent Perl Programmer
Laughing Otter Computing Services
e-mail: otter101@hotmail.com
John Straumann wrote:
> Hey all:
>
> I have a CGI that accepts input from a text field, and I want to be able
> to hard code the input using a line like this:
>
> <form method="GET" action="/cgi-bin/example.cgi?input=test">
>
> But this will not work.
>
> Does anyone know why?
>
> John Straumann.
------------------------------
Date: Tue, 20 Jul 1999 03:52:45 GMT
From: Joan Richards <richj@home.com>
Subject: C & Perl...
Message-Id: <3793F23D.3FA040F5@home.com>
I need to access some data strctures written in C via Perl...Can I do
this? Now, i don't need to write to these data structures, I just need
to get what's in them and print them out. I've looked in the faq's
etc., and noticed a reference to h2p something, but that didn't seem to
be what I was looking for. Is it? If so, are there any better
references to how to use the h2p stuff online?
mitch
------------------------------
Date: Tue, 20 Jul 1999 03:57:03 GMT
From: Joan Richards <richj@home.com>
Subject: Re: C & Perl...
Message-Id: <3793F33F.CC9E4BF3@home.com>
> references to how to use the h2p stuff online?
>
> mitch
hehe, i sent this from my sisters account...ooops. my name is mitch
though.
------------------------------
Date: 20 Jul 1999 01:35:13 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: DBM problem: very weird!
Message-Id: <7n0joh$pbd$1@lublin.zrz.tu-berlin.de>
Zeng <zeng@haas.Berkeley.EDU> wrote in comp.lang.perl.misc:
First off, it's customary on usenet to place your comments *after*
the quoted text, and also to trim the quoted stuff to what is
necessary to get the context.
>I believe what I did is just following an example given on page 270-271
>of Programming Perl by Larry Wall, etc (the camel book). The only
>difference is that I have the 'dbmopen %tmp' there. But after getting
>rid of that, it still behaves strangely as before. What gives? What is
>the correct way to do a hash of hashes?
Well, the code you posted bears little resemblance to the examples on
the pages you cite. After getting rid of (deleting?) the dbmopen it
doesn't make any sense because the hash %rmp is now undefined, so the
while-loop isn't executed at all. Show us what you have now,
maybe someone will see what's wrong.
Anno
Zeng's original code:
>> > dbmopen %tmp, "tmp", 0644 || die "Can't open file ";
>> > dbmopen %rmp, "rmp", 0644 || die "Can't open file ";
>> >
>> > while (($y, $a) = each %rmp) {
>> > ($n, $t, $g) = split($y);
>> >
>> > $u = &some_subroutine;
>> >
>> > @Keys = keys %{$tmp{$u}};
>> > print "KEY1, @Keys \n";
>> > @Keys = keys %{$tmp{$u}};
>> > print "KEY2, @Keys \n";
------------------------------
Date: 20 Jul 1999 03:29:19 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: how to execute aliased command from Perl script?(+)
Message-Id: <7n0qef$pm9$1@lublin.zrz.tu-berlin.de>
Artem Trunov <artem@dancer.physics.louisville.edu> wrote in comp.lang.perl.misc:
>for example, if "ll" is an alias for "ls -al"
>
>then
>
>system ("ll") ;
>
>or
>
>$status=`ll`;
>
>will return error: "Cant exec: no suxh file or directory";
Sure. Perl is not your shell, how is it supposed to know about
aliases?
Anno
------------------------------
Date: Mon, 19 Jul 1999 20:04:21 -0700
From: Steve Laybourn <laughingotter@foxinternet.net>
Subject: Re: How to remove a char from end of file
Message-Id: <3793E735.EC10F130@foxinternet.net>
Hello again:
I made a typo in the multi-line code.
>foreach $x(0 .. $#clams) { print OTTER "$clam[$x]\n"; }
should read:
>foreach $x(0 .. $#clams) { print OTTER "$clams[$x]\n"; }
A single typo, but this particular one would have been fatal.
$clam[...] was never defined, so that statement would essentially replace
all records with undef values.
I hope this gets to you before you try it.
Or that you backed your databases up before you tried this. I've learned
to do this quite often.
Be seeing you,
Steve Laybourn, Delta Green Section
Laughing Otter Computing Services
e-mail: otter101@hotmail.com
Dariush wrote:
> Hi everyone;
>
> How can I remove a character form the end of a file. looks like an ascii
> char. A square bracket.
> How Can I remove this character.?
>
> Thank you.
> Please send response to
>
> Teamlinux@hotmail.com
>
> Thank you.
------------------------------
Date: Tue, 20 Jul 1999 12:06:40 +1000
From: chrisd <cmd@maths.uq.edu.au>
Subject: Re: Listing Files
Message-Id: <3793D9B0.9680D1CF@maths.uq.edu.au>
opendir(DIR, "/");
while ($file = <DIR>) {
push @array, $file;
}
not that I'm completely au fait with this
Chris.
Ashish Kadakia wrote:
>
> Hi, I would like to list all the files starting with the
> root directory..
> Can anyone point me how to do that?
>
> * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
> The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: Tue, 20 Jul 1999 12:09:40 +1000
From: chrisd <cmd@maths.uq.edu.au>
Subject: Re: Listing Files
Message-Id: <3793DA64.31300D10@maths.uq.edu.au>
Sorry, my bad
opendir(DIR, "/");
foreach $file (readdir(DIR)) {
push @array, $file;
}
close(DIR);
Ashish Kadakia wrote:
>
> Hi, I would like to list all the files starting with the
> root directory..
> Can anyone point me how to do that?
>
> * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
> The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: 19 Jul 1999 20:59:34 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Listing Files
Message-Id: <slrn7p7lv3.oqh.abigail@alexandra.delanet.com>
Ashish Kadakia (anonymous@web.remarq.com) wrote on MMCXLVIII September
MCMXCIII in <URL:news:932424514.5244@www.remarq.com>:
|| Hi, I would like to list all the files starting with the
|| root directory..
|| Can anyone point me how to do that?
system 'find / -type f -print';
Abigail
--
perl -e '$a = q 94a75737420616e6f74686572205065726c204861636b65720a9 and
${qq$\x5F$} = q 97265646f9 and s g..g;
qq e\x63\x68\x72\x20\x30\x78$&eggee;
{eval if $a =~ s e..eqq qprint chr 0x$& and \x71\x20\x71\x71qeexcess}'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 19 Jul 1999 21:00:48 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Listing Files
Message-Id: <slrn7p7m1e.oqh.abigail@alexandra.delanet.com>
Ashish Kadakia (anonymous@web.remarq.com) wrote on MMCXLIX September
MCMXCIII in <URL:news:932432425.6381@www.remarq.com>:
// that's on UNIX system.
// I want to on NT system, with Perl and put the list into an
// array.
@array = qx /whatever-the-command-on-NT-is/;
Please ask in an NT group for the command.
Abigail
--
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
print } sub __PACKAGE__ { &
print ( __PACKAGE__)} &
__PACKAGE__
( )
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 19 Jul 1999 19:57:17 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Listing Files
Message-Id: <ylk8rw6naq.fsf@windlord.stanford.edu>
chrisd <cmd@maths.uq.edu.au> writes:
> Sorry, my bad
> opendir(DIR, "/");
> foreach $file (readdir(DIR)) {
> push @array, $file;
> }
> close(DIR);
readdir understands context.
@array = readdir DIR;
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Mon, 19 Jul 1999 21:04:14 -0700
From: "Kevin M. Sproule" <kmsproule@worldnet.att.net>
Subject: Re: Listing Files
Message-Id: <7n0sdf$bjb$1@bgtnsc03.worldnet.att.net>
Ashish Kadakia wrote in message <932424514.5244@www.remarq.com>...
>Hi, I would like to list all the files starting with the
>root directory..
>Can anyone point me how to do that?
>
>
>
>* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network
*
>The fastest and easiest way to search and participate in Usenet - Free!
What the previous examples lack in functionality they make up for in
brevity. ;) The request was to list "all" the files starting with the root
directory. Here a a working WIN32 solution.
>>> Start Code <<<
#!/perl/bin/perl.exe
# walker.pl - Walks a win32 directory structure. Kevin Sproule 7/19/1999
$level=0;
# @array=();
sub recur {
my $file = shift;
local *DIR;
my $newpath;
$level++;
unless (opendir(DIR, $file)) {
$level--;
return;
}
foreach $entry (readdir(DIR)) {
if ($level == 1) {
print $file.$entry,"\n";
# push @array,$file.$entry;
} else {
print $file."\\".$entry,"\n";
# push @array,$file."\\",$entry;
}
if ($level == 1) {
$newpath=$file.$entry;
} else {
$newpath=$file."\\".$entry;
}
recur($newpath) unless ($entry eq "." | $entry eq "..");
}
closedir(DIR);
$level--;
}
my $start=shift;
if ($start eq "") {
print "Usage: walker DRIVE:\\[directory\\]\n";
exit;
}
if (substr($start,-1) ne "\\") { $start.="\\" }
recur($start);
>>> End Code <<<
To iterate is human, to recurse devine.
------------------------------
Date: Mon, 19 Jul 1999 18:41:29 -0700
From: Daniel Bohling <dbohling@pacbell.net>
Subject: Need help with socket loop!
Message-Id: <932434951.1654692910@news.pacbell.net>
Hi all. I'm trying to adapt the unix domain client/server found
in the
camel book. I'm simply trying to get the client and server to "chat" at
this point. They connect to one another just fine and will send single
messages but if i try to make them loop while reading from STDIN (on
client) to STDOUT (on server) it just sits. I assume it has something to
do with buffering?
Also is it possible to have two loops running at the same time?
Maybe
more clearer -- is there a non-forking, non-shell, non(cmd &) way to
launch a loop within a singular perl program that can get STDIN and
STDOUT while another loop does likewise?
I guess i mean a subroutine that runs parrallel with the main program.
Here's my code -- okay the camel book's, but butchered by me...And
thanks for even looking at it!
=======================client=================================
#!/usr/bin/perl -w
use diagnostics;
use CGI qw(param);
use Socket;
use strict;
#$| = 1;
my ($rendezvous, $linein, $lineout);
$rendezvous = shift || '/home/httpd/html/img/streamsocket';
socket(SOCK, PF_UNIX, SOCK_STREAM, 0) || die "Socket: $!\n";
connect(SOCK, sockaddr_un($rendezvous)) || die "Connect: $!\n";
print SOCK "Connected here";
print STDOUT "Connected here\n";
while ($linein = <SOCK>) {
print STDOUT $linein;
}
#while ($lineout = <STDIN>) {
# print SOCK $lineout;
#}
#$linein = <SOCK>;
#print $linein;
close SOCK;
exit 0;
=====================server===========
#!/usr/bin/perl -w
use diagnostics;
use CGI qw(param);
use Socket;
use strict;
#######################this is the server -- we only want one to feed
numerous clients and to clean up the disk
#######PREPARE USER DEFINED FUNCTIONS
sub logmsg;
#######BEGIN BODY
#$| = 1;
my $NAME = '/home/httpd/html/img/streamsocket';
my $uaddr = sockaddr_un($NAME);
my $proto = getprotobyname('tcp');
socket(Server, PF_UNIX, SOCK_STREAM, 0) || die "Socket: $!\n";
unlink($NAME);
bind(Server, $uaddr);
listen(Server, SOMAXCONN);
logmsg "Server started on $NAME";
my $waitpid = 0;
my $paddr;
#$SIG{CHLD} = \&REAPER; ###IF I FORK IS THIS A LOOPING FORMULA ALLOWING
THE REST OF PROGRAM TO CONTINUE?
for ( ; $paddr = accept(Client,Server); ) {
logmsg "connection on $NAME";
my $in;
print Client "Hey there bonehead\n";
#print Client $in;
while ($in = <STDIN>) {
#print STDOUT "$in\n";
print Client "$in\n";
}
}
################################SUBROUTINES FROM HERE ON DOWN
#sub REAPER {
#$waitpid = wait;
#$SIG{CHLD} = \&REAPER;
#logmsg "reaped $waitpid" . ($? ? "with exit $?" : "");
#}
########LOGMSG
sub logmsg {
open(LOG, ">>/home/httpd/html/img/logserver.txt"); #GONNA HAVE TO FLOCK
HERE|| die "Cant do any logging because: $!\n";
print LOG "$0 $$: @_ at ",scalar localtime, "\n";
print STDOUT "$0 $$: @_ at ",scalar localtime, "\n";
}
------------------------------
Date: Mon, 19 Jul 1999 20:27:24 -0700
From: Daniel <dbohling@pacbell.net>
Subject: Need help with socket loop!
Message-Id: <3793EC9C.BD4C986C@pacbell.net>
Hi all. I'm trying to adapt the unix domain client/server found
in the
camel book. I'm simply trying to get the client and server to "chat" at
this point. They connect to one another just fine and will send single
messages but if I try to make them loop while reading from STDIN (on
server) to STDOUT (on client) it just sits. When I do a ^d it sends
everything i'd typed in including newlines. I assume it has something to
do with buffering?
Also is it possible to have two loops running at the same time?
Maybe
more clearer -- is there a non-forking, non-shell, non(cmd &) way to
launch a loop within a singular perl program that can get STDIN and
STDOUT while another loop does likewise?
I guess i mean a subroutine that runs parallel with the main program.
Here's my code -- okay the camel book's, but butchered by me...And
thanks for even looking at it!
=======================client=================================
#!/usr/bin/perl -w
use diagnostics;
use CGI qw(param);
use Socket;
use strict;
#$| = 1;
my ($rendezvous, $linein, $lineout);
$rendezvous = shift || '/home/httpd/html/img/streamsocket';
socket(SOCK, PF_UNIX, SOCK_STREAM, 0) || die "Socket: $!\n";
connect(SOCK, sockaddr_un($rendezvous)) || die "Connect: $!\n";
print SOCK "Connected here";
print STDOUT "Connected here\n";
while ($linein = <SOCK>) {
print STDOUT $linein;
}
#while ($lineout = <STDIN>) {
# print SOCK $lineout;
#}
#$linein = <SOCK>;
#print $linein;
close SOCK;
exit 0;
=====================server===========
#!/usr/bin/perl -w
use diagnostics;
use CGI qw(param);
use Socket;
use strict;
#######################this is the server -- we only want one to feed
numerous clients and to clean up the disk
#######PREPARE USER DEFINED FUNCTIONS
sub logmsg;
#######BEGIN BODY
#$| = 1;
my $NAME = '/home/httpd/html/img/streamsocket';
my $uaddr = sockaddr_un($NAME);
my $proto = getprotobyname('tcp');
socket(Server, PF_UNIX, SOCK_STREAM, 0) || die "Socket: $!\n";
unlink($NAME);
bind(Server, $uaddr);
listen(Server, SOMAXCONN);
logmsg "Server started on $NAME";
my $waitpid = 0;
my $paddr;
#$SIG{CHLD} = \&REAPER; ###IF I FORK IS THIS A LOOPING FORMULA ALLOWING
THE REST OF PROGRAM TO CONTINUE?
for ( ; $paddr = accept(Client,Server); ) {
logmsg "connection on $NAME";
my $in;
print Client "Hey there bonehead\n";
#print Client $in;
while ($in = <STDIN>) {
#print STDOUT "$in\n";
print Client "$in\n";
}
}
################################SUBROUTINES FROM HERE ON DOWN
#sub REAPER {
#$waitpid = wait;
#$SIG{CHLD} = \&REAPER;
#logmsg "reaped $waitpid" . ($? ? "with exit $?" : "");
#}
########LOGMSG
sub logmsg {
open(LOG, ">>/home/httpd/html/img/logserver.txt"); #GONNA HAVE TO FLOCK
HERE|| die "Cant do any logging because: $!\n";
print LOG "$0 $$: @_ at ",scalar localtime, "\n";
print STDOUT "$0 $$: @_ at ",scalar localtime, "\n";
}
------------------------------
Date: Mon, 19 Jul 1999 18:53:21 -0700
From: Daniel <dbohling@pacbell.net>
Subject: Need help with socket loop?
Message-Id: <3793D691.C5772CB3@pacbell.net>
Hi all. I'm trying to adapt the unix domain client/server found
in the
camel book. I'm simply trying to get the client and server to "chat" at
this point. They connect to one another just fine and will send single
messages but if i try to make them loop while reading from STDIN (on
client) to STDOUT (on server) it just sits. I assume it has something to
do with buffering?
Also is it possible to have two loops running at the same time?
Maybe
more clearer -- is there a non-forking, non-shell, non(cmd &) way to
launch a loop within a singular perl program that can get STDIN and
STDOUT while another loop does likewise?
I guess i mean a subroutine that runs parrallel with the main program.
Here's my code -- okay the camel book's, but butchered by me...And
thanks for even looking at it!
=======================client=================================
#!/usr/bin/perl -w
use diagnostics;
use CGI qw(param);
use Socket;
use strict;
#$| = 1;
my ($rendezvous, $linein, $lineout);
$rendezvous = shift || '/home/httpd/html/img/streamsocket';
socket(SOCK, PF_UNIX, SOCK_STREAM, 0) || die "Socket: $!\n";
connect(SOCK, sockaddr_un($rendezvous)) || die "Connect: $!\n";
print SOCK "Connected here";
print STDOUT "Connected here\n";
while ($linein = <SOCK>) {
print STDOUT $linein;
}
#while ($lineout = <STDIN>) {
# print SOCK $lineout;
#}
#$linein = <SOCK>;
#print $linein;
close SOCK;
exit 0;
=====================server===========
#!/usr/bin/perl -w
use diagnostics;
use CGI qw(param);
use Socket;
use strict;
#######################this is the server -- we only want one to feed
numerous clients and to clean up the disk
#######PREPARE USER DEFINED FUNCTIONS
sub logmsg;
#######BEGIN BODY
#$| = 1;
my $NAME = '/home/httpd/html/img/streamsocket';
my $uaddr = sockaddr_un($NAME);
my $proto = getprotobyname('tcp');
socket(Server, PF_UNIX, SOCK_STREAM, 0) || die "Socket: $!\n";
unlink($NAME);
bind(Server, $uaddr);
listen(Server, SOMAXCONN);
logmsg "Server started on $NAME";
my $waitpid = 0;
my $paddr;
#$SIG{CHLD} = \&REAPER; ###IF I FORK IS THIS A LOOPING FORMULA ALLOWING
THE REST OF PROGRAM TO CONTINUE?
for ( ; $paddr = accept(Client,Server); ) {
logmsg "connection on $NAME";
my $in;
print Client "Hey there bonehead\n";
#print Client $in;
while ($in = <STDIN>) {
#print STDOUT "$in\n";
print Client "$in\n";
}
}
################################SUBROUTINES FROM HERE ON DOWN
#sub REAPER {
#$waitpid = wait;
#$SIG{CHLD} = \&REAPER;
#logmsg "reaped $waitpid" . ($? ? "with exit $?" : "");
#}
########LOGMSG
sub logmsg {
open(LOG, ">>/home/httpd/html/img/logserver.txt"); #GONNA HAVE TO FLOCK
HERE|| die "Cant do any logging because: $!\n";
print LOG "$0 $$: @_ at ",scalar localtime, "\n";
print STDOUT "$0 $$: @_ at ",scalar localtime, "\n";
}
------------------------------
Date: Tue, 20 Jul 1999 01:11:05 GMT
From: ether_nut@my-deja.com
Subject: PERL & SQL
Message-Id: <7n0ib0$dkp$1@nnrp1.deja.com>
I've been working on a PERL/SQL script that runs a simple query
like : select distinct
c.rowid
c.column_name
c.column_names
from c.table_name
where c.rowid='rowid' and
c.column_name = ..etc
After the query runs I can get it to generate a file & it will run
the results through SQL*PLUS no problem, but I'm having problems making
the query info show up on output from the PERL script (It's a web page
which is embedded in PERL).
Does anyone have an example of a good way to display the query results
in PERL. (any example will do)
Thanks
Dave
dave@worldexpress.com
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 20 Jul 1999 12:04:12 +1000
From: chrisd <cmd@maths.uq.edu.au>
Subject: Re: PERL & SQL
Message-Id: <3793D91C.AA91B640@maths.uq.edu.au>
Have you looked at the DBI and DBD::MySql modules?
ether_nut@my-deja.com wrote:
>
> I've been working on a PERL/SQL script that runs a simple query
> like : select distinct
> c.rowid
> c.column_name
> c.column_names
> from c.table_name
> where c.rowid='rowid' and
> c.column_name = ..etc
> After the query runs I can get it to generate a file & it will run
> the results through SQL*PLUS no problem, but I'm having problems making
> the query info show up on output from the PERL script (It's a web page
> which is embedded in PERL).
>
> Does anyone have an example of a good way to display the query results
> in PERL. (any example will do)
>
> Thanks
>
> Dave
> dave@worldexpress.com
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
------------------------------
Date: 19 Jul 1999 21:02:27 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: PERL & SQL
Message-Id: <slrn7p7m4h.oqh.abigail@alexandra.delanet.com>
ether_nut@my-deja.com (ether_nut@my-deja.com) wrote on MMCXLIX September
MCMXCIII in <URL:news:7n0ib0$dkp$1@nnrp1.deja.com>:
!!
!! but I'm having problems making
!! the query info show up on output from the PERL script (It's a web page
!! which is embedded in PERL).
!!
!! Does anyone have an example of a good way to display the query results
!! in PERL. (any example will do)
With other words, you haven't tried at all and want to get a free ride?
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Mon, 19 Jul 1999 21:36:27 -0600
From: Ron Reidy <rereidy@uswest.net>
Subject: Re: PERL & SQL
Message-Id: <3793EEBB.6F69958F@uswest.net>
ether_nut@my-deja.com wrote:
> I've been working on a PERL/SQL script that runs a simple query
> like : select distinct
> c.rowid
> c.column_name
> c.column_names
> from c.table_name
> where c.rowid='rowid' and
> c.column_name = ..etc
> After the query runs I can get it to generate a file & it will run
> the results through SQL*PLUS no problem, but I'm having problems making
> the query info show up on output from the PERL script (It's a web page
> which is embedded in PERL).
>
> Does anyone have an example of a good way to display the query results
> in PERL. (any example will do)
>
> Thanks
>
> Dave
> dave@worldexpress.com
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
Queries do not generate files!
How are you doing it in perl?
perldoc DBI
perldoc CGI
--
Ron Reidy
Oracle DBA
Reidy Consulting, L.L.C.
------------------------------
Date: 19 Jul 1999 19:02:26 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Programming problem
Message-Id: <m1aess13kd.fsf@halfdome.holdit.com>
>>>>> "Abigail" == Abigail <abigail@delanet.com> writes:
Abigail> goto (qw(LABEL0 LABEL1 LABEL2 LABEL3
Abigail> LABEL4 LABEL5 LABEL6)) [$count % 7];
hey, let's optimize that computed goto:
goto sprintf "LABEL%d", $count % 7;
That's so scary that it works. And here's the old fortran "goto less equal greater":
goto (qw(LESS EQUAL GREATER))[($a <=> $b)+1]
Eeek. :)
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Mon, 19 Jul 1999 16:11:23 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: runs okay in shell, not in browser
Message-Id: <bp00n7.cj4.ln@magna.metronet.com>
lmoloch@my-deja.com wrote:
: Subject: runs okay in shell, not in browser
Perl FAQ, part 9:
"My CGI script runs from the command line but not the browser.
(500 Server Error)"
: I've been puzzling over this piece of code for some time now. It runs
: perfectly when I execute it by typing in its name (or when I type "perl
: userlog.cgi", but the script refuses to run if I call it via a web
: browser-- it displays only a small part of the middle of the expected
: output:
So there must be something different in the environment then.
Like:
a different current directory
a different path
a different set of environment variables
: for (`who`) {
Try giving the complete path to who, in case it is not in
the WWW server's path.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 20 Jul 1999 08:55:05 +0700
From: "Paul A." <attapola@hotmail.com>
Subject: Re: runs okay in shell, not in browser
Message-Id: <7n0kq7$nhb$1@chatta.samart.co.th>
<lmoloch@my-deja.com> wrote in message news:7n08np$a3r$1@nnrp1.deja.com...
> Here is the script:
> ----------------------
> #!/bin/perl
> # userlog.cgi
>
> print "Content-type: text/html", "\n\n";
> print "<HTML>", "\n\n";
> print "<HEAD>", "\n\n";
> print "<TITLE>", "Users logged in ","</TITLE>","\n\n";
> print "</HEAD>","\n\n";
> print "<BODY>\n";
>
> %ucnt = ();
> for (`who`) {
> s/\s.*\n//;
> $ucnt{$_}++;
> }
>
> @users = sort keys %ucnt;
> print "Users logged in: @users\n";
>
>
> foreach $user (@users) {
> print "<A HREF=\"mailto:$user\@microsoftschoolver1.edu\">$user</A>
> <BR> ";
>
> }
> print "\n", "</BODY>","\n\n";
> print "</HTML>","\n\n";
> ---------------
> Any idea why it doesnt run thru a browser?
> (file permissions are 755)
Make sure you have perl in /bin. Also check permission of user who run
httpd. Your code work fine in my server.
Hope this help.
Nobi
------------------------------
Date: Mon, 19 Jul 1999 23:29:17 -0400
From: Winston Riley IV <rriley@umd5.umd.edu>
Subject: Simple Question: how to add another element to an array
Message-Id: <3793ED0D.36D58F2@umd5.umd.edu>
This seems so simple that I can't believe I need to ask. . . but I do!
I have an array (@AlumniData) which I need to add another element to
($NewLine). the program than sorts and write the array back to a file.
I have spent two nights trying to figure this silly thing out. I must be
overlooking the obvious.
Any help is recieved with many thanks.
<<< Rex >>>
------------------------------
Date: 20 Jul 1999 03:44:05 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Simple Question: how to add another element to an array
Message-Id: <7n0ra5$pni$1@lublin.zrz.tu-berlin.de>
Winston Riley IV <rriley@umd5.umd.edu> wrote in comp.lang.perl.misc:
>This seems so simple that I can't believe I need to ask. . . but I do!
>
>I have an array (@AlumniData) which I need to add another element to
>($NewLine). the program than sorts and write the array back to a file.
>
>I have spent two nights trying to figure this silly thing out. I must be
>overlooking the obvious.
perldoc -f push
perldoc -f unshift
perldoc -f splice
>Any help is recieved with many thanks.
My pleasure.
Anno
------------------------------
Date: Mon, 19 Jul 1999 23:55:24 -0400
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Simple Question: how to add another element to an array
Message-Id: <3793F32C.6BCC8B18@rochester.rr.com>
Winston Riley IV wrote:
> This seems so simple that I can't believe I need to ask. . . but I do!
>
> I have an array (@AlumniData) which I need to add another element to
> ($NewLine). the program than sorts and write the array back to a file.
...
How about:
push @AlumniData,$NewLine;
print join "\n",sort @AlumniData;
, assuming your lines don't already end with "\n"?
------------------------------
Date: Mon, 19 Jul 1999 21:01:48 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Simple Question: how to add another element to an array
Message-Id: <MPG.11fd9482266b0903989cff@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <3793ED0D.36D58F2@umd5.umd.edu> on Mon, 19 Jul 1999 23:29:17
-0400, Winston Riley IV <rriley@umd5.umd.edu> says...
> I have an array (@AlumniData) which I need to add another element to
> ($NewLine). the program than sorts and write the array back to a file.
perldoc -f push
perldoc -f sort
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 20 Jul 1999 03:01:25 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: symbolic ref or hard ref?
Message-Id: <7n0oq5$pjn$1@lublin.zrz.tu-berlin.de>
Chao Fang <cfang@nwu.edu> wrote in comp.lang.perl.misc:
>I ran into some syntax that is not in any textbooks about Perl.
>I have a package like:
>
>package WordNet;
>%noun;
The above line does nothing. Why is it there?
>sub new {
> .....
>}
>............
>1;
>
>in package main, I have to use
> $noun = WordNet::noun;
Bareword. Ick. What makes you say you have to use that?
>It seems like $noun is a symbolic reference and I can use %$noun to deref
>it. ref($noun) returns null.
You assigned the string 'WordNet::noun' to $noun. That doesn't make
$noun a symref per se, it's just a string. If you insist on dereferencing
it in %$noun, perl is compliant and dereferences it for you.
>But if I change the WordNet package a little like:
>$noun = \%{ an anonymous hash};
What do you mean by change? I don't see a line in your first version
of the package that corresponds to this one. Anyway, you do make
$noun a hard reference this way. If you do that while "package WordNet"
is in effect, $noun is really $WordNet::noun.
>I will have to write
> $noun = ${WordNet::noun};
>in main to get a ref. This time the $noun in main is a hard ref, with
>ref($noun) returning HASH.
Yes. How is that amazing? I can't see any unexpected behavior in
what you describe. Only some constructs that are discouraged, namely
a variable in void context and a bareword for a string.
Anno
------------------------------
Date: 20 Jul 1999 02:02:28 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: weird getc behaviour
Message-Id: <7n0lbk$pfc$1@lublin.zrz.tu-berlin.de>
Thomas Ruedas <ruedas@geophysik.uni-frankfurt.de> wrote in comp.lang.perl.misc:
>Hello,
>here's a problem with getc which I can't understand. I'm writing a Perl
>script to extract \cite commands from a LaTeX file. This is a short test
>version:
>#!/usr/local/bin/perl5
>$infile=$ARGV[0];
>$outfile=join("-",("cite",$infile));
>open (OUTFILE,">$outfile");
>open (INFILE,"$infile");
>while ($char = getc INFILE) {
If $char is '0' that will be a boolean false, so your loop ends.
try
while ( defined ($char = getc INFILE) ) {
> print $char;
>}
>close (INFILE);
>close (OUTFILE);
>exit;
>
>The while loop is quit for some mysterious reason before reading the 0
>in the last line of the following LaTeX snippet:
>\@addtoreset{table}{subsection}
>...
>% redefine subparagraph title appareance
>\titleformat{\subparagraph}[runin]{\normalfont\itshape}{}{0pt}{}
Do you really need to process the file one character at a time?
Or it that a vestige from former C programming. From what you say
above, a loop like
while ( $line = <INFILE> ) {
if ( $line =~ /\\cite/ ) {
# process line
}
}
might serve you better.
Anno
------------------------------
Date: 20 Jul 1999 02:09:49 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: weird getc behaviour
Message-Id: <7n0lpe$ph0$1@lublin.zrz.tu-berlin.de>
Eric Bohlman <ebohlman@netcom.com> wrote in comp.lang.perl.misc:
>Thomas Ruedas (ruedas@geophysik.uni-frankfurt.de) wrote:
[...]
>: while ($char = getc INFILE) {
>
>This is what's causing your problem. If getc() returns a '0' or a
>whitespace character, you'll drop out of the loop.
If whitespace worked as you claim, the loop wouldn't reach the '0'
that is actually throwing it.
Anno
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
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 V9 Issue 195
*************************************