[11596] in Perl-Users-Digest
Perl-Users Digest, Issue: 5196 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 22 07:07:36 1999
Date: Mon, 22 Mar 99 04:00:22 -0800
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, 22 Mar 1999 Volume: 8 Number: 5196
Today's topics:
[HELP] How to restrict other sites to link my documents (Sbin Lin)
Re: Accessing NT ACLs remotely <carvdawg@patriot.net>
Re: adding a number to an existing value in another fil <Philip.Newton@datenrevision.de>
Re: adding a number to an existing value in another fil <cschmitz@stud.informatik.uni-trier.de>
Bug in Queue.pm ? <alexandre.bustico@cenatoulouse.dgac.fr>
embeded Perl on Win32 <Piotr.Martyniuk@softax.com.pl>
Re: Environment strings <bret@bordwell.com>
Hello! one cgi question sachin@surya.pune.lucent.com
Re: help with perl and win98 <seannln@bit-net.com>
Re: Here 's a good one !!! <Philip.Newton@datenrevision.de>
Re: Ms-Mail from perl massimobalestra@my-dejanews.com
Net::FTP <brandeda@se.bel.alcatel.be>
Re: Newbie perl/CGI question (Part II) <Tony.Curtis@vcpc.univie.ac.at>
One liner? (Sara Young)
Re: One liner? cschmitz@stud.informatik.uni-trier.de
Re: One liner? <All@n.due.net>
Re: Perl question <imagee@image-engineering.co.uk>
PERL TCP issue (Tim Judd)
Possible values for $^O? <Philip.Newton@datenrevision.de>
Re: Possible values for $^O? <rwolfe@rwolfe.com>
removing ASCII chars < 32 <wk@rayleigh.ecs.soton.ac.uk>
Re: removing ASCII chars < 32 (Bart Lateur)
return codes in Win32 Perl <pmak@iname.com>
Re: Sending to multiple recipients via Sendmail (Jonathan Stowe)
Re: Sending to multiple recipients via Sendmail (Jonathan Stowe)
Re: Sockets question for Win32 (Lars Gregersen)
Re: Tie::File::URL (was Re: URGENT help required!!) (Bart Lateur)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 22 Mar 1999 11:57:24 GMT
From: sbin@cs.nthu.edu.tw (Sbin Lin)
Subject: [HELP] How to restrict other sites to link my documents?
Message-Id: <7d5b74$c92$1@news.cs.nthu.edu.tw>
Hi,
Could anyone tell me how to restrict other sites to
link my documents (just like images). I want to protect my images
which would not be retrived directly by other sites.
I mean the images could just be retrived from the web pages in my site.
Is it possible? If yse, how can it do that?
Thankx in advance......
Regards,
Sbin Lin
sbin@ma.ks.edu.tw
------------------------------
Date: Mon, 22 Mar 1999 05:42:47 +0000
From: Marquis de Carvdawg <carvdawg@patriot.net>
Subject: Re: Accessing NT ACLs remotely
Message-Id: <36F5D857.73B5D98@patriot.net>
> > I am working on a way to access Registry and Dir/file
> > ACLs within my domain, all from my box. I want to move
> > away from using DumpACL and make it 100% Perl.
> >
> > Which modules can I use to get the Registry and Dir ACLs?
> >
> > Again, I need to do remotely...the assumption is that as I
> > am Domain Admin, I will be able to do so.
>
> You're in luck if you've got a modern version of ActivePerl.
> Check out the Win32 modules. Particularly Win32::TieRegistry .
> If you want to get really down and dirty, there's
> Win32API::Registry too. And Win32::NetAdmin and
> Win32::NetResource . There are some nice examples of NT admin
> code in back issues of The Perl Journal too, and they're
> well worth the price.
Dave,
Thanks. I've been looking at Win32::TieRegistry, but I don't see (maybe
not clearly enough...) how to access the Registry ACLs...even locally.
And
that doesn't help me with the Dir ACLs at all.
Do you have some code snippets that I could look at? I'd appreciate
it...
Carv
------------------------------
Date: Mon, 22 Mar 1999 11:44:46 +0100
From: Philip Newton <Philip.Newton@datenrevision.de>
Subject: Re: adding a number to an existing value in another file
Message-Id: <36F61F1E.3B433F08@datenrevision.de>
TinP wrote:
>
> Also I was wondering if someone answers my question what is the proper
> netiquette?Should I write back a thanks? Of course I appreciate the help but
> don't want to clog the thread with a useless post of thanks even though I am
> thankful.
Probably best to e-mail them directly if you want to thank them.
Cheers,
Philip
------------------------------
Date: 22 Mar 1999 11:07:34 GMT
From: Christoph Schmitz <cschmitz@stud.informatik.uni-trier.de>
Subject: Re: adding a number to an existing value in another file
Message-Id: <7d589m$3e9$1@fu-berlin.de>
TinP <tgj@snip..net> wrote:
: In one file I have a database of scores
: filename scores.txt
: Tom | 56
: In another file I have another list of names and scores for this week.
: scores_this_week.txt
: Tom | 3
: Sue | 15
: What I wanted to do was this:
: If the name isn't already in the scores.txt file I want to add the name and
: the score. That is easy enough for me but If the name already exists, I want
: to just add the new value to the current number that is already there. Any
: suggestions on how do that?
Hi Tom,
I hacked up a little program that might solve your problem. It uses a hash
to store the name/value pairs, reads the two files (the first while loops)
and outputs the new scores to a file calles scores_added.txt. You may want
to change scores_added.txt to scores.txt in the Perl code, but be aware that
this overwrites your original scores.txt file.
I hope this helps,
Christoph
--------- cut here -------------
%scores = ();
open OLD, "< scores.txt" or die "can't open scores.txt";
while (<OLD>) {
chop;
($name, $score) = split /\|/;
$name =~ s/\s//g; # trim whitespace
$score =~ s/\s//g;
$scores{$name} = $score;
}
close OLD;
open THISWEEK, "< scores_this_week.txt" or die "can't open s_t_w";
while (<THISWEEK>) {
chop;
($name, $score) = split /\|/;
$name =~ s/\s//g; # trim whitespace
$score =~ s/\s//g;
# if $scores{$name} exists, the new score is added;
# if it doesn't, it's created, initialized to 0 and
# then the new score is added
$scores{$name} += $score;
}
close THISWEEK;
open ADDED, "> scores_added.txt" or die "can't open s_a.txt";
foreach $key (keys %scores) {
print ADDED $key.'|'.$scores{$key}."\n";
}
close ADDED;
--------- cut here -------------
--
-- Christoph Schmitz <cschmitz(at)stud.informatik.uni-trier.de> --
Whoever has lived long enough to find out what life is, knows how deep a debt
of gratitude we owe to Adam, the first great benefactor of our race. He
brought death into the world. -- Mark Twain, "Pudd'nhead Wilson's Calendar"
------------------------------
Date: 19 Mar 1999 16:13:52 +0100
From: Alexandre BUSTICO <alexandre.bustico@cenatoulouse.dgac.fr>
Subject: Bug in Queue.pm ?
Message-Id: <qdlngtms0f.fsf@cenatoulouse.dgac.fr>
It seems to me there is a bug in queue.pm :
sub dequeue_nb {
use attrs qw(locked method);
my $q = shift;
if (@$q) {
return shift @$q;
} else {
return undef;
}
}
sub enqueue {
use attrs qw(locked method);
my $q = shift;
push(@$q, @_) and cond_broadcast $q;
}
If i well understand this pragma, use attrs qw(locked method)
will ensure that no more than one thread be could call
the same method on the same object. But more than
1 thread could call 2 differents methods on the same object.
If my understanding is all right, two thread could
apply method dequeue_nb and enqueue on the same
object and in this case it could be a
non protected concurrent access on @$q list.
If it was possible, it would be preferable to lock
the object, not the method.
any work around ?
--
Alexandre Bustico
Email: Alexandre.Bustico@cenatoulouse.dgac.fr
CENA 7 avenue Edouard Belin BP 4005 | Phone: (+33) 05 62 25 95 41
31055 Toulouse Cedex, FRANCE | Fax: (+33) 05 62 25 95 99
------------------------------
Date: Mon, 22 Mar 1999 11:33:26 +0100
From: "Piotrek" <Piotr.Martyniuk@softax.com.pl>
Subject: embeded Perl on Win32
Message-Id: <7d56fr$5cl$1@euler.softax.com.pl>
Hello
I wanted to port a program which is internaly using Perl from Linux to
WinNT.
And I had a problem with linking it. There were many unresolved symbols
like:
PL_na, PL_Xpv, PL_stack_max, PL_stack_base and more.
So I took this sample program from perlembed documentation
("Evaluating a Perl statement from your C program")
#include <EXTERN.h>
#include <perl.h>
static PerlInterpreter *my_perl;
main (int argc, char **argv, char **env)
{
char *embedding[] = { "", "-e", "0" };
my_perl = perl_alloc();
perl_construct( my_perl );
perl_parse(my_perl, NULL, 3, embedding, NULL);
perl_run(my_perl);
/** Treat $a as an integer **/
perl_eval_pv("$a = 3; $a **= 2", TRUE);
printf("a = %d\n", SvIV(perl_get_sv("a", FALSE)));
/** Treat $a as a float **/
perl_eval_pv("$a = 3.14; $a **= 2", TRUE);
printf("a = %f\n", SvNV(perl_get_sv("a", FALSE)));
/** Treat $a as a string **/
perl_eval_pv("$a = 'rekcaH lreP rehtonA tsuJ'; $a = reverse($a);", TRUE);
printf("a = %s\n", SvPV(perl_get_sv("a", FALSE), PL_na));
perl_destruct(my_perl);
perl_free(my_perl);
}
The results of linking it were following:
cl /c /nologo /FoDEBUG/test_perl.obj /Ic:/perl/lib/MSWin32-x86/Core
/DWIN32 /D_WINDOWS /DMSWIN32 /DWIN32IO_IS_STDIO /DDEBUG_CODE /D_DEBUG /GX
/GR
/FD /ZI /Yd /MDd /W3 /Gm /Zi /Od test_perl.cxx
test_perl.cxx
c:\sources\mci\aaa\test_perl.cxx(30) : warning C4508: 'main' : function
should r
eturn a value; 'void' return type assumed
link /NOLOGO /OUT:DEBUG/testperl.exe c:/perl/lib/MSWin32-x86/
Core/perl.lib /DEBUG DEBUG/test_perl.obj
test_perl.obj : error LNK2001: unresolved external symbol
"__declspec(dllimport)
unsigned int PL_na" (__imp_?PL_na@@3IA)
DEBUG/testperl.exe : fatal error LNK1120: 1 unresolved externals
As you see I compiled it with Microsoft VC (6.0).
I tried it with perl 5.005, 5.004 and also last ActiveState distribution.
This error was in all cases.
Can anybody help me to make this thing work?
Thanks.
Piotrek
------------------------------
Date: Mon, 22 Mar 1999 06:33:14 -0500
From: Bret Bordwell <bret@bordwell.com>
Subject: Re: Environment strings
Message-Id: <36F62A7A.3497@bordwell.com>
Ronald J Kimball wrote:
>
> In that case, it must be your code. Environment variables simply don't
> work that way.
>
> Perhaps it's an error on line 17?
>
Funny, line 17.
Well, maybe some other value is being held, or something, 'cause it's
weird.
Now I'm a seasoned programmer with over 12 years doing this stuff for
DOS and Windows. I'm a bit new
with Perl... so give me a break.
When I make a play, and log off to come back the next day, and make 1
play, it works just fine, and I can
continue this, making a play, one per day, or every 6 hours or so, and
it works just fine. But when
I make a play, immediatly get my mail, then respond to that mail, it
craps out and uses a previous value
it had received, screwing it up. (this is the EXACT Same code)
Again, this can be tested at:
http://www.bordwell.com/sevenhtml/aformdev.html
and the rules to the game are at:
http://www.bordwell.com/sevenhtml
------------------------------
Date: Mon, 22 Mar 1999 10:47:26 GMT
From: sachin@surya.pune.lucent.com
Subject: Hello! one cgi question
Message-Id: <7d573s$99m$1@nnrp1.dejanews.com>
Hello guys!
I am newbie, just want to read from a file and write to some other file..I am
able to read from the file, but whenever i open a new file and write to it,
everything goes right...but no file is created actually.....Whether cgi-bin
evironment puts a restriction on creating files....
Sachin Goyal
Bachelor of Enginneering (Computer Science)
BITS- PIlani INDIA
sachin_goyal@mailcity.co
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Sun, 21 Mar 1999 08:09:02 -0500
From: Sean Phillips <seannln@bit-net.com>
To: Andrew Tipson <atipson@wesleyan.edu>
Subject: Re: help with perl and win98
Message-Id: <36F4EF6D.23849CDE@bit-net.com>
Andrew - See my comments in the code...
#!/usr/bin/perl -w
require 5.002;
use strict;
use Socket;
my ($host, $file, $proto, $port, $hisiaddr, $hispaddr, $cmdline,
$lineindex, $therest, $cookie);
$cmdline = shift || 'http://localhost/';
# Takes the arguement off of ARGV or uses http://localhost/ if there is
none.
# REMOVE for a pure web implementation and set $cmdline to what ever
host you
# want. i.e. 'http://www.slashdot.org/ultramode.txt';
$cookie = shift || '';
# REMOVE for a pure web implementation or if you don't want to convey
that you have
# any COOKIE info for the server.
$lineindex = index $cmdline, '//';
if ($lineindex < 0) {
$therest = $cmdline;
} else {
$therest = substr $cmdline, $lineindex + 2;
}
$lineindex = index $therest, '/';
$host = substr $therest, 0, $lineindex;
# Host should now contain "http://www.slashdot.org/"
$file = substr $therest, $lineindex;
# File should now contain "ultramode.txt"
$proto = getprotobyname('tcp');
$port = getservbyname('http', 'tcp') || 80;
# Port is normally 80.
$| = 1;
$hisiaddr = inet_aton($host) || die "unknown host";
$hispaddr = sockaddr_in($port, $hisiaddr);
socket(SOCKET, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
connect(SOCKET, $hispaddr) || die "bind: $!";
select(SOCKET); $| = 1; select(STDOUT);
print SOCKET "GET $file HTTP/1.0\n";
print SOCKET "Host: $host\n";
if ($cookie ne "") {
print SOCKET "Cookie: $cookie\n";
}
# REMOVE for a pure web implementation or if you don't want to convey
that you have
# any COOKIE info for the server.
print SOCKET "\n";
while (<SOCKET>) {
print STDOUT $_;
# Here we are retrieving the page line by line. You could, instead of
printing these, add them to an array using the statement "push @myarray,
$_" then later process the lines - or you could make a giant string out
of the page by using the statement '$mystring .= "$_\n"' then later
process the string...
}
close(SOCKET);
print STDOUT "\n";
The point is this, the script is void of any debug information due to
the fact that it (or a variant of it) has been solidly for two years
now. In each comment I tell you what the script is expecting - stick
some print statements in there to see what you are actually getting.
Some other hints... The script is definitely expecting a filename.
getdoc http://www.linux.org will fail where getdoc http://www.linux.org/
will succeed. The trailing '/' represents the filename passed to the
server.
Now, I suspect that you want this as a function since the input is a
simple string and the output is either a string or an array - converting
this into a function should be very easy...
- Sean
Andrew Tipson wrote:
> I mean I'd like to be able to run the script independently of the
> command
> line, simply from a link on a webpage, and it's not completely clear
> to me
> where "slashdot.org" or "ultramode.txt" would fit into the script you
> displayed. Part of the reason I don't think my perl is configured
> properly
> is that I can't seem to get any response from the command line- I've
> tried
> every modifier every script- no response- just another empty line.
> But
> scripts that I run normally, calling them from a webpage, work great.
>
> Sean Phillips wrote:
>
> > Andrew -
> >
> > What messages do you get when you try to run the script?
> > What do you mean by "...make this script work independantly"?
> >
> > - Sean
> >
------------------------------
Date: Mon, 22 Mar 1999 11:08:00 +0100
From: Philip Newton <Philip.Newton@datenrevision.de>
Subject: Re: Here 's a good one !!!
Message-Id: <36F61680.F1F6D64A@datenrevision.de>
Jim and Paula wrote:
>
> On Sat, 20 Mar 1999 00:18:15 GMT, nospam@here.com wrote:
>
> >If you're using NT you can set a buffer size for your command prompt
> >window. Then all you have to do is scroll up to your first error.
>
> The best solution for me was to discover Uedit, which lets you run
> perl from the editor, then captures err or std output to a file that
> it loads for your perusal. I tried a few other editors and they did
> fine on most compilers but gave me fits on Perl. Uedit seems to have
> no problems.
PFE, the Programmer's File Editor available from
http://www.lancs.ac.uk/people/cpaap/pfe , works fine for me -- it can
also run commands and capture output. I use Windows 95 but PFE is also
available for Win 3.1 and WinNT (Intel and Alpha).
Cheers,
Philip
------------------------------
Date: Mon, 22 Mar 1999 08:54:40 GMT
From: massimobalestra@my-dejanews.com
Subject: Re: Ms-Mail from perl
Message-Id: <7d50gd$47i$1@nnrp1.dejanews.com>
Thank you to everyone answered to my question.
My problem is that Ms-Mail (at least what we have installed here) is not an
SMTP server.
I tried to connect to the usual port (25) of he SMTP protocol but it does not
work, it uses a proprietary protocol.
My question is: Is there someone who knows how this protocol works?
Thank you again
Massimo
> > massimobalestra@my-dejanews.com wrote:
> > : Hi, Does somebody knows if there is a way to send a mail Through a server
> > : Microsoft Mail (Ms-Mail) without having a gateway? Or (Off Topic) does
> > : exists there a (freeware) gateway from unix to ms-mail?
> >
> > : I know perl and unix but not ms-mail server.
> >
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 22 Mar 1999 12:25:12 +0100
From: David Van den Brande <brandeda@se.bel.alcatel.be>
Subject: Net::FTP
Message-Id: <36F62898.BE457922@se.bel.alcatel.be>
Hi,
is there a Net::FTP command that changes the local working directory ?
Or, is there a way to give a local path within a get command
$ftp->get(/home/usr/tmp/localfilename,remotefilename) ?
Thanks,
David
--
V David Van den Brande, Trainee at
----------------- Alcatel Switching VE27
| A L C A T E L | Fr. Wellesplein 1 - 2018 Antwerp - Belgium
----------------- mailto:David.Van_den_Brande@alcatel.be
------------------------------
Date: 22 Mar 1999 09:57:29 +0100
From: Tony Curtis <Tony.Curtis@vcpc.univie.ac.at>
Subject: Re: Newbie perl/CGI question (Part II)
Message-Id: <837ls97vgm.fsf@vcpc.univie.ac.at>
Re: Newbie perl/CGI question (Part II), q969
<q969@truman.edu> said:
q969> open (LOG, ">>datafile"); $DataLen =
q969> $ENV{'CONTENT_LENGTH'}; read (STDIN,
q969> ...
Move to the CGI.pm module. It will make life much
much easier in the future.
hth
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien. | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds! | private email:
Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: 22 Mar 1999 09:25:38 GMT
From: syoung@actcom.co.il (Sara Young)
Subject: One liner?
Message-Id: <7d52ai$pp$1@lnews.actcom.co.il>
Let's say you have an array of @positions and a $delimiter.
Your task is to take a $line and insert the delimiter in the correct
character locations. For example, if:
@positions = (4, 6);
$line = 'hello there';
$delimiter = ',';
Then the output should be:
hel,lo, there
Is it possible to do this with one line of code?
Sara
------------------------------
Date: 22 Mar 1999 09:59:47 GMT
From: cschmitz@stud.informatik.uni-trier.de
Subject: Re: One liner?
Message-Id: <7d54aj$1lv$1@fu-berlin.de>
Sara Young <syoung@actcom.co.il> wrote:
: Let's say you have an array of @positions and a $delimiter.
: Your task is to take a $line and insert the delimiter in the correct
: character locations. For example, if:
: @positions = (4, 6);
: $line = 'hello there';
: $delimiter = ',';
: Then the output should be:
: hel,lo, there
: Is it possible to do this with one line of code?
How about
$i=0; foreach $p ($positions) { substr($line,$p+$i++,1) .= $delimiter }
This yields
hello, t,here
which is not exactly what you specified, but then, what does (4,6) mean
in your example? The above line inserts the $delimiter after the fourth
and sixth positions in the original $line, counting from zero. I guess
that's what you wanted?
PS. The $i++ is needed because the $line gets longer after each insert.
If the delimiter is to be longer than 1 character, you would have
to write
$i=0;
$d = length $delimiter;
foreach $p ($positions) {
substr($line,$p+$i,1) .= $delimiter
$i += $d;
}
That's not technically a one-liner, but if you shorten the names of
$positions and $delimiter, you might be able to squeeze it into one line.
Hope this helps,
Christoph
--
-- Christoph Schmitz <cschmitz(at)stud.informatik.uni-trier.de> --
Brian: You are all individuals!
The Crowd: We are all individuals! -- Life of Brian (1979)
------------------------------
Date: Mon, 22 Mar 1999 11:18:07 GMT
From: "Allan M. Due" <All@n.due.net>
Subject: Re: One liner?
Message-Id: <PFpJ2.5595$DM5.2279@news.rdc1.ct.home.com>
Sara Young <syoung@actcom.co.il> wrote in message
news:7d52ai$pp$1@lnews.actcom.co.il...
: Let's say you have an array of @positions and a $delimiter.
: Your task is to take a $line and insert the delimiter in the correct
: character locations. For example, if:
: @positions = (4, 6);
: $line = 'hello there';
: $delimiter = ',';
: Then the output should be:
: hel,lo, there
:
: Is it possible to do this with one line of code?
Needs the latest version of perl, otherwise move the foreach.
#!/usr/local/bin/perl -w
#use strict;
my @positions = (4, 6);
my $line = 'hello there';
my $delimiter = ',';
substr($line,$_,0,$delimiter) foreach (@positions);
print $line;
HTH
AmD
------------------------------
Date: Mon, 22 Mar 1999 08:35:36 +0000
From: Richard Watkins <imagee@image-engineering.co.uk>
Subject: Re: Perl question
Message-Id: <36F600D8.643DD73D@image-engineering.co.uk>
> The command I've
> used is $value[$n] =~ s/\n/ /; But this never works (I've tried
> changing the 's' to a 'tr'). I get the same output to the text file
> whether I include this line or not.
This seems glaringly obvious to me, so much so I'm questioning whether
it is the solution since I do not rate myself as a Perl expert.
Should you not use $value[$n] =~ s/\n/ /g; instead, the g forces a
global substitute, ie. replaces of the newlines instead of just the
first one it finds.
If this solves the problem I'm a happy man, I know more Perl than I
thought!!
Richard.
--
Image Engineering - Constructing your web presence.
http://www.image-engineering.co.uk
5, Mayfly Close, Chatteris, Cambs, PE16 6PF
Tel: 01354 696390 Mobile: 0966 389110
email: richard@image-engineering.co.uk
------------------------------
Date: Mon, 22 Mar 1999 03:52:44 -0800
From: dev@null.org (Tim Judd)
Subject: PERL TCP issue
Message-Id: <dev-2203990352450001@a48-07-09.pdx.du.teleport.com>
I have a script that for the life of me, I can not get working. I just
try to send a couple commands over a connected socket and get responses
back (for right now) - I know perl connects because I see the welcome
message. I appreciate any help, as I am finding this now entreaging,
simple file manipulation is easy now. I thought I would get a challenge.
:) Thanks.
Help Appreciated, Flames are ignored.
Here's my script.
#!perl -w
use Socket;
$PORT = getservbyname("119",'tcp');
$IPPACK = inet_aton("news.teleport.com");
$SOCKADDR = sockaddr_in("119", $IPPACK);
$PROTO = getprotobyname('tcp');
socket(NNTP, PF_INET, SOCK_STREAM, $PROTO) || die "socket: $!";
connect(NNTP, $SOCKADDR) || die "connect: $!";
while (defined($line = <NNTP>)) {
print $line;
}
send(NNTP, "DATE\r\n", undef);
send(NNTP, "QUIT\r\n", undef);
close (NNTP) || die "close: $!";
--Anonymous (spammers beware.)
------------------------------
Date: Mon, 22 Mar 1999 11:38:54 +0100
From: Philip Newton <Philip.Newton@datenrevision.de>
Subject: Possible values for $^O?
Message-Id: <36F61DBE.938C272A@datenrevision.de>
Hi there,
there was a thread about finding out the OS a while back, which
mentioned $^O. What are the possible (or most common) values for $^O?
After all, this is one variable where you can't find out all the outputs
by trial and error, unless you have access to a whole lot of systems. On
my HP-UX box, $^O has the value 'hpux'. What others are there (for
commonly-used operating systems)? Does $^O differentiate between e.g.
Win95, Win98, WinNT, and Win2000?
Cheers,
Philip
------------------------------
Date: Mon, 22 Mar 1999 11:51:42 GMT
From: Richard Wolfe <rwolfe@rwolfe.com>
Subject: Re: Possible values for $^O?
Message-Id: <36F64B02.E0DC9A86@rwolfe.com>
That got me curious, too. I can provide these two:
MSWin32 (Windows 98)
linux (Caldera Linux)
-Richard
Philip Newton wrote:
>
> Hi there,
>
> there was a thread about finding out the OS a while back, which
> mentioned $^O. What are the possible (or most common) values for $^O?
> After all, this is one variable where you can't find out all the outputs
> by trial and error, unless you have access to a whole lot of systems. On
> my HP-UX box, $^O has the value 'hpux'. What others are there (for
> commonly-used operating systems)? Does $^O differentiate between e.g.
> Win95, Win98, WinNT, and Win2000?
>
> Cheers,
> Philip
------------------------------
Date: Mon, 22 Mar 1999 10:06:47 +0000
From: Wayne Keenan <wk@rayleigh.ecs.soton.ac.uk>
Subject: removing ASCII chars < 32
Message-Id: <36F61637.4AB81ACD@rayleigh.ecs.soton.ac.uk>
how can one remove ASCII chars < 32 in strings?
thanking you(s) premtively from the past to the future
Wayne
------------------------------
Date: Mon, 22 Mar 1999 10:36:06 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: removing ASCII chars < 32
Message-Id: <36f71c73.7597555@news.skynet.be>
Wayne Keenan wrote:
>how can one remove ASCII chars < 32 in strings?
If $string is the scalar holding your string:
$string =~ s/\000-\037//d;
The numbers are in octal, base 8, so "\037" is the character with Ascii
code 31.
Note that this will delete newlmines and tabs as well. Maybe you'd like
these to be converted to (single) spaces instead. Then, do the next
before the above:
$string =~ tr/\t\n / /s;
Bart.
------------------------------
Date: Mon, 22 Mar 1999 17:00:13 +0800
From: Phil Mak <pmak@iname.com>
Subject: return codes in Win32 Perl
Message-Id: <36F6069D.48ECD4CA@iname.com>
Hi,
I've set up a Perl program to delete certain files from a directory
running under Windows NT. For some reason, it is not doing it. When I
check the $? variable to find out the return code, it gives me the value
'65280'. Does anyone know what this means? Or can somebody direct me
to a web page that would contain a list of all the return codes and
their meanings? Just need someone to point me in the right direction.
Thanks,
Phil
------------------------------
Date: Mon, 22 Mar 1999 09:53:42 GMT
From: gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Sending to multiple recipients via Sendmail
Message-Id: <36f61289.3548258@news.dircon.co.uk>
On Sun, 21 Mar 1999 16:06:04 -0600, "Glen Lee Edwards"
<GLEdwards@christianfamilies.net> wrote:
>
>>or alternativley you could just set the Bcc: header to a list of the
>>intended recipients.
>
>I've done that, and received some very rude automated replys from systems
>for having a "rediculuously long header."
>
That shouldnt happen - from the sendmail manpage:
The Bcc: line will be deleted before transmission. Any addresses in
the argument list will be suppressed, that is, they will not receive
copies even if listed in the message header.
That is assumiong that you are using the -t switch to sendmailof
course.
/J\
------------------------------
Date: Mon, 22 Mar 1999 10:02:47 GMT
From: gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Sending to multiple recipients via Sendmail
Message-Id: <36f61347.3737944@news.dircon.co.uk>
On Sun, 21 Mar 1999 15:06:31 -0700, Martin Foster
<mfoster@spots.ab.ca> wrote:
>Jonathan Stowe wrote:
>>
>> In comp.lang.perl.misc Glen Lee Edwards <GLEdwards@christianfamilies.net> wrote:
>> > I have a small mailing list, about 25, that I use from a mailing program I
>> > wrote. Currently I am closing the pipe after each letter is sent and then
>> > reopening it for the next letter. Is there a way from a PERL program to
>> > notify Sendmail that one letter is finished and a new one is coming without
>> > closing and reopening the pipe?
>> >
>>
>> Err no you cant do that. But why would you want to ? there are other
>> facilities available to send mail to multiple recipients. If you are
>> using sendmail then you could set up an :include: file in your aliases file
>> or alternativley you could just set the Bcc: header to a list of the
>> intended recipients.
>>
>
>Could you not interface directly with the SMTP side of Sendmail. That
>way you would alleviate the need for having to open multiple pipes and
>it would allow you to make the script for system independent, since
>some people use Qmail, and Sendmail, and MS Echange et cetera.
>
Except of course Glen explicitly mentioned that he was using
'sendmail'. As has been discussed to death in comp.lang.perl.misc it
is in almost all cases preferable to use some reliable MTA such as
sendmail *where that is available* to deal with this stuff - I wont
rehearse the arguments here but a quick search of DejaNews will get a
broad spectrum of the various views around this.
>
>P-S. You can interface with SMTP directly by telneting into port 25
>of the server you deal with. Which in most cases will be localhost.
>
If using Perl and you need to do this then Net::SMTP is probably a
better solution - and I dont think that it is a safe assumption that
in all case the SMTP server will be on localhost - especially if one
isnt runnig unix.
/J\
------------------------------
Date: Mon, 22 Mar 1999 10:18:15 GMT
From: lg@kt.dtu.dk (Lars Gregersen)
Subject: Re: Sockets question for Win32
Message-Id: <36f61705.249778205@news.dtu.dk>
On Thu, 18 Mar 1999 23:00:28 -0600, "Chuck Hirstius"
<chirstius@mediaone.net> wrote:
>I have seen many examples of perl tcp client/servers for unix, and a few for
>Win32. But I have never seen a multi threaded server or client for Win32.
>I know that Threads are a bit buggy (or so last I heard), and fork() does
>not exist,
If you need to convert some Unix code fast that uses fork you can
always use the system function. This will be expensive though.
> so is there anyway to have bi-directional communication between
>client and server without spawning new threads under Win32? I'm just
You don't need threads/fork etc. for bidirectional communication. If
you need to handle more than one client from your application threads
can be a nice thing to have but this is not necessary.
>looking for a send/response here. Client connects, server sends a menu,
>client responds, server sends results, etc. If anyone can help or just
>point me to some Win32 specific examples of this setup I'd be grateful.
You don't need windows specific examples. This is already taken care
of by the Activestate people. Look at the example at the end of the
IO::Select documentation. Looking at the documentation for IO::Sockets
can't hurt either. Except for the fork thing everything works great on
Windows (as well as on Unix of course).
happy programming
Lars
------------------------------
Lars Gregersen (lg@kt.dtu.dk)
http://www.gbar.dtu.dk/~matlg
------------------------------
Date: Mon, 22 Mar 1999 11:51:51 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Tie::File::URL (was Re: URGENT help required!!)
Message-Id: <36f61e2e.8040305@news.skynet.be>
As promised... (posted and mailed)
Daniel Grisinger wrote:
>Below is a module that handles tying filehandles to URLs. It
>accepts a list of filenames that can contain both local
>files and URLs. I have no idea what it would mean to write
>to a URL, so I didn't implement that.
You *did* implement it, but as noops. It would be better to not
implement them at all. In this case using a function like print() on
such a handle would cause an error. That's the behaviour you should get.
print F "Oops!\n";
=>
Can't locate object method "PRINT" via package "TieHandle"
>**Start Tie/File/URL.pm**
>package Tie::File::URL;
>
>use strict;
>use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
>use LWP;
>use LWP::UserAgent;
>
>require Exporter;
>@ISA = qw(Exporter);
Since you don't export anything, you don't need this.
>$VERSION = '0.01';
>
># Preloaded methods go here.
>
>sub TIEHANDLE {
> my $class = shift;
> my $file = shift;
> my $self = { content => undef,
Why not simply '' instead of undef? You always assign something to it,
('' in case of errors) anyway.
> offset => 0 };
>
> if ($file =~ /^http:/) {
> my $ua = LWP::UserAgent -> new();
> my $req = HTTP::Request -> new (GET => $file);
> my $res = $ua -> request ($req);
> if ($res -> is_success()) {
> $self -> {content} = $res -> content();
> }
> else {
> warn "Couldn't open $file\n";
> $self -> {content} = '';
See?
> }
> }
> else {
> if (open (FH, $file)) {
> local $/;
> $self -> {content} = <FH>;
> }
> else {
> warn "Couldn't open $file: $!";
> $self -> {content} = '';
See?
> }
> }
> return bless $self, $class;
>}
>
># called as read(FH, $buf, $len, $offset)
>sub READ {
> my $self = shift;
> my $buf = \$_[0]; # modify $buf in place
> my (undef, $len, $offset) = @_;
I found a "better" alternative. I always wondered if that bizarre
equivalence:
\($a, $b) is equivalent to (\$a, \$b)
would have any use. And I found one. BTW on my system (Perl5.004),
"my(undef)" is not allowed.
my $buf = \(shift);
# takes a reference to the first item, and removes it
my ($len, $offset) = @_;
> $$buf = ''; # but clear it first
# wrong.
> $$buf = substr($self -> {content}, $offset, $len);
#very wrong
> $self -> {offset} += length ($$buf);
# partly wrong: add length of read string, not length of buffer
> return length $$buf;
# idem ditto: return same
>}
The above function does NOT behave at all like the built-in read(), for
the case where $$buf was not empty and $offset not zero.
This would be more like it, but it fails fatally if $offset is outside
the length of the original string:
substr($$buf,$offset)
= substr($self->{content}, $self->{offset}, $len);
Therefore, $$buf may NOT be cleared first.
Use is intended to append newly read bytes to (part of) the original
contents.
I noticed that if $offset is more than the original length of the
scalar, read would pad the scalar with null bytes. So this is my fully
functional attempt:
sub READ {
# called as read(FH, $buf, $len, $offset)
my $self = shift;
my $buf = \(shift);
# takes a reference to the first item, and removes it
my ($length, $offset) = @_;
$offset += 0 ; # convert to number; does NOT complain if undef
# but DOES complain if not a number
my $read = substr($self->{content}, $self->{offset}, $length);
$$buf = pack("a$offset",defined($$buf)?$$buf:'') . $read;
$self->{offset} += length($read);
return length($read);
}
># called as getc(FH);
>sub GETC {
> my $self = shift;
> my $offset = $self -> {offset};
> my $char = substr ($self -> {content}, $offset, 1);
> $offset++ if $char;
Oops. "0" is considered as false.
$offset += length($char) if defined $char;
> return $char;
>}
Actually, generally, GETC() coan be written in function of READ:
sub GETC {
my $self = shift;
my $buf;
READ($self, $buf, 1);
return $buf;
}
So I'm not sure why we need to implement it, anyway, except for
execution speed, and because of "special" files, such as the keyboard.
Hmm.
># called by <FH>
>sub READLINE {
> my $self = shift;
> my $offset = $self -> {offset};
> $offset ||= 0;
$offset += 0; #force numeric
> if ( $self -> {content} =~ /.{$offset}([^\n]*\n)/s ) {
OUCH! Extremely slow if using a large buffer! It returns undef for the
last line, instead of that line, if that wasn't terminated with newline.
And finally: why doesn't it use the value of $/ ?
> $self -> {offset} += length $1;
> return $1;
> }
> return undef;
>}
In ordinary cases ($/ is "\n"), this would work:
# called by <FH>
sub READLINE {
my $self = shift;
pos = $self->{offset} + 0; #starting point
if ($self->{content} =~ /(.*\n|.+)/g) {
# at least one character
$self->{offset} += length($1);
return $1;
}
return undef;
}
In case $/ must be fully supported (ugh!), this gets a LOT more
difficult. You could try a pattern like:
m[(.*?\Q$/\E|.+)]gs
(untested) but this has these disadvantages:
A) It doesn't support the exotic values for $/: undef for rest of file,
and empty string for paragraph mode (= at least two consecutive
newlines)
B) SLOW! The pattern needs to be recompiled every time. Daniel
Grisinger wrote me in e-mail that currently he uses a cached precompiled
regex, that needs recompilation only if $/ is different from the last
time the function was called. Hmm...
But actually: one of the shortcomings of $/, as many people see it, is
that it doesn't support regexes (apart from the paragraph mode). So why
not take this as an advantage, and implement the function using index()
instead.
# called by <FH>
sub READLINE {
my $self = shift;
my $start = $self->{offset} + 0;
return undef unless $start < length $self->{content}; # EOF
if(defined $/) {
if (length $/) { # ordinary case
my $end = index $self->{content}, $/, $start;
unless($end < 0) {
$self->{offset} = $end += length $/;
return substr($self->{content}, $start,
$end-$start);
}
} else { # paragraph mode
pos = $start;
if($self->{content} =~ /(.*?\n\n+|.+)/gs) {
$self->{offset} += length($1);
return $1;
}
}
}
# rest of file
$self->{offset} = length $self->{content};
return substr($self->{content},$start);
}
Elaborate, huh? I think so too. And, just like with GETC(), READLINE()
can easily be implemented in a general way based upon READ(): unless
buffered, read a chunk; search for $/, and if not found, read a new
chyunk and append it to the buffer, etc. until found, or eof.
So I bounce this back to the implementors. WHY do we have to emulate
Perl's built-in behaviour at all? Why can't this not be done
automatically by the tiehandle mechanism, for example, if the definition
for READLINE() is missing, and READ() is present?
>sub CLOSE {
> my $self = shift;
> return;
>}
Oops. This is a noop. It is NEVER called automatically.
>sub DESTROY {
> my $self = shift;
> return;
>}
This is the "close", but only called by untie(), NOT by close().
># do nothing, i'm not sure what writing to a URL means
>sub WRITE {
> return undef;
>}
>
>sub PRINT {
> return undef;
>}
>
>sub PRINTF {
> return undef;
>}
I think you'd better delete those.
>I don't know of any way to override CORE::open so that it
>will call my function instead. Tying filehandles solves
>part of the problem, but not all.
Well, actually... close() does nothing for tied filehandles. So you
should consider tie() to be the equivalent of open(), and untie() the
equivalent of close(). Therefore, the improved demo program could be be
like:
**Start tieurl**
#!/usr/local/bin/perl
# tieurl - testing an idea with tied filehandles
use Tie::File::URL;
my @files = qw!http://moiraine.dimensional.com/~dgris/home.html
http://slashdot.org
/home/dgris/.bashrc!;
for (@files) {
tie *F, 'Tie::File::URL', $_; #open
for (1..10) {
my $line = <F>;
last unless defined $line;
print $line;
}
untie *F; #close
}
Bart.
------------------------------
Date: 12 Dec 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 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 5196
**************************************