[17957] in Perl-Users-Digest
Perl-Users Digest, Issue: 117 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 22 11:05:33 2001
Date: Mon, 22 Jan 2001 08:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <980179508-v10-i117@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 22 Jan 2001 Volume: 10 Number: 117
Today's topics:
Re: bidirectional communication using sockets <sebastien.cottalorda@mageos.com>
Re: bidirectional communication using sockets <sebastien.cottalorda@mageos.com>
CGI - SSI <wolfgang.schrader@off1.siemens.de>
Re: DBI/Oracle why SPACE ? (Honza Pazdziora)
Re: Deleting a line from file (Garry Williams)
Directory Recursion Problem. <dajh101@yahoo.co.uk>
Re: Directory Recursion Problem. (Rafael Garcia-Suarez)
Re: Directory search without repeating (Martien Verbruggen)
Re: Directory search without repeating (Ross Clement)
Re: Directory search without repeating (Anno Siegel)
Re: Directory search without repeating (Anno Siegel)
Re: Getting past protected directories? (Abigail)
Re: input_record_separator error <apobull@my-deja.com>
Re: input_record_separator error (Anno Siegel)
Re: input_record_separator error (Bernard El-Hagin)
Re: input_record_separator error (Garry Williams)
Re: input_record_separator error (Bernard El-Hagin)
Re: input_record_separator error (Anno Siegel)
Inserting fields in place <seppy@chartermi.net>
Re: Newbie Perl Problem mintcake@my-deja.com
Re: percentages, how? (hymie!)
Re: percentages, how? <lmoran@wtsg.com>
stability of threads + interpreter performance <not@defined.com>
Re: Still Can't Get MIME Lite To Send Attachment... (Honza Pazdziora)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 22 Jan 2001 14:35:28 -0000
From: "Sébastien Cottalorda" <sebastien.cottalorda@mageos.com>
Subject: Re: bidirectional communication using sockets
Message-Id: <94hcri$1huf$1@news4.isdnet.net>
Hi,
Here is a couple of perl script that works perfectly for me.
CLIENT:
#!c:\perl\bin\perl -w
use IO::Socket;
$socket = IO::Socket::INET->new(PeerAddr=> '190.197.10.217',
PeerPort=> '123456',
Proto=> "tcp",
Type=> SOCK_STREAM)
or die "Couln\'t connect to 190.197.10.217:123456 $@\n";
$phrase = "How are you \?";
$socket->send("$phrase"."FIN",'') or die "Can\'t send $!\n";
print "> $phrase \n";
$data_read='seb';
ITER: while ($data_read) {
$socket->recv($data_read,'256') or die "Can\'t recv $!\n";
print "< $data_read \n" unless ($data_read=~/FIN/);
last ITER if ($data_read=~/FIN/);
}
$data_read=~s/FIN//;
print "< $data_read \n";
exit 0;
SERVEUR:
#!c:\perl\bin\perl -w
use IO::Socket;
use Carp;
use POSIX qw(strftime);
$port_recep='123456';
$server= IO::Socket::INET->new(LocalPort=> $port_recep,
Type=> SOCK_STREAM,
Reuse=>1,
Listen=>10)
or die "Couln\'t be a tcp server on $port_recep $@\n";
while ($client=$server->accept()) {
$data_read='seb';
ITER: while ($data_read) {
$client->recv($data_read,'256') or die "Can\'t recv $!\n";
print "< $data_read \n" unless ($data_read=~/FIN/);
last ITER if ($data_read=~/FIN/);
}
$data_read=~s/FIN//;
print "< $data_read \n";
$phrase = "I feel good thanks";
$client->send($phrase."FIN",'') or die "Can\'t send $!\n";
print "> $phrase \n";
}
exit 0;
The principe:
The client connect to the server and send pack of 256 bytes, when finishing,
it send the word "FIN". Then the client go into listenning position.
The server listen a connection, open the socket, read 256 bytes packets
until the reception of word "FIN" (you can choose what you want).
then the server send the answer finishing with the word "FIN" (you can
choose of course).
The client record the server listening by pack of 256 bytes until the word
"FIN".
Then it close the connection.
This is the first version of my program, I've then replaced "FIN" by "\r" :
Carriage Return
BE VERY CAREFULL, it's very easy to make deadlock with that method : Server
listening and client listening too.
Hope this helps.
Sebastien
<mmustafa@my-deja.com> a écrit dans le message :
942bgq$aj5$1@nnrp1.deja.com...
> Hi,
> I am trying to write a PERL program using sockets. One side ( which
> we call client ) is communicating with the listener ( which we call
> server) thru a specific port. This is working fine.
> The problem i am running into is after sending a couple of strings
> (haven't been able to pass an array), the listener/ server reads it,
> and does some processing. But if the listener wants to send some
> response back to the client, the client can't read it. I will give a
> brief code summnary here ( rather then the whole thing ) , this didn't
> work :
> CLIENT CODE :
> #socket initializination, $port and $server are arguments
> socket(SOCKET, PF_INET, SOCK_STREAM, (getprotobyname('tcp'))[2]);
> connect (SOCKET, pack('Sna4x8', AF_INET, $port,
> (gethostbyname($server))[4]))
> || die "Can't connect to server $server on port $port .\n";
> SOCKET->autoflush();
>
>
> print SOCKET "Command1 \r\n";
> print SOCKET "Command2 \r\n";
>
> # I need to read response from the server :
> # did NOT WORK
> # shutdown(SOCKET,1);
> # while (<SOCKET>) {
> # while (defined ($string = <SOCKET>) ) {
> recv(SOCKET,$string,100,0);
> if ($string) {
> $string = $_;
> print "STRING : ****($string)****\n";
> if ($string == 1) {
>
>
> I tried threading the process , which created further problems ( maybe
> programing error).
> I tried shutdown , which also on the server side, so that the client
> doesn't keep on waiting ( according to the documentation , recv will
> keep on waiting).
>
>
> Here is a snippet of SERVER CODE :
> $server = IO::Socket::INET->new( Proto => 'tcp',
> LocalPort => $DEFAULT_PORT,
> Listen => SOMAXCONN,
> Reuse => 1);
>
> while(<$server>)
> {
> chomp($_);
> print "Value of i = $i and this is what I got
> from the other machine: **($_)** \n";
> autoflush $server 5;
> $i++;
> if ($i == 1) {
> $input = $_ ;
> chomp($input);
> print "\tRELEASE OR DROP = ($input) \n";
> }
>
>
> If anyone knows how to do it... please post something....
> I apologise if the message is cryptic or vague, I would love to explain
> further if anyone has interest to help.
>
> Thanks a lot in advance
> Farooq
>
>
> Sent via Deja.com
> http://www.deja.com/
------------------------------
Date: Mon, 22 Jan 2001 14:42:26 -0000
From: "Sébastien Cottalorda" <sebastien.cottalorda@mageos.com>
Subject: Re: bidirectional communication using sockets
Message-Id: <94hdaa$soe$1@news2.isdnet.net>
Hi,
Here are sample of bidirectionnal client/server.
Client:
#!c:\perl\bin\perl -w
use IO::Socket;
$socket = IO::Socket::INET->new(PeerAddr=> '190.197.10.217',
PeerPort=> '123456',
Proto=> "tcp",
Type=> SOCK_STREAM)
or die "Couln\'t connect to 190.197.10.217:123456 $@\n";
$phrase = "Comment vas-tu ?";
$socket->send("$phrase"."FIN",'') or die "Can\'t send $!\n";
print "> $phrase \n";
$data_read='seb';
ITER: while ($data_read) {
$socket->recv($data_read,'256') or die "Can\'t recv $!\n";
print "< $data_read \n" unless ($data_read=~/FIN/);
last ITER if ($data_read=~/FIN/);
}
$data_read=~s/FIN//;
print "< $data_read \n";
exit 0;
Server:
#!c:\perl\bin\perl -w
use IO::Socket;
use Carp;
use POSIX qw(strftime);
$port_recep='123456';
$server= IO::Socket::INET->new(LocalPort=> $port_recep,
Type=> SOCK_STREAM,
Reuse=>1,
Listen=>10)
or die "Couln\'t be a tcp server on $port_recep $@\n";
while ($client=$server->accept()) {
$data_read='seb';
ITER: while ($data_read) {
$client->recv($data_read,'256') or die "Can\'t recv $!\n";
print "< $data_read \n" unless ($data_read=~/FIN/);
last ITER if ($data_read=~/FIN/);
}
$data_read=~s/FIN//;
print "< $data_read \n";
$phrase = 'Je vais bien Merci';
$client->send($phrase."FIN",'') or die "Can\'t send $!\n";
print "> $phrase \n";
}
exit 0;
The client connect using a socket to the server.
It send block of 256 bytes.
When it has finished, it end a special word "FIN" (you can choose what you
like for example : "\r")
Then the client listen the socket instead of writing into it.
The server receive datas, but send an answer just after it received the word
"FIN".
Then both programs ends.
Be very Carefull, it's very easy to make deadlock (server and client both
listenning and waiting other part datas send).
Hope this helps
Sebastien
<mmustafa@my-deja.com> a écrit dans le message :
942bgq$aj5$1@nnrp1.deja.com...
> Hi,
> I am trying to write a PERL program using sockets. One side ( which
> we call client ) is communicating with the listener ( which we call
> server) thru a specific port. This is working fine.
> The problem i am running into is after sending a couple of strings
> (haven't been able to pass an array), the listener/ server reads it,
> and does some processing. But if the listener wants to send some
> response back to the client, the client can't read it. I will give a
> brief code summnary here ( rather then the whole thing ) , this didn't
> work :
> CLIENT CODE :
> #socket initializination, $port and $server are arguments
> socket(SOCKET, PF_INET, SOCK_STREAM, (getprotobyname('tcp'))[2]);
> connect (SOCKET, pack('Sna4x8', AF_INET, $port,
> (gethostbyname($server))[4]))
> || die "Can't connect to server $server on port $port .\n";
> SOCKET->autoflush();
>
>
> print SOCKET "Command1 \r\n";
> print SOCKET "Command2 \r\n";
>
> # I need to read response from the server :
> # did NOT WORK
> # shutdown(SOCKET,1);
> # while (<SOCKET>) {
> # while (defined ($string = <SOCKET>) ) {
> recv(SOCKET,$string,100,0);
> if ($string) {
> $string = $_;
> print "STRING : ****($string)****\n";
> if ($string == 1) {
>
>
> I tried threading the process , which created further problems ( maybe
> programing error).
> I tried shutdown , which also on the server side, so that the client
> doesn't keep on waiting ( according to the documentation , recv will
> keep on waiting).
>
>
> Here is a snippet of SERVER CODE :
> $server = IO::Socket::INET->new( Proto => 'tcp',
> LocalPort => $DEFAULT_PORT,
> Listen => SOMAXCONN,
> Reuse => 1);
>
> while(<$server>)
> {
> chomp($_);
> print "Value of i = $i and this is what I got
> from the other machine: **($_)** \n";
> autoflush $server 5;
> $i++;
> if ($i == 1) {
> $input = $_ ;
> chomp($input);
> print "\tRELEASE OR DROP = ($input) \n";
> }
>
>
> If anyone knows how to do it... please post something....
> I apologise if the message is cryptic or vague, I would love to explain
> further if anyone has interest to help.
>
> Thanks a lot in advance
> Farooq
>
>
> Sent via Deja.com
> http://www.deja.com/
------------------------------
Date: Mon, 22 Jan 2001 17:00:53 +0100
From: Schrader <wolfgang.schrader@off1.siemens.de>
Subject: CGI - SSI
Message-Id: <3A6C5935.B4596CF7@off1.siemens.de>
Hi,
I get the actual server time in an html-Page using a ssi-perl-script.
If I re-request this page, the cached version including the old, cached
time will be displayed.
the SSI-Call is (JavaScript):
function init() {
wwlgettime(<!--#exec cgi="/common/homepage/cgi-bin/dategmt.pl" -->);
wwlini();
}
Anyone knowing a trick getting the actual server time with little effort
?
Reloading or requesting the whole page via cgi would be a workaround,
but costs too much performance and netload for this - large - page.
I tried
print "Expires:". scalar gmtime."\n\n";
writing the http-Header but it doesnt work
maybe, the newsgroup is not the correct one, nevertheless,
I hope for a perl-, http- and ssi- Guru ;-)
thanks in advance
Wolfgang
------------------------------
Date: Sun, 21 Jan 2001 17:36:45 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: DBI/Oracle why SPACE ?
Message-Id: <G7Iwx9.Hww@news.muni.cz>
On Sun, 21 Jan 2001 18:27:00 +0100, Peter <peter@cgi-shop.dk> wrote:
> > are you really sure these are spaces, not some other (unprintable)
> > character?
>
> It seems like spaces.......how do i detect if it is ?
man od(1).
> And how do I delete them?
It's not a point of deleting them. The point is to setup your
environment so that they're not there from the very beginning.
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
.project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------
------------------------------
Date: Mon, 22 Jan 2001 14:13:04 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Deleting a line from file
Message-Id: <QdXa6.5659$tg4.28857@eagle.america.net>
On Mon, 22 Jan 2001 13:02:53 +1000, Jeffrey Grace
<gracenews@optusnet.com.au> wrote:
>"Tad McClellan" <tadmc@augustmail.com> wrote in message
>news:slrn96ljop.gb2.tadmc@tadmc26.august.net...
>> Jeffrey Grace <gracenews@optusnet.com.au> wrote:
>> >"Tad McClellan" <tadmc@augustmail.com> wrote in message
>> >news:slrn96j61l.9cm.tadmc@tadmc26.august.net...
>>
>> I think you are saying that you want a _real_ in-place edit, that is,
>> you want the new file to have the same inode number as the original
>> file. Would that solve your problem?
>
>basically yes. Or any other method that can do the equivalent of keeping a
>file locked during the removal of a line of text.
To make a number of operations atomic, you need a semaphore.
Just adopt a convention of using a lock file. Lock it before
beginning the series of operations and unlock it after completing the
operations. (Be sure to close any files you're updating so that their
buffers get flushed before unlocking.) Once you "train" all processes
to use the semaphore, you're done. :-)
--
Garry Williams
------------------------------
Date: Mon, 22 Jan 2001 15:44:05 -0000
From: "David Harrigan" <dajh101@yahoo.co.uk>
Subject: Directory Recursion Problem.
Message-Id: <94hkg6$4br$1@soap.pipex.net>
Hiya,
Consider the following snippet. Can anyone tell me why it fails?
(assume that there is a root directory with a load of subdirs. The perl
script is in the root directory)
#!/usr/bin/perl -w
$defaultLoc = ".";
indexDir($defaultLoc);
sub indexDir {
opendir DIR, $_[0] || die "Can't open $defaultLoc !!";
foreach $subdir (sort readdir DIR) {
print "$subdir\n";
if(chdir $subdir) {
indexDir($subdir);
}
}
closedir DIR;
}
------------------------------
Date: Mon, 22 Jan 2001 15:58:29 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Directory Recursion Problem.
Message-Id: <slrn96om60.3gb.rgarciasuarez@rafael.kazibao.net>
David Harrigan wrote in comp.lang.perl.misc:
> Hiya,
>
> Consider the following snippet. Can anyone tell me why it fails?
Define "fails". Does it produce an error message? If it does, include
this error message (after having looked it up in perldiag). If it
behaves strangely, please describe how you expect your code to behave,
and how your code fails to comply with your expectations.
> (assume that there is a root directory with a load of subdirs. The perl
> script is in the root directory)
>
> #!/usr/bin/perl -w
No 'use strict'? Bad.
> $defaultLoc = ".";
>
> indexDir($defaultLoc);
>
> sub indexDir {
> opendir DIR, $_[0] || die "Can't open $defaultLoc !!";
Include $! in the error message. Very useful.
> foreach $subdir (sort readdir DIR) {
> print "$subdir\n";
> if(chdir $subdir) {
You should test if $subdir is a directory. In fact, you should test if
"$_[0]/$subdir" is a directory name. And you should probably remove the
'.' and '..' directories from the list; e.g :
foreach $subdir (sort grep { -d "$_[0]/$subdir" && !/^\.\.?$/ } readdir DIR) {
...
}
> indexDir($subdir);
> }
> }
> closedir DIR;
> }
HTH.
--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
perl -sleprint -- -_='Just another Perl hacker,'
------------------------------
Date: Tue, 23 Jan 2001 01:57:35 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Directory search without repeating
Message-Id: <slrn96oiiv.bgr.mgjv@martien.heliotrope.home>
On 22 Jan 2001 13:41:00 GMT,
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> Ross Clement <clemenr@westminster.ac.uk> wrote in comp.lang.perl.misc:
>>Hi. What's the best way to recursively search directories without a risk of
>>looping if directories are linked into their own subdirectories. My limited
>>knowledge is limited to either using `ls -id` or (&stat( $filename)) to get
>>the i-number, then not expanding directories if a directory of that
>>inumber has been expanded before.
>
> That approach is fine, except you need to remember the device along with
> the inode if symlinks are a possibility.
>
>>Any better approaches? If I was doing this in Java, I'd use the File()
>>class to find the absolute path for a file, and keep a record of these.
>
> What is "the" absolute path to a file? The existence of hard links
> under Unix means there can be more than one, which is exactly the
> problem. I don't see how an absolute path name would solve it.
Loops in a file system created by hard links to directories can only
be created by a superuser process, specifically for the reason that
they're harder to detect for programs. If a loop like that exists, you
have severe problems, and you need to fix those.
Loops created by symlinks are easier to create, and are therefore much
more common.
Yes, using the inode and device id together will prevent following any
loops. Keeping track of the fully resolved path will prevent following
loops introduced by symlinks. Under normal circumstances you only really
need to worry about the second. Hard loops are pathological, and should
be viewed as a problem to be fixed.
of course, all of this is specific to Unix-like file systems only. Other
file systems may very well have other problems/difficulties to deal
with.
Martien
--
Martien Verbruggen |
Interactive Media Division | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd. | you come to the end; then stop.
NSW, Australia |
------------------------------
Date: 22 Jan 2001 15:15:12 GMT
From: clemenr@westminster.ac.uk (Ross Clement)
Subject: Re: Directory search without repeating
Message-Id: <3a6c4e80@ant.wmin.ac.uk>
Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote:
: Ross Clement <clemenr@westminster.ac.uk> wrote in comp.lang.perl.misc:
: >Hi. What's the best way to recursively search directories without a risk of
: >looping if directories are linked into their own subdirectories. My limited
: >knowledge is limited to either using `ls -id` or (&stat( $filename)) to get
: >the i-number, then not expanding directories if a directory of that
: >inumber has been expanded before.
:
: That approach is fine, except you need to remember the device along with
: the inode if symlinks are a possibility.
:
: >Any better approaches? If I was doing this in Java, I'd use the File()
: >class to find the absolute path for a file, and keep a record of these.
:
: What is "the" absolute path to a file? The existence of hard links
: under Unix means there can be more than one, which is exactly the
: problem. I don't see how an absolute path name would solve it.
I thought it might solve the problem if every file had only one pathname
that got returned, no matter how you got to the file in the first place.
I thought that this is what happens with Java.
Cheers,
Ross-c
------------------------------
Date: 22 Jan 2001 15:38:15 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Directory search without repeating
Message-Id: <94hk57$2o2$1@mamenchi.zrz.TU-Berlin.DE>
Martien Verbruggen <mgjv@tradingpost.com.au> wrote in comp.lang.perl.misc:
>On 22 Jan 2001 13:41:00 GMT,
> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>> What is "the" absolute path to a file? The existence of hard links
>> under Unix means there can be more than one, which is exactly the
>> problem. I don't see how an absolute path name would solve it.
>
>Loops in a file system created by hard links to directories can only
>be created by a superuser process, specifically for the reason that
>they're harder to detect for programs. If a loop like that exists, you
>have severe problems, and you need to fix those.
Except for the . and .. links that are present in every standard
directory, and must be avoided in file tree traversal for exactly
the reason that worries the OP. I guess those two are the reason
hard loops are permitted at all.
>Loops created by symlinks are easier to create, and are therefore much
>more common.
Yes, and also easier to detect, because there is only one original.
All hard links are created equal.
[...]
>of course, all of this is specific to Unix-like file systems only. Other
>file systems may very well have other problems/difficulties to deal
>with.
True.
Topic? What topic?
Anno
------------------------------
Date: 22 Jan 2001 15:46:01 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Directory search without repeating
Message-Id: <94hkjp$2o2$2@mamenchi.zrz.TU-Berlin.DE>
Ross Clement <clemenr@westminster.ac.uk> wrote in comp.lang.perl.misc:
>Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote:
>: Ross Clement <clemenr@westminster.ac.uk> wrote in comp.lang.perl.misc:
>: >Hi. What's the best way to recursively search directories without a risk of
>: >looping if directories are linked into their own subdirectories. My limited
>: >knowledge is limited to either using `ls -id` or (&stat( $filename)) to get
>: >the i-number, then not expanding directories if a directory of that
>: >inumber has been expanded before.
>:
>: That approach is fine, except you need to remember the device along with
>: the inode if symlinks are a possibility.
>:
>: >Any better approaches? If I was doing this in Java, I'd use the File()
>: >class to find the absolute path for a file, and keep a record of these.
>:
>: What is "the" absolute path to a file? The existence of hard links
>: under Unix means there can be more than one, which is exactly the
>: problem. I don't see how an absolute path name would solve it.
>
>I thought it might solve the problem if every file had only one pathname
>that got returned, no matter how you got to the file in the first place.
>I thought that this is what happens with Java.
It can't. Suppose you hit on a directory x that has multiple hard
links. The Java thingie tells you its canonical path name is y
(x = y is a possibility). Time passes as you walk the file tree.
Someone else (another process) renames y to z. Now you hit on another
link to x. Java can hardly lie to you and tell you "it's really y",
because y doesn't exist any more.
Anno
------------------------------
Date: 22 Jan 2001 14:16:51 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Getting past protected directories?
Message-Id: <slrn96og6j.qn2.abigail@tsathoggua.rlyeh.net>
zawy (zawy@yahoo.com) wrote on MMDCCI September MCMXCIII in
<URL:news:3a6c3421.5251069@news.knology.net>:
`'
`' How do I use Perl to enter my username and password on a Unix protected directory (over ther internet)? LWP::Authen::Basic somewhere?
Don't use lines longer than about 75 characters, and certainly not
longer than 80 chars! Not every has 180 degree vision.
You shouldn't be using LWP for "Unix protected directories". LWP
deals with HTTP, which is OS independent.
You might want to use `ssh' or `scp', but that requires a daemon to
be set up on the server machine. You should contact your system
administrator; (s)he can tell you what is available for you - this
group cannot.
Abigail
--
perl -wleprint -eqq-@{[ -eqw\\- -eJust -eanother -ePerl -eHacker -e\\-]}-
------------------------------
Date: Mon, 22 Jan 2001 14:05:03 GMT
From: Bill Smith <apobull@my-deja.com>
Subject: Re: input_record_separator error
Message-Id: <94hemb$gfr$1@nnrp1.deja.com>
In article <94h1p2$a4d$1@mamenchi.zrz.TU-Berlin.DE>,
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
> Bill Smith <apobull@my-deja.com> wrote in comp.lang.perl.misc:
> >Perl was recently upgraded here to V5.6 using the version from
> >www.perl.com. Since that upgrade, I have had several scripts return
> >the following error:
> >
> >input_record_separator is not supported on a per-handle basis
> >at /opt/perl-5.6.0/site_lib/QIP.pl line 110
> >input_record_separator is not supported on a per-handle basis
> >at /opt/perl-5.6.0/site_lib/QIP.pl line 112
> >
> >I have these scripts running via cron. These two lines repeat well
> >over 100 times in the "Output from cron message".
> >
> >The code it's complaining about is below.
> >
> > input_record_separator $fh ": ";
> > chomp($_ = ReadLine(1, $fh));
> > input_record_separator $fh "\n";
>
> The function (or method) input_record_separator is not a standard
> Perl function. It must be part of one of the modules you're using,
> probably QIP itself. Consult its documentation, its source and
> its author.
>
> Anno
>
input_record_separator is not a QIP module. It is in fact part of Perl.
Consult O'Reilly's Programming Perl, 3rd Edition, page 666. What is
listed there is what my colleague here suggested but still isn't
working.
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 22 Jan 2001 14:14:31 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: input_record_separator error
Message-Id: <94hf87$qht$1@mamenchi.zrz.TU-Berlin.DE>
Bill Smith <apobull@my-deja.com> wrote in comp.lang.perl.misc:
>In article <94h1p2$a4d$1@mamenchi.zrz.TU-Berlin.DE>,
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
[...]
>> The function (or method) input_record_separator is not a standard
>> Perl function. It must be part of one of the modules you're using,
>> probably QIP itself. Consult its documentation, its source and
>> its author.
>>
>> Anno
>>
>
>input_record_separator is not a QIP module. It is in fact part of Perl.
>Consult O'Reilly's Programming Perl, 3rd Edition, page 666. What is
>listed there is what my colleague here suggested but still isn't
>working.
$INPUT_RECORD_SEPARATOR is part of Perl (marginally, because you
have to use a module to activate it). input_record_separator isn't
a standard Perl function.
Anno
------------------------------
Date: Mon, 22 Jan 2001 14:16:59 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: input_record_separator error
Message-Id: <slrn96og6q.2q0.bernard.el-hagin@gdndev25.lido-tech>
On Mon, 22 Jan 2001 14:05:03 GMT, Bill Smith <apobull@my-deja.com> wrote:
>In article <94h1p2$a4d$1@mamenchi.zrz.TU-Berlin.DE>,
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
>> Bill Smith <apobull@my-deja.com> wrote in comp.lang.perl.misc:
>> >Perl was recently upgraded here to V5.6 using the version from
>> >www.perl.com. Since that upgrade, I have had several scripts return
>> >the following error:
>> >
>> >input_record_separator is not supported on a per-handle basis
>> >at /opt/perl-5.6.0/site_lib/QIP.pl line 110
>> >input_record_separator is not supported on a per-handle basis
>> >at /opt/perl-5.6.0/site_lib/QIP.pl line 112
>> >
>> >I have these scripts running via cron. These two lines repeat well
>> >over 100 times in the "Output from cron message".
>> >
>> >The code it's complaining about is below.
>> >
>> > input_record_separator $fh ": ";
>> > chomp($_ = ReadLine(1, $fh));
>> > input_record_separator $fh "\n";
>>
>> The function (or method) input_record_separator is not a standard
>> Perl function. It must be part of one of the modules you're using,
>> probably QIP itself. Consult its documentation, its source and
>> its author.
>
>input_record_separator is not a QIP module. It is in fact part of Perl.
>Consult O'Reilly's Programming Perl, 3rd Edition, page 666. What is
>listed there is what my colleague here suggested but still isn't
>working.
I think you've mistaken input_record_separator and
$INPUT_RECORD_SEPARATOR, which is something completely different.
Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'
------------------------------
Date: Mon, 22 Jan 2001 14:32:04 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: input_record_separator error
Message-Id: <EvXa6.5660$tg4.28857@eagle.america.net>
On 22 Jan 2001 14:14:31 GMT, Anno Siegel
<anno4000@lublin.zrz.tu-berlin.de> wrote:
>Bill Smith <apobull@my-deja.com> wrote in comp.lang.perl.misc:
>>In article <94h1p2$a4d$1@mamenchi.zrz.TU-Berlin.DE>,
>> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
>
>[...]
>
>>> The function (or method) input_record_separator is not a standard
>>> Perl function. It must be part of one of the modules you're using,
>>> probably QIP itself. Consult its documentation, its source and
>>> its author.
>>>
>>> Anno
>>>
>>
>>input_record_separator is not a QIP module. It is in fact part of Perl.
>>Consult O'Reilly's Programming Perl, 3rd Edition, page 666. What is
>>listed there is what my colleague here suggested but still isn't
>>working.
>
>$INPUT_RECORD_SEPARATOR is part of Perl (marginally, because you
>have to use a module to activate it). input_record_separator isn't
>a standard Perl function.
This says different:
$ grep input_record_separator /usr/local/lib/perl5/5.6.0/*
/usr/local/lib/perl5/5.6.0/FileHandle.pm: input_record_separator
/usr/local/lib/perl5/5.6.0/FileHandle.pm: input_record_separator
$ perl -MFileHandle -wle '$fh=new FileHandle;print \
> $fh->can("input_record_separator")'
CODE(0x1765f4)
$
--
Garry Williams
------------------------------
Date: Mon, 22 Jan 2001 14:36:17 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: input_record_separator error
Message-Id: <slrn96ohau.2q0.bernard.el-hagin@gdndev25.lido-tech>
On Mon, 22 Jan 2001 14:32:04 GMT, Garry Williams <garry@zvolve.com> wrote:
>On 22 Jan 2001 14:14:31 GMT, Anno Siegel
><anno4000@lublin.zrz.tu-berlin.de> wrote:
>>Bill Smith <apobull@my-deja.com> wrote in comp.lang.perl.misc:
>>>In article <94h1p2$a4d$1@mamenchi.zrz.TU-Berlin.DE>,
>>> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
>>
>>[...]
>>
>>>> The function (or method) input_record_separator is not a standard
>>>> Perl function. It must be part of one of the modules you're using,
>>>> probably QIP itself. Consult its documentation, its source and
>>>> its author.
>>>>
>>>> Anno
>>>>
>>>
>>>input_record_separator is not a QIP module. It is in fact part of Perl.
>>>Consult O'Reilly's Programming Perl, 3rd Edition, page 666. What is
>>>listed there is what my colleague here suggested but still isn't
>>>working.
>>
>>$INPUT_RECORD_SEPARATOR is part of Perl (marginally, because you
>>have to use a module to activate it). input_record_separator isn't
>>a standard Perl function.
>
>This says different:
>
> $ grep input_record_separator /usr/local/lib/perl5/5.6.0/*
> /usr/local/lib/perl5/5.6.0/FileHandle.pm: input_record_separator
> /usr/local/lib/perl5/5.6.0/FileHandle.pm: input_record_separator
> $ perl -MFileHandle -wle '$fh=new FileHandle;print \
> > $fh->can("input_record_separator")'
> CODE(0x1765f4)
> $
Well then it's part of a module. That doesn't make it a standard Perl
function, even if the module is included with the standard distribution.
Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'
------------------------------
Date: 22 Jan 2001 15:20:38 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: input_record_separator error
Message-Id: <94hj46$f7$1@mamenchi.zrz.TU-Berlin.DE>
Garry Williams <garry@zvolve.com> wrote in comp.lang.perl.misc:
>On 22 Jan 2001 14:14:31 GMT, Anno Siegel
><anno4000@lublin.zrz.tu-berlin.de> wrote:
>>$INPUT_RECORD_SEPARATOR is part of Perl (marginally, because you
>>have to use a module to activate it). input_record_separator isn't
>>a standard Perl function.
>
>This says different:
>
> $ grep input_record_separator /usr/local/lib/perl5/5.6.0/*
> /usr/local/lib/perl5/5.6.0/FileHandle.pm: input_record_separator
> /usr/local/lib/perl5/5.6.0/FileHandle.pm: input_record_separator
> $ perl -MFileHandle -wle '$fh=new FileHandle;print \
> > $fh->can("input_record_separator")'
> CODE(0x1765f4)
> $
Ah, so there is such a beast in FileHandle. If that makes it a
"standard Perl function" may still be debatable. The English module
(the one that defines, among others, $INPUT_RECORD_SEPARATOR) has
some extra standing in that it has made it into perlvar (and from
there to the Camel). Just because it's in a standard module doesn't
make it standard Perl.
Dead horse? What dead horse?
Anno
------------------------------
Date: Mon, 22 Jan 2001 10:46:17 -0500
From: "Brian E. Seppanen" <seppy@chartermi.net>
Subject: Inserting fields in place
Message-Id: <3A6C55C9.562CB28A@chartermi.net>
Hello:
I have several existing mrtg configs that monitor routers and whatnot.
I have a lot of them. I want to begin adding threshold monitoring into
these configurations, and that would entail adding several fields with
additional information. There will need to be some hand modifications
necessary, but I'd like to get the majority taken care of it I can.
What I need to do is search for a specified line, and once I find that I
need to insert the text. In this situation the config files will
sometimes contain multiple occurrences of options, so I need to match
each one and insert.
Is this possible? here's what I've got obviously it doesn't do what I
need.
#!/usr/bin/perl -w
use Cwd 'chdir';
use strict 'vars';
chdir '/home/mrtg/templates/test';
my @files = `ls -1 /home/mrtg/templates/test | tr -d / `;
foreach (@files) {
print "Opening File: $_\n";
open (FILE,">>$_");
my $line = m/Options/;
print FILE "\nI AM A TEST\n";
close FILE;
}
The test text simply get's appended to the end of the file. Is it
possible to do what I'm asking?
TIA. Very much a perl newbie.
Brian Seppanen
Charter Communications
Regional Data Center 906-228-4226 ext 23
Marquette, MI seppy@chartermi.net
------------------------------
Date: Mon, 22 Jan 2001 14:37:48 GMT
From: mintcake@my-deja.com
Subject: Re: Newbie Perl Problem
Message-Id: <94hgjr$ia5$1@nnrp1.deja.com>
In article <slrn96o757.2q0.bernard.el-hagin@gdndev25.lido-tech>,
bernard.el-hagin@lido-tech.net wrote:
> On Mon, 22 Jan 2001 11:17:33 GMT, badass101@my-deja.com
> <badass101@my-deja.com> wrote:
> >Hi,
> >
> >I have a variable, $text1, which is full of text.
> >I want to strip the whitespace and new lines out of the file so that
i
> >get a list of words, seperated by a space,
> >
> >e.g.
> >word1 word2 word3
> >
> >How can i do this easily??
>
> First, read this:
>
> perldoc -f split
>
> After you're done with that you can use your new knowledge to try to
> come up with a solution. If you can't, post your attempt and we'll
> gladly help you fix it.
>
> Cheers,
> Bernard
> --
> #requires 5.6.0
> perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @
= [$ ?] }'
>
OK, you can use split (and then join) but what I think badass was
really after was:
$text1 =~ s/\s*\ \sg;
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Mon, 22 Jan 2001 15:23:15 -0000
From: hymie@lactose.smart.net (hymie!)
Subject: Re: percentages, how?
Message-Id: <t6ok33kimclq23@corp.supernews.com>
In our last episode, the evil Dr. Lacto had captured our hero,
snef <snef@soneramail.nl>, who said:
>I've got 3 characters: a, b, c in an array (@x)
>Now I want to get one character randomly
>This is easy. Something like $a[rand 3].
>
>but now i want to add some winning percentages. The change to get b must
>be 80%.
>How can I do this?
$myrandomnumber = rand;
if ($myrandomnumber < .15) { return $a[0]; } # 15% chance
elsif ($myrandomnumber < .95) { return $a[1]; } # 80% chance
else { return $a[2]; } # 5% chance
hymie! http://www.smart.net/~hymowitz hymie@lactose.smart.net
===============================================================================
Sometimes I falter, sometimes I lose. Sometimes I get caught up wallowing in my
blues. So undecided; I hesitate and yet Every once in awhile I just manage to
forget that I think of myself as damaged goods. --Christine Lavin
===============================================================================
------------------------------
Date: Mon, 22 Jan 2001 11:01:44 -0500
From: Lou Moran <lmoran@wtsg.com>
Subject: Re: percentages, how?
Message-Id: <n8mo6ts1nt0d2miu9om3ergmti3gdjd6si@4ax.com>
On 21 Jan 2001 00:12:24 GMT, abigail@foad.org (Abigail) wrote
wonderful things about sparkplugs:
<SNIP, read and barely understood>
>Abigail
I have decided that you are scary smart. Like don't play Trivial
Pursuit with this person smart.
lmoran@wtsgSPAM.com
print "\x{263a}"
------------------------------
Date: Mon, 22 Jan 2001 15:27:00 GMT
From: "Koen Bossaert" <not@defined.com>
Subject: stability of threads + interpreter performance
Message-Id: <8jYa6.77$j4.10000@nreader2.kpnqwest.net>
Hi,
I read that threading is a lot more stable, but still experimental in Perl
5.6 than in 5.005, but that one has to pay a performance penalty if you
recompile the interpreter to support threading (ref:
http://www-106.ibm.com/developerworks/library/l-perl5.html?dwzone=linux).
Can anyone tell me if it is stable enough to use in business applications?
How big is the performance penalty?
See you,
Koen
__________________________________
Learn from the mistakes of others. You can't
live long enough to make them all yourself.
------------------------------
Date: Sun, 21 Jan 2001 15:18:30 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Still Can't Get MIME Lite To Send Attachment...
Message-Id: <G7IqIu.Du9@news.muni.cz>
On Sun, 21 Jan 2001 15:06:54 GMT, Rand Simberg <simberg.interglobal@trash.org> wrote:
>
> I still can't get MIME Lite to actually attach a file. When I run the
> following:
>
> $msg = new MIME::Lite
> From =>$mailer,
> To =>$recipient,
> Subject =>'Contact Record Archive',
> Type =>'multipart/mixed';
>
> # Add parts (each "attach" has same arguments
> as "new"):
> attach $msg
> Type =>'TEXT',
> Data =>"The attached file contains
> your requested archive backup.";
> attach $msg
> Type =>'text/plain',
> Path =>"$data_directory/$file",
Did you try to specify Filename, as the doc shows? Since you have slash
in Path, MIME::Lite may refuse that attach call.
Yours,
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
.project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 117
**************************************