[22981] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5201 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 9 21:27:56 2003

Date: Wed, 9 Jul 2003 18:25:56 -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           Wed, 9 Jul 2003     Volume: 10 Number: 5201

Today's topics:
        load environment <wonderwall@email.it>
    Re: load environment (Helgi Briem)
    Re: load environment <abigail@abigail.nl>
    Re: load environment <bart.lateur@pandora.be>
    Re: load environment <abigail@abigail.nl>
    Re: Matt's Simple Search - a new angle? <google@asktoby.com>
    Re: Matt's Simple Search - a new angle? <simon.andrews@bbsrc.ac.uk>
    Re: Matt's Simple Search - a new angle? <cat@no-spam.com>
    Re: microphone input (Alythh)
    Re: microphone input (Helgi Briem)
        My if statement doesn't fit my needs <beaudet@cyber.kodak.com>
    Re: My if statement doesn't fit my needs <nanae@perusion.com>
    Re: My if statement doesn't fit my needs <theaney@cablespeed.com>
    Re: My if statement doesn't fit my needs <beaudet@cyber.kodak.com>
    Re: Net::NNTP Undefined value (Gene Mat)
    Re: Net::NNTP Undefined value (Helgi Briem)
        NNTP Image Grabber <usr12@comcast.net>
        No PPM! Help! <john_carter_nc_nospam@hotmail.com>
    Re: No PPM! Help! <cc@zazou.demon.co.uk>
    Re: No PPM! Help! <nanae@perusion.com>
        Odd open but no warning <cc@zazou.demon.co.uk>
    Re: Odd open but no warning <bwalton@rochester.rr.com>
    Re: Odd open but no warning <cc@zazou.demon.co.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 09 Jul 2003 11:44:37 +0200
From: Enzo <wonderwall@email.it>
Subject: load environment
Message-Id: <bego60$6b8$1@newsreader.mailgate.org>

Hi to all,

i have problem with a script perl. I need load any enviroment variables
from a file. In a shell unix I can do . ./file.sh but in perl how can i
do it? It's possble? 
I think also load file from shell and after the shell invoke perl script 
and in perl script with ENV I can read the environment variables, but i
don't like this.

Excuse me for my bad english.
Thanks to all.
Enzo.


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

Date: Wed, 09 Jul 2003 10:57:09 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: load environment
Message-Id: <3f0bf3ac.1388276046@news.cis.dfn.de>

On Wed, 09 Jul 2003 11:44:37 +0200, Enzo <wonderwall@email.it> wrote:

>i have problem with a script perl. I need load any enviroment variables
>from a file. In a shell unix I can do . ./file.sh but in perl how can i
>do it? It's possble? 
>I think also load file from shell and after the shell invoke perl script 
>and in perl script with ENV I can read the environment variables, but i
>don't like this.

Your Question is Frequently Asked.

As such, it is answered in the section of the PerlFAQ
known as:

  "I {changed directory, modified my environment} in a perl script.

  How come the change disappearen when I exited the script?  
  How do I get my changes to be visible?"

You can access the answer by typing:

perldoc -q environment

at your command prompt.

Short answer, a daughter process cannot affect
the environment of its parent.  So while you can easily
run a shell script from Perl,

system ("file.sh") == 0 or die "Cannot run file.sh:$?\n"

doing so would not modify the environment of the
Perl script itself.

The simplest way is to modify the environment
within the Perl script itself, for example:

$ENV{FOO} = 'bar';

Parse the file first to get the appropriate keys
and values if you prefer.


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

Date: 09 Jul 2003 11:02:08 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: load environment
Message-Id: <slrnbgnthf.a4i.abigail@alexandra.abigail.nl>

Enzo (wonderwall@email.it) wrote on MMMDXCIX September MCMXCIII in
<URL:news:bego60$6b8$1@newsreader.mailgate.org>:
}}  Hi to all,
}}  
}}  i have problem with a script perl. I need load any enviroment variables
}}  from a file. In a shell unix I can do . ./file.sh but in perl how can i
}}  do it? It's possble? 
}}  I think also load file from shell and after the shell invoke perl script 
}}  and in perl script with ENV I can read the environment variables, but i
}}  don't like this.


You could do a double exec. Here's a piece of code that I've used to
do a trick that does what you want to do. $APP_ENVIRONMENT contains
a filename of environment variables to set.

Place this code near the top of your file.

    if (@ARGV && $ARGV [0] eq '--sourced_environment') {
        shift;
    }
    else {
        if (-f $APP_ENVIRONMENT) {
            #
            # Now we perform a double exec. The first exec gives us a shell,
            # allowing us the source the file with the environment variables.
            # Then, from within the shell we re-exec ourself - but with an
            # argument that will prevent us from going into infinite recursion.
            #
            # We cannot do a 'system "source $APP_ENVIRONMENT"', because
            # environment variables are not propagated to the parent.
            #
            # Note the required trickery to do the appropriate shell quoting
            # when passing @ARGV back to ourselves.
            #

            @ARGV = map {s/'/'"'"'/g; "'$_'"} @ARGV;

            exec << "        --";
                source '$APP_ENVIRONMENT'
                exec    $0  --sourced_environment @ARGV;
            --
            die  "This should never happen.";
        }
    }


Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$==-2449231+gm_julian_day+time);do{until($=<$#r){$_.=$r[$#r];$=-=$#r}for(;
!$r[--$#r];){}}while$=;$,="\x20";print+$_=>September=>MCMXCIII=>=>=>=>=>=>=>=>'


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

Date: Wed, 09 Jul 2003 14:19:14 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: load environment
Message-Id: <909ogv07vp7bfk7l24m7ct6mfcdoe9tf6r@4ax.com>

Abigail wrote:

>            exec << "        --";
>                source '$APP_ENVIRONMENT'
>                exec    $0  --sourced_environment @ARGV;
>            --
>            die  "This should never happen.";

OK, silly question... in case this *does* happen, in which error
variable should we look for the reason why? $! ?

Perl has far too many different error variables.... ($!, $^E to name
just two)

-- 
	Bart.


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

Date: 09 Jul 2003 14:50:31 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: load environment
Message-Id: <slrnbgoatn.q45.abigail@alexandra.abigail.nl>

Bart Lateur (bart.lateur@pandora.be) wrote on MMMDXCIX September MCMXCIII
in <URL:news:909ogv07vp7bfk7l24m7ct6mfcdoe9tf6r@4ax.com>:
$$  Abigail wrote:
$$  
$$ >            exec << "        --";
$$ >                source '$APP_ENVIRONMENT'
$$ >                exec    $0  --sourced_environment @ARGV;
$$ >            --
$$ >            die  "This should never happen.";
$$  
$$  OK, silly question... in case this *does* happen, in which error
$$  variable should we look for the reason why? $! ?

You've been around in this newgroup long enough to know to check the
documentation first.

Yes, this *is* documented.


Abigail
-- 
perl -wle 'print "Prime" if ("m" x shift) !~ m m^\m?$|^(\m\m+?)\1+$mm'


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

Date: Tue, 8 Jul 2003 19:36:46 +0100
From: "Toby Newman" <google@asktoby.com>
Subject: Re: Matt's Simple Search - a new angle?
Message-Id: <2bEOa.639$4C3.19@newsfep3-gui.server.ntli.net>


----- Original Message -----
From: "Cat" <cat@no-spam.com>
Newsgroups: comp.lang.perl.misc
Sent: Tuesday, July 08, 2003 1:08 PM
Subject: Re: Matt's Simple Search - a new angle?


> Toby Newman wrote:
> >
> > I'd like it to search through *.wiki files (they're just text files)
> > in '/home/wiki/', i.e. not inside my public_html folder.
> >
> > It doesn't seem to work!
> >
> > i.e It works if I use the following variables:
> >
> > $basedir = '/home/public_html/';
> > $baseurl = 'http://www.asktoby.com/';
> > @files = ('*.html','*.php');
> > $title = "TITLE";
> > $title_url = 'http://www.asktoby.com/';
> > $search_url = 'http://www.asktoby.com/search.html';
> >
> > But if I use these variables:
> >
> > $basedir = '/home/wiki/';
> > $baseurl = 'http://www.asktoby.com/';
> > @files = ('*.wiki');
> > $title = "TITLE";
> > $title_url = 'http://www.asktoby.com/';
> > $search_url = 'http://www.asktoby.com/search.html';
> >
> > I get no results.
> >
> > Why could this be?
> >
>
> Do you have permission to view the contents of /home/wiki ?
> Do you get any results with ls /home/wiki/*.wiki ?
> Are you executing the script from a web page ?


Hi! Thank you for your response.

I have asked Matt but he does not reply! I am hoping someone in this
discussion group will have a clue for me :)

The permissions of the /home/wiki/ folder are drwxrwxrwx, and the
permissions of the *.wiki files within are all -rw-r--r--. Unless I'm
mistaken, that means everyone has permission to read the files (i.e. all r's
and no -'s).

I am executing this script from a web page on my ISP's space. As such, I
don't know a way to enter commands like ls /home/wiki/*.wiki

I hope I have answered your questions correctly, Cat. Look forward to your
reply.

Toby




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

Date: Wed, 09 Jul 2003 09:17:41 +0100
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: Matt's Simple Search - a new angle?
Message-Id: <3F0BCFA5.5060203@bbsrc.ac.uk>


>>Toby Newman wrote:

[about wanting to use Matts search script]

>>>I'd like it to search through *.wiki files (they're just text files)
>>>in '/home/wiki/', i.e. not inside my public_html folder.
>>>
>>>It doesn't seem to work!

[snip parameters used]

>>>
>>>I get no results.
>>>
>>>Why could this be?
>>>

 > From: "Cat" <cat@no-spam.com>
>>Do you have permission to view the contents of /home/wiki ?
>>Do you get any results with ls /home/wiki/*.wiki ?
>>Are you executing the script from a web page ?


 > Toby Newman wrote:
>
> Hi! Thank you for your response.
> 
> I have asked Matt but he does not reply! I am hoping someone in this
> discussion group will have a clue for me :)


Toby,

Just to explain a couple of the responses you've had to your original
post, and the general lack of specific help.

You're using a script from Matts script archive.  Those scripts are
a continual source of problems here.  They were written a long time
ago and have been shown to contain many bugs, and in some cases
potential sectrity holes.  Where bugs have been pointed out to Matt
he has failed to provide updated versions of his scripts and
continued to distribute the old code.  You are unlikely to get help
fixing Matts scripts as the regulars here have been over this ground
too many times :-)

On a positive note, a while back the London Perl Mongers group
decided to rewrite Matts scripts from scratch, providing their
own alternatives which were a drop in replacement for the originals
but which fixed the bugs and were more secure.  Even Matts site
now acknowedges that people should be using these versions of the
scripts.

You can get a new version of the search program from:

http://sourceforge.net/projects/nms-cgi/

You may find that this version will fix the problem you're having
or it may not, but you're much more likely to get help here if
you're using the NMS version of the script as a least there should
be no major bugs in it.  You may find that even if it doesn't work
it may give more informative error messages than the original.

As an aside, I'm not familiar with the layout of Wiki documents, but
it's possible that the search script is looking for certain HTML tags
to define which parts of each document to search.  If these aren't
present in the Wiki pages then the script may fail because of that.

Are you able to check your server error logs when the script runs?
Are there any messages reported?

Hope this gets you a bit further.

Cheers

Simon.



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

Date: Wed, 09 Jul 2003 21:43:55 +1000
From: Cat <cat@no-spam.com>
Subject: Re: Matt's Simple Search - a new angle?
Message-Id: <3F0BFFFB.CEE4026A@no-spam.com>

Toby Newman wrote:
> 
> The permissions of the /home/wiki/ folder are drwxrwxrwx, and the
> permissions of the *.wiki files within are all -rw-r--r--. Unless I'm
> mistaken, that means everyone has permission to read the files (i.e. all r's
> and no -'s).
> 
> I am executing this script from a web page on my ISP's space. As such, I
> don't know a way to enter commands like ls /home/wiki/*.wiki
> 
> I hope I have answered your questions correctly, Cat. Look forward to your
> reply.
> 

Look at your search.pl script and scroll down to the first function;

sub parse_form {

   # Get the input
   read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
                        ^^^^^^^^^^^^^^^^^^^^^^

   # Split the name-value pairs
   @pairs = split(/&/, $buffer);

   foreach $pair (@pairs) {
      ($name, $value) = split(/=/, $pair);

      $value =~ tr/+/ /;
      $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

      $FORM{$name} = $value;
   }
}


change the read line to something like;
   read(STDIN, $buffer, 40);

because $ENV{'CONTENT_LENGTH'} is expecting an environmental variable that
isn't defined anywhere.


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

Date: 9 Jul 2003 01:00:18 -0700
From: alythh@netscape.net (Alythh)
Subject: Re: microphone input
Message-Id: <6a25ba72.0307090000.5d86d60c@posting.google.com>

thanks, 
that's just what I needed, I already started experimenting...
if I may add a further question...
I'm finding that I have some kinds of volume problems on the mike,
although I raised up 100% the levels via aumix.
I mean that with my mike I can record without problems my voice if I
speak almost to contact to the mike, but... what I wanted was a system
able to record any sound/voice/music in a room.
Is it possible, or have I to buy some kind of specialized device?

thanks for your help,

Alessandro Magni

helgi@decode.is (Helgi Briem) wrote in message 
> To get you started, read this article from The
> Perl Journal and System Administrators Magazine:
> 
> http://www.samag.com/documents/s=1272/sam05030002/


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

Date: Wed, 09 Jul 2003 10:22:59 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: microphone input
Message-Id: <3f0bebee.1386294515@news.cis.dfn.de>

On 9 Jul 2003 01:00:18 -0700, alythh@netscape.net (Alythh) wrote:

Please do not top-post.  It annoys the regulars
and severely reduces your chances of
recieving useful answers to your questions.

If you don't know what top-posting is and
why you shouldn't do it, read:

http://jargon.watson-net.com/jargon.asp?w=top-post

If you read and follow the posting guidelines posted
here weekly and also available at:

http://mail.augustmail.com/~tadmc/clpmisc.shtml

For more information about netiquette in general, see 
the "Netiquette Guidelines" at:

http://andrew2.andrew.cmu.edu/rfc/rfc1855.html

>I'm finding that I have some kinds of volume problems on 
>the mike, although I raised up 100% the levels via aumix.

>I mean that with my mike I can record without problems 
>my voice if I speak almost to contact to the mike, but... 
>what I wanted was a system able to record any 
>sound/voice/music in a room.

>Is it possible, or have I to buy some kind of specialized 
>device?

I don't know, as I have never done this myself.

However, I suspect that this comes down to the
sensitivity of the microphone itself rather than
the software used to process the sound. 

Typical computer microphones are very 
insensitive and (I can't remember what it's 
called) only supposed to capture sounds
from very close up.

You will probably need a specialised microphone.

In any case, this problem has nothing to do
with Perl anymore.

I hope this helps.


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

Date: Wed, 09 Jul 2003 11:16:58 +0200
From: Jean-Luc BEAUDET <beaudet@cyber.kodak.com>
Subject: My if statement doesn't fit my needs
Message-Id: <3F0BDD8A.3070102@cyber.kodak.com>

Hi all ,

I wrote something like below

> 58              if ( chown 102, 200, $DirtoCreate or warn "Unable to 
> chown $DirtoCreate: $!\n" ) {
> 59                  print "Rights for $DirtoCreate successfully 
> changed.\n";
> 60              }

but it doesn't fit my needs.

What i'd like would be:
if the chown command succeeds it prints Rights for $DirtoCreate 
successfully changed.
BUT if it fails, i want it to only print the warn text and NOT the print 
text.

The first case works OK, but in the second one i've got both the warn 
AND the print.

Where did i fail ?

Thx for any help.

Jean-Luc B :O)



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

Date: Wed, 9 Jul 2003 10:17:46 +0000 (UTC)
From: Perusion hostmaster <nanae@perusion.com>
Subject: Re: My if statement doesn't fit my needs
Message-Id: <slrnbgnqun.5lk.nanae@ns.valuemedia.com>

On Wed, 09 Jul 2003 11:16:58 +0200, Jean-Luc BEAUDET <beaudet@cyber.kodak.com> wrote:
> Hi all ,
> 
> I wrote something like below
> 
>> 58              if ( chown 102, 200, $DirtoCreate or warn "Unable to 
>> chown $DirtoCreate: $!\n" ) {
>> 59                  print "Rights for $DirtoCreate successfully 
>> changed.\n";
>> 60              }
> 
> but it doesn't fit my needs.
> 
> What i'd like would be:
> if the chown command succeeds it prints Rights for $DirtoCreate 
> successfully changed.
> BUT if it fails, i want it to only print the warn text and NOT the print 
> text.
> 
> The first case works OK, but in the second one i've got both the warn 
> AND the print.
> 
> Where did i fail ?

Not realizing that warn returns a true status if it was able to
warn. 8-)

You could just add an else branch:

my $verbose;
my $uid = 102;
my $gid = 200;

if ( chown $uid, $gid, $DirtoCreate ) {
    print "Rights for $DirtoCreate successfully changed.\n"
		if $verbose;
}
else {
	warn "Unable to chown $DirtoCreate: $!\n";
}

-- 
Perusion Hostmaster

"Being against torture ought to be sort of a bipartisan thing."
-- Karl Lehenbauer


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

Date: Wed, 09 Jul 2003 06:29:48 -0400
From: Tim Heaney <theaney@cablespeed.com>
Subject: Re: My if statement doesn't fit my needs
Message-Id: <87brw4ouw3.fsf@mrbun.watterson>

Jean-Luc BEAUDET <beaudet@cyber.kodak.com> writes:
>
> What i'd like would be:
> if the chown command succeeds it prints Rights for $DirtoCreate
> successfully changed.
> BUT if it fails, i want it to only print the warn text and NOT the
> print text.

  58              if ( chown 102, 200, $DirtoCreate ) {
  59                  print "Rights for $DirtoCreate successfully changed.\n";
  60              } else {
                      warn "Unable to chown $DirtoCreate: $!\n";
                  }


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

Date: Wed, 09 Jul 2003 14:02:17 +0200
From: Jean-Luc BEAUDET <beaudet@cyber.kodak.com>
To: Jean-Luc BEAUDET <beaudet@cyber.kodak.com>
Subject: Re: My if statement doesn't fit my needs
Message-Id: <3F0C0449.4000703@cyber.kodak.com>

Thxs to you.

I understood where i failed...

:O)


Jean-Luc BEAUDET wrote:

> Hi all ,
>
> I wrote something like below
>
>> 58              if ( chown 102, 200, $DirtoCreate or warn "Unable to 
>> chown $DirtoCreate: $!\n" ) {
>> 59                  print "Rights for $DirtoCreate successfully 
>> changed.\n";
>> 60              }
>
>
> but it doesn't fit my needs.
>
> What i'd like would be:
> if the chown command succeeds it prints Rights for $DirtoCreate 
> successfully changed.
> BUT if it fails, i want it to only print the warn text and NOT the 
> print text.
>
> The first case works OK, but in the second one i've got both the warn 
> AND the print.
>
> Where did i fail ?
>
> Thx for any help.
>
> Jean-Luc B :O)
>



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

Date: Tue, 08 Jul 2003 21:07:19 GMT
From: geneSPAMAWAYmat@yahoo.com (Gene Mat)
Subject: Re: Net::NNTP Undefined value
Message-Id: <Xns93B2AE2E083CgeneSPAMAWAYmatyahoo@167.206.3.2>

Your right Tad. I've now become an instant fan of 

use warnings; 
use strict; 

I'm new perl and Usenet, but I'll me more carefull when posting in the 
future.

Thanks for everyones help,
Gene Mat

tadmc@augustmail.com (Tad McClellan) wrote in 
<slrnbgk3mb.3da.tadmc@magna.augustmail.com>:

>Gene Mat <geneSPAMAWAYmat@yahoo.com> wrote:
>
>> my $LIST=nntp->list;
>          ^^^^^
>
>> Please Help.
>
>
>Please ask a machine to help you *before* asking thousands of
>people around the world to help you.
>
>You should always enable warnings when developing Perl code.
>
>



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

Date: Wed, 09 Jul 2003 10:15:17 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Net::NNTP Undefined value
Message-Id: <3f0bea00.1385800171@news.cis.dfn.de>

On Tue, 08 Jul 2003 21:07:19 GMT, geneSPAMAWAYmat@yahoo.com (Gene Mat)
wrote:

Please do not top-post.  It annoys the regulars
and severely reduces your chances of
recieving useful answers to your questions.

If you don't know what top-posting is and
why you shouldn't do it, read:

http://jargon.watson-net.com/jargon.asp?w=top-post


>Your right Tad. I've now become an instant fan of 
>
>use warnings; 
>use strict; 
>
>I'm new perl and Usenet, but I'll me more carefull when 
>posting in the  future.

If you read and follow the posting guidelines posted
here weekly and also available at:

http://mail.augustmail.com/~tadmc/clpmisc.shtml

For more information about netiquette in general, see 
the "Netiquette Guidelines" at:

http://andrew2.andrew.cmu.edu/rfc/rfc1855.html



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

Date: Thu, 10 Jul 2003 00:33:49 GMT
From: usr12 <usr12@comcast.net>
Subject: NNTP Image Grabber
Message-Id: <3F0CB46C.9020907@comcast.net>

The script below can be used to grab binary files (images) from a newsgroup.


#!/usr/bin/perl -w

#####################################################################
#                                                                   #
#    Name: nnbot                                                    #
# Version: 2.0.4                                                    #
#    Date: Feb 15, 2003                                             #
#                                                                   #
#    This script will retrieve all messages in a specified set of   #
# news groups and uudecode their contents, saving the results       #
# in a local file. This can be handy for automatically downloading  #
# such things as image files.                                       #
#                                                                   #
#    A file called .nnbotrc is needed in the User's ~/etc directory #
# to list the news groups to process and the associated directory   #
# that will be used to stored the uudecoded files. As nnbot         #
# processes each message, the .nnbotrc file is updated with the     #
# last article number that was processed. The extra overhead in     #
# saving this file is gained by being able to stop this script as   #
# needed and not having to reprocess messages on a restart.         #
#                                                                   #
#    The default news server is "news" and can be overridden on the #
# command line.                                                     #
#                                                                   #
# This script requires News::NNTPClient.                            #
#                                                                   #
#    At startup, this nnbot looks for the .nnbotrc in the user's    #
# ~/etc directory. The layout of this file contains the following   #
# fields:                                                           #
#                                                                   #
# 1. News group name                                                #
# 2. Directory to save uudecoded files                              #
# 3. Starting article number (can default to 0)                     #
#                                                                   #
# example:                                                          #
#     alt.group.1,/home/sampleuser/tmp,0                            #
#     alt.group.2,/home/sampleuser/tmp,0                            #
#                                                                   #
#####################################################################

require 5.001;
use News::NNTPClient;
use Shell qw(rm uudecode);

#####################################################################
#                                                                   #
#                           read .nnbotrc                           #
#                                                                   #
#####################################################################

$news_server = "netnews.comcast.net";
if ($ARGV[0]) {
     $news_server = $ARGV[0];
}

$rcfile = $ENV{HOME} . "/etc/.nnbotrc";
$i = 0;

# Read the Groups from the rc file
open(RCFILE, $rcfile) or die $rcfile." file not found...";
while(<RCFILE>){
     chomp($_);
     ($group_name[$i], $base_dir[$i], $first_article[$i]) = split(/\,/, $_);
     $i++;
}
close(RCFILE);

# Process each one
$i = 0;
foreach $group_name (@group_name) {
     if ($group_name ne "") {
	$base_dir[$i] =~ s/~/$ENV{HOME}/;
	chdir $base_dir[$i] or die "Can't chdir to ".$base_dir[$i];
	get_group($group_name, $base_dir[$i], $first_article[$i], $rcfile);
     }
     $i++;
}

#####################################################################
#                                                                   #
#                            all done                               #
#                                                                   #
#####################################################################
1;

#####################################################################
#                                                                   #
#                            get_group                              #
#                                                                   #
#####################################################################

sub get_group {
     $group_name = $_[0];
     $base_directory = $_[1];
     $last_read = $_[2];
     $rcfile = $_[3];

     $connect = new News::NNTPClient($news_server);
     ($first, $last) = ($connect->group($group_name));

     $last_read++;
     if ($last_read > $first) {
	$first = $last_read;
     }

     for (; $first <= $last; $first++) {
	$message_status = $connect->stat($first);
	if ($message_status ne "") {
	    $filename = $base_directory . "/" . $first . ".uu";
	    open(UUFILE, ">$filename")
		or die "UU file error" . $filename;
	    print UUFILE $connect->body($first);
	    close(UUFILE);

	    #decode and delete it
	    uudecode($filename);
	    rm($filename);

	    #update .nnbotrc to reflect the processed message
	    update_rc($group_name, $first)
         }
     }
}

#####################################################################
#                                                                   #
#                        update .nnbotrc                            #
#                                                                   #
#####################################################################
sub update_rc {
     $rcfile = $ENV{HOME} . "/etc/.nnbotrc";
     $update_name = $_[0];
     $update_article = $_[1];
     $j = 0;
     $k = 0;

     # Read the Groups from the rc file
     open(OLDRC, $rcfile) or die $rcfile." file not found during update...";
     while(<OLDRC>){
	chomp($_);
	($rc_name[$j], $rc_dir[$j], $rc_article[$j]) = split(/\,/, $_);
	$j++;
     }
     close(OLDRC);

     open(NEWRC, ">$rcfile") or die $rcfile." can't be created during update";
     foreach $rc_name (@rc_name) {
	if ($rc_name eq $update_name) {
	    $rc_article[$k] = $update_article;
	}
	print NEWRC ("$rc_name,$rc_dir[$k],$rc_article[$k]\n");
	$k++;
     }
     close(NEWRC);
}



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

Date: Tue, 08 Jul 2003 22:28:32 -0400
From: john <john_carter_nc_nospam@hotmail.com>
Subject: No PPM! Help!
Message-Id: <befucb$l7d$2@sun-news.laserlink.net>

I am running red hat 8.0 and there is no ppm file on my computer.  I 
loaded the rpm for both 5.6 and 5.8 and still nothing! How do I get ppm!??



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

Date: Wed, 9 Jul 2003 03:38:36 +0000 (UTC)
From: Colin Campbell <cc@zazou.demon.co.uk>
Subject: Re: No PPM! Help!
Message-Id: <slrnbgn3hs.nd.cc@ze.zazou.org>

In article <befucb$l7d$2@sun-news.laserlink.net>, john wrote:
> I am running red hat 8.0 and there is no ppm file on my computer.  I 
> loaded the rpm for both 5.6 and 5.8 and still nothing! How do I get ppm!??
> 
In unix land we do things differently (actually elsewhere they do things
differently!). Checkout perldoc CPAN for full details, or try the
command 'perl -MCPAN -e shell' 
(or red hat maybe has rpms of modules you might want, they love to
package things in bits)
C.


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

Date: Wed, 9 Jul 2003 10:27:39 +0000 (UTC)
From: Perusion hostmaster <nanae@perusion.com>
Subject: Re: No PPM! Help!
Message-Id: <slrnbgnrh7.5lk.nanae@ns.valuemedia.com>

On Wed, 9 Jul 2003 03:38:36 +0000 (UTC), Colin Campbell <cc@zazou.demon.co.uk> wrote:
> In article <befucb$l7d$2@sun-news.laserlink.net>, john wrote:
>> I am running red hat 8.0 and there is no ppm file on my computer.  I 
>> loaded the rpm for both 5.6 and 5.8 and still nothing! How do I get ppm!??
>> 
>
> In unix land we do things differently (actually elsewhere they do things
> differently!). Checkout perldoc CPAN for full details, or try the
> command 'perl -MCPAN -e shell' 

> (or red hat maybe has rpms of modules you might want, they love to
> package things in bits)

Red Hat has historically done a very bad job of packaging Perl for
its distribution. Not surprising in that they are a bunch of
Python-heads. 8-)

The one for Red Hat Linux 9 is particularly disgusting. They have
built it for threads, which makes Perl very unreliable and apt
to dump core at any time. They have also added random patches
from the maintenance branch with no apparent testing. There are
modules in CPAN which can't even run their Makefile.PL as a result.

I recommend rebuilding your Perl from scratch the moment you 
get a Red Hat 9 machine. You should not uninstall the RPMS because
you will run into dependency hell; just do a 

	## Save libperl.so for use with vim, et al
	cp -i `find /usr/lib/perl5 -name libperl.so -type f` /usr/local/lib

	## Can the whole mess
	rm -rf /usr/lib/perl5

	./Configure -des -Dprefix=/usr && make test && make install

Then install the modules you need with CPAN.

-- 
Perusion Hostmaster

"Being against torture ought to be sort of a bipartisan thing."
-- Karl Lehenbauer


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

Date: Tue, 8 Jul 2003 20:11:22 +0000 (UTC)
From: Colin Campbell <cc@zazou.demon.co.uk>
Subject: Odd open but no warning
Message-Id: <slrnbgm9b9.v4.cc@ze.zazou.org>

Recently I had to look at a perl script which was misbehaving. When I looked 
at it the code was pretty horrific, among other horrors was the following

open FH, "|$external_program|";
print FH "command";
$response = <FH>;

What surprised me was that this compiled without even a warning. 
I wondered if there was ever a use for such an apparently mistaken 
construction?

Any views?
(Other than someone should buy the author the llama book for Xmas)
Colin



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

Date: Wed, 09 Jul 2003 01:06:05 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Odd open but no warning
Message-Id: <3F0B6A72.6080407@rochester.rr.com>

Colin Campbell wrote:

> Recently I had to look at a perl script which was misbehaving. When I looked 
> at it the code was pretty horrific, among other horrors was the following
> 
> open FH, "|$external_program|";
> print FH "command";
> $response = <FH>;
> 
> What surprised me was that this compiled without even a warning. 
> I wondered if there was ever a use for such an apparently mistaken 
> construction?
 ...
> Colin

See the docs for open() and IPC::Open2, which explain a bit about this. 
  The construction will compile, since the second argument to open is 
just a string at compile-time, but you'll need IPC::Open2 to get the 
functionality you would expect from the construction.  As for uses, 
certainly, you might want to give commands to an external program a line 
at a time and get back its responses a line at a time.  Consider bc, for 
example.  You will need to be careful -- be sure to write when the 
external program is expecting input and to read when the external 
program is expecting to output, or you will just hang.

-- 
Bob Walton



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

Date: Wed, 9 Jul 2003 03:31:38 +0000 (UTC)
From: Colin Campbell <cc@zazou.demon.co.uk>
Subject: Re: Odd open but no warning
Message-Id: <slrnbgn34p.nd.cc@ze.zazou.org>

In article <3F0B6A72.6080407@rochester.rr.com>, Bob Walton wrote:
> 
>> open FH, "|$external_program|";
> 
> See the docs for open() and IPC::Open2, which explain a bit about this. 
Not really the question I was trying to ask. (I'd already replaced it
with Open2 while cursing its author). But, the answer is that you only
get the warning when running with warnings, not by doing a compile with
warnings. (Hangs head in shame as he should of tried that before
posting).
  Colin


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 5201
***************************************


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