[11626] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5227 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 25 15:07:31 1999

Date: Thu, 25 Mar 99 12:01:32 -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           Thu, 25 Mar 1999     Volume: 8 Number: 5227

Today's topics:
    Re: protecting perl scripts <reich@pants.internetcds.com>
    Re: protecting perl scripts (Greg Bacon)
    Re: re-sorting a sorted list (and sorting by date) (M.J.T. Guy)
    Re: regular expression <cassell@mail.cor.epa.gov>
        SCO 3.2.4.2 Installation Issue <scott.ranzal@mci.com>
    Re: SENDMAIL not allowing Content-Type: multipart/mixed (I R A Aggie)
    Re: SENDMAIL not allowing Content-Type: multipart/mixed (George Crissman)
        Unsupported release: newsdiff (Brad Knowles)
    Re: Urgent: Document contains no data (Bart Lateur)
    Re: Urgent: Document contains no data (I R A Aggie)
    Re: Values of 'true' and 'false'? (M.J.T. Guy)
    Re: Values of 'true' and 'false'? (M.J.T. Guy)
    Re: Values of 'true' and 'false'? (Larry Rosler)
    Re: Way to find out if a regex matched? (Tad McClellan)
        Win32::API Question <craig.david@mt.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 25 Mar 1999 10:00:53 -0800
From: Mahlon <reich@pants.internetcds.com>
To: Greg Bacon <gbacon@cs.uah.edu>
Subject: Re: protecting perl scripts
Message-Id: <877ls5zbxm.fsf@martini.office.cdsnet.net>



Unfortunatly, it appears that all you need to do to defeat Greg's script is
change the last line of the encrypted script from
'eval $prog' to 'print $prog'

Decrypts the source to STDOUT.



-Mahlon


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

Date: 25 Mar 1999 19:58:07 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: protecting perl scripts
Message-Id: <7de4gf$cg2$1@info2.uah.edu>

In article <877ls5zbxm.fsf@martini.office.cdsnet.net>,
	Mahlon <reich@pants.internetcds.com> writes:
: Unfortunatly, it appears that all you need to do to defeat Greg's script is
: change the last line of the encrypted script from
: 'eval $prog' to 'print $prog'

To ride this ride, you must be at least this tall.  Better luck next
year.

Greg
-- 
The ability to quote is a serviceable substitute for wit. 
    -- Maugham


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

Date: 25 Mar 1999 18:28:21 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: re-sorting a sorted list (and sorting by date)
Message-Id: <7ddv85$5vm$1@pegasus.csx.cam.ac.uk>

In article <1dp57zw.1k0rk5m1cvixfwN@[207.60.170.219]>,
Ronald J Kimball <rjk@linguist.dartmouth.edu> wrote:
><nkaiser@my-dejanews.com> wrote:
>
>> I need to first sort the array by number. This is not a problem, I got that
>> working (see example below). Then, I need to sort the array by date (but still
>> ordered by number). Similar to an "order by number,date" in SQL.
>
>You actually want to do this in one sort, comparing the primary keys
>first, and the secondary keys only if the primary keys match.
>
>Something like the following:
>
>sort { $date[$a] <=> $date[$b] ||
>       $idx[$a] <=> $idx[$b]      } 0 .. $#idx

Actually, the request was for a sort by number, then date.   So you
need to swap those comparisons:

sort { $idx[$a] <=> $idx[$b] ||
       $date[$a] <=> $date[$b]     } 0 .. $#idx


Mike Guy


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

Date: Thu, 25 Mar 1999 11:54:05 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: regular expression
Message-Id: <36FA945D.B14016AD@mail.cor.epa.gov>

rheinman@my-dejanews.com wrote:
> Very new to Perl, and several hours on CPAN, this group, etc hasn't turned up
> an answer to what is certainly a simple problem.

They're all simple.. once you know how.  But you've done well so far.
In particular, your Subject line on your post was informative and targeted
your problem.

> The following perl program is trying to read a file and replace occurences of
> 'brown' with 'red':
> 
> #! /opt/perl5/bin/perl -w

Good!  Always use that -w flag.  I put 'use strict;' as my second line too.

> use diagnostics;
> $value = "initialize";

You can drop this line.  See comments below.

> open(FH, "< input.file") || die "cannot open input file: $!";
> open(HH, "> output.file") || die "cannot open output file: $!";

Checking the success of your opens.  Very good.  I personally prefer
to use 'or' instead of '||' since 'or' has lower precedence.  That lets
me drop the parens and just write:
   open FH, "<input.file" or die "cannot open input file: $!";
The $! is good too.

> $inline = <FH>;
> while (defined($inline = <FH>)){
>    $value = s/brown/red/g;

Okay.  Here's the problem.  You assigned the value of the line to
$inline, but you're trying to do the subst on $value.  And you're using
'='.  When you want to do a subst on a variable, use the pattern binding
operator =~ like this:
     $inline =~ s/brown/red/g;

And also: if you want to make sure you match 'brown' but not 'brownies'
or 'lowbrown' or 'Eric Debrowner', then read about the nifty \b assertion.
     $inline =~ s/\bbrown\b/red/g;
\b is a zero-width assertion that matches at a word boundary, meaning it
matches _in_between_ the word and the non-word. 

>    select HH; # and write record
>    print "$value \n";

You can just write this as:
     print HH "$value";
Note: no comma between filehandle and list.  No \n after $value.  Why not?
You never chopped the newline off the line when you read it in - you didn't
need to.  So it's still there, ready to print out for you.

> }
> [errors snipped]
> 
> What I need to do eventually is to be able to do multiline replacements in a
> file, ie:
> 
> this is sentence one
> and this is the next sentence
> of this paragraph
> 
> would become just:
> 
> of this paragraph

Get the first part working, and then check out the following features:
$/    (the input line separator)
s///m
s///s

If you can't figure out how to get your multiline replacer working,
come on back and ask for more help.

David
-- 
David L. Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Thu, 25 Mar 1999 19:38:35 GMT
From: Scott Ranzal <scott.ranzal@mci.com>
Subject: SCO 3.2.4.2 Installation Issue
Message-Id: <36FA9110.F1ACE73A@mci.com>

This is a multi-part message in MIME format.
--------------ECCD7F006F4A4BF4F860606C
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I am having trouble installing Perl5.005_02 on an SCO 3.2.4.2 machine
with gcc 2.7.2.1.

I am including the myconfig output and a small text file with the make
errors.  I think(although am completely guessing that the sigaction
struct is causing problems with signal recognition).

Thank you for any help you can provide

Scott Ranzal
scott.ranzal@mci.com
4155440508
--------------ECCD7F006F4A4BF4F860606C
Content-Type: text/plain; charset=us-ascii;
 name="make.out"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="make.out"

	`sh  cflags libperl.a miniperlmain.o`  miniperlmain.c
	  CCCMD =  gcc -DPERL_CORE -c -U M_XENIX -I/usr/include -I/usr/local/include  -O2   
In file included from perl.h:567,
                 from miniperlmain.c:11:
/usr/include/sys/times.h:54: warning: `struct utimbuf' declared inside parameter list
/usr/include/sys/times.h:54: warning: its scope is only this definition or declaration,
/usr/include/sys/times.h:54: warning: which is probably not what you want.
	`sh  cflags libperl.a perl.o`  perl.c
	  CCCMD =  gcc -DPERL_CORE -c -U M_XENIX -I/usr/include -I/usr/local/include  -O2   
In file included from perl.h:567,
                 from perl.c:15:
/usr/include/sys/times.h:54: warning: `struct utimbuf' declared inside parameter list
/usr/include/sys/times.h:54: warning: its scope is only this definition or declaration,
/usr/include/sys/times.h:54: warning: which is probably not what you want.
perl.c: In function `open_script':
perl.c:1951: warning: assignment makes pointer from integer without a cast
	`sh  cflags libperl.a gv.o`  gv.c
	  CCCMD =  gcc -DPERL_CORE -c -U M_XENIX -I/usr/include -I/usr/local/include  -O2   
In file included from perl.h:567,
                 from gv.c:20:
/usr/include/sys/times.h:54: warning: `struct utimbuf' declared inside parameter list
/usr/include/sys/times.h:54: warning: its scope is only this definition or declaration,
/usr/include/sys/times.h:54: warning: which is probably not what you want.
	`sh  cflags libperl.a toke.o`  toke.c
	  CCCMD =  gcc -DPERL_CORE -c -U M_XENIX -I/usr/include -I/usr/local/include  -O2   
In file included from perl.h:567,
                 from toke.c:15:
/usr/include/sys/times.h:54: warning: `struct utimbuf' declared inside parameter list
/usr/include/sys/times.h:54: warning: its scope is only this definition or declaration,
/usr/include/sys/times.h:54: warning: which is probably not what you want.
toke.c: In function `Perl_yylex':
toke.c:1958: warning: passing arg 2 of `execv' from incompatible pointer type
	`sh  cflags libperl.a perly.o`  perly.c
	  CCCMD =  gcc -DPERL_CORE -c -U M_XENIX -I/usr/include -I/usr/local/include  -O2   
In file included from perl.h:567,
                 from perly.y:17:
/usr/include/sys/times.h:54: warning: `struct utimbuf' declared inside parameter list
/usr/include/sys/times.h:54: warning: its scope is only this definition or declaration,
/usr/include/sys/times.h:54: warning: which is probably not what you want.
	`sh  cflags libperl.a op.o`  op.c
	  CCCMD =  gcc -DPERL_CORE -c -U M_XENIX -I/usr/include -I/usr/local/include  -O2   
In file included from perl.h:567,
                 from op.c:19:
/usr/include/sys/times.h:54: warning: `struct utimbuf' declared inside parameter list
/usr/include/sys/times.h:54: warning: its scope is only this definition or declaration,
/usr/include/sys/times.h:54: warning: which is probably not what you want.
	`sh  cflags libperl.a regcomp.o`  regcomp.c
	  CCCMD =  gcc -DPERL_CORE -c -U M_XENIX -I/usr/include -I/usr/local/include  -O2   
In file included from perl.h:567,
                 from regcomp.c:78:
/usr/include/sys/times.h:54: warning: `struct utimbuf' declared inside parameter list
/usr/include/sys/times.h:54: warning: its scope is only this definition or declaration,
/usr/include/sys/times.h:54: warning: which is probably not what you want.
	`sh  cflags libperl.a dump.o`  dump.c
	  CCCMD =  gcc -DPERL_CORE -c -U M_XENIX -I/usr/include -I/usr/local/include  -O2   
In file included from perl.h:567,
                 from dump.c:16:
/usr/include/sys/times.h:54: warning: `struct utimbuf' declared inside parameter list
/usr/include/sys/times.h:54: warning: its scope is only this definition or declaration,
/usr/include/sys/times.h:54: warning: which is probably not what you want.
	`sh  cflags libperl.a util.o`  util.c
	  CCCMD =  gcc -DPERL_CORE -c -U M_XENIX -I/usr/include -I/usr/local/include  -O2   
In file included from perl.h:567,
                 from util.c:16:
/usr/include/sys/times.h:54: warning: `struct utimbuf' declared inside parameter list
/usr/include/sys/times.h:54: warning: its scope is only this definition or declaration,
/usr/include/sys/times.h:54: warning: which is probably not what you want.
util.c: In function `Perl_my_popen':
util.c:1869: warning: return makes pointer from integer without a cast
util.c: In function `Perl_rsignal':
util.c:1945: storage size of `act' isn't known
util.c:1945: storage size of `oact' isn't known
util.c:1948: `SIGALL' undeclared (first use this function)
util.c:1948: (Each undeclared identifier is reported only once
util.c:1948: for each function it appears in.)
util.c: In function `Perl_rsignal_state':
util.c:1966: storage size of `oact' isn't known
util.c: In function `Perl_rsignal_save':
util.c:1977: storage size of `act' isn't known
util.c:1980: `SIGALL' undeclared (first use this function)
util.c: In function `Perl_my_pclose':
util.c:2048: storage size of `hstat' isn't known
util.c:2048: storage size of `istat' isn't known
util.c:2048: storage size of `qstat' isn't known
util.c:2083: `SIGHUP' undeclared (first use this function)
util.c:2085: `SIGQUIT' undeclared (first use this function)
util.c: In function `cast_i32':
util.c:2262: warning: decimal constant is so large that it is unsigned
util.c:2263: warning: decimal constant is so large that it is unsigned
util.c: In function `cast_iv':
util.c:2273: warning: decimal constant is so large that it is unsigned
util.c:2274: warning: decimal constant is so large that it is unsigned
*** Error code 1

--------------ECCD7F006F4A4BF4F860606C
Content-Type: text/plain; charset=us-ascii;
 name="myconfig.out"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="myconfig.out"

Summary of my perl5 (5.0 patchlevel 5 subversion 2) configuration:
  Platform:
    osname=sco, osvers=, archname=i386-sco
    uname='evsdp8 evsdp8 3.2 2 i386 '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='gcc', optimize=' -O2', gccversion=2.7.2.1
    cppflags='-U M_XENIX -I/usr/include -I/usr/local/include'
    ccflags ='-U M_XENIX -I/usr/include -I/usr/local/include'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
    alignbytes=4, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='ld', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /shlib /lib /usr/lib
    libs=-ldbm.nfs -lintl -lsocket -lnsl_s -lndbm -lld -lm -lc -lPW -lx -lc_s
    libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_none.xs, dlext=none, d_dlsymun=undef, ccdlflags=''
    cccdlflags='', lddlflags=''


--------------ECCD7F006F4A4BF4F860606C--



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

Date: 25 Mar 1999 19:07:50 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: SENDMAIL not allowing Content-Type: multipart/mixed header
Message-Id: <slrn7fl2ul.42e.fl_aggie@stat.fsu.edu>

On Thu, 25 Mar 1999 16:34:42 +0000, Julian Madle
<julian.madle@mcmail.com> wrote:

+ I have written a Perl4 compliant multipurpose formmail script that
+ handles attachments, I have re-writtrn the base64 encoder module
+ to be Perl4 compatible

Ummm...not to put too fine a point on it...but...WHY ARE YOU WORRYING
ABOUT PERL4 IN 1999??? I assure you, no one else is. Further, Perl4 is
CERTifiably insecure -- if you use it to run CGI programs, you do so
at your own risk.

James


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

Date: Thu, 25 Mar 1999 19:29:05 GMT
From: strads@tmisnet.com (George Crissman)
Subject: Re: SENDMAIL not allowing Content-Type: multipart/mixed header
Message-Id: <36fa8bc5.2338434@news2.tmisnet.com>

I'm real new at this ... but did you notice that "\n\n" appears
TWICE in the header area?  That would be my first guess
at what's causing the problem.

-- George Crissman
-- strads@tmisnet.com

On Thu, 25 Mar 1999 16:34:42 +0000, Julian Madle
<julian.madle@mcmail.com> wrote:

>I have written a Perl4 compliant multipurpose formmail script that
>handles attachments, I have re-writtrn the base64 encoder module
>to be Perl4 compatible and the Mail is sending out. However I do
>not know much about SENDMAIL and I cannot manage to get the 
>multipart/mixed stuff in the email header, therefore my mail client
>(Netscape Messenger) does not recognize the attachment, instead
>leaving the base64 encoded file in the message contents (which I
>have to save out and decode with Winzip). The code is below, any
>ideas much appreciated to julian.madle@mcmail.com.
>
>
>$bound = "------------6B797646304";
>$attach = qq{$bound\nContent-Type: $contentType;
>name="$newfilename"\nContent-Transfer-Encoding: };
>$attach .= qq{base64\nContent-Disposition: inline;
>filename="$newfilename"\n\n$upfile64\n$bound};
>
># SEND MAIL
>open(MAIL,"|$mailprog -t");
>print MAIL "To: $in{'recipient'}\n";
>print MAIL "From: $in{'email'}\n";
>print MAIL "MIME-Version: 1.0\n";
>print MAIL "Subject: $in{'subject'}\n";
>print MAIL qq{Content-Type: multipart/mixed; boundary="$bound"\n\n};

The first '\n\n' occurs in the line above.

>print MAIL qq{\n$bound\nContent-Type: text/plain; charset=us-ascii;
>name="message.txt"\n};
>print MAIL "Content-Transfer-Encoding: 7bit\n\n";

The second '\n\n' occurs right up there.

>print MAIL $main_message; # THE FORM CONTENT
>print MAIL $attach; # BASE64 ENCODED STRING
>close (MAIL);
>}

-----------------------------------------------------------------------
"There is no need to criminalize millions of legitimate and responsible
businesses and individuals in order to stop a very small group of
irresponsible people, particularly when there are other ways already
working ." says Mr. Dan Hufnal of the (relatively small) 10,000 member 
DEAA.  What does he mean by "other ways already working"?
Maybe:  <http://www.tmisnet.com/~strads/spamhunt/index.html>
-----------------------------------------------------------------------


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

Date: Thu, 25 Mar 1999 19:58:01 +0100
From: brad@shub-internet.org (Brad Knowles)
Subject: Unsupported release: newsdiff
Message-Id: <brad-2503991958010001@brad.techos.skynet.be>

Folks,

    Okay, I've actually cooked up another hopefully useful tool to help
debug news server problems.  It requires NNTP access at a reference and
target news server, and that they both support XOVER.

    It will grab all the message-ids on both servers and compare the byte
sizes of the messages.  If there are any articles on the reference but not
the target, it will tell you.  If there are any articles that are of
differing sizes, it will tell you.  You can also request that it tell you
if there are any articles on the target but not the reference, and if you
want to be really verbose you can ask that it tell you if they exist on
both servers and are the same size.

    You can also get it to display either the headers or the entire
articles for those articles that are on the reference but not the target
or where the sizes differ.  Note that these options are turned off by
default, since this will seriously exercise the overview database on the
reference system, and could result in a large number of messages being
displayed.


    Please be gentle, this is only the second Perl program I've ever
written from the ground-up.  ;-)

    In particular, I'd like to get any comments you may have about Perl
programming style or better use of the Net::NNTP module.


    Given what this thing is loading and the fact that I make very liberal
use of multi-dimensional hashes, it will take a while to start up and will
chew some serious amounts of RAM.


#!/usr/bin/perl

# newsdiff -- Compare newsgroups (by individual message-id)
#   between reference & target newservers
#
#   Author: Brad Knowles <blk@skynet.be>
#     Date: Wed Mar 24 19:54:15 MET 1999
#
# Inspired by discussions with Forrest J. Cavalier III and
#   Curt Welch, with Net::NNTP xover code borrowed
#   liberally from Greg Bacon (author of Net::NNTP).
#   Perl programming assistance from James "Thomas" Goltz
#============================================================
# Copyright (c) 1999 by Belgacom Skynet, all rights reserved.
#
# This program is provided as-is, with absolutely no
# warranty or suitability for any purpose implied.
#
# This program is not even guaranteed to run or compile, and
# you use it entirely at your own risk!
#
# No support will be provided, although comments and
# suggestions are appreciated, and attempts will be made to
# fold in improvements and make them available under the
# same terms as the rest of the program.
#
# This program is provided as freely available and
# distributable Perl source code only, and you are free
# to make whatever modifications you like, so long as you
# contribute them back to me and do not make the modified
# versions available to other persons without express prior
# consent.
#============================================================

############################################################
############################################################
###                                                      ###
### NO MODIFICATIONS BELOW THIS LINE SHOULD BE NECESSARY ###
###                                                      ###
############################################################
############################################################

$nntp_port||=119;
# Standard port number for NNTP.

use Getopt::Std;
use Net::NNTP;

getopts('r:t:g:ahvV');

if ($#ARGV != -1)
{
    usage();
    exit 1;
}

if (defined $opt_r)
{
    $reference = $opt_r;
}
else
{
    usage();
    exit 1;
}

if (defined $opt_t)
{
    $target = $opt_t;
}
else
{
    usage();
    exit 1;
}

if (defined $opt_g)
{
    @groups=split /,/, $opt_g;
}
else
{
    usage();
    exit 1;
}

if (defined $opt_a)
{
    $show_missing_articles = $opt_a;
}

if (defined $opt_h)
{
    $show_missing_headers = $opt_h;
}

if (defined $opt_v)
{
    $verbose = $opt_v;
}

if (defined $opt_V)
{
    $verbose = $veryverbose = $opt_v;
}

%ref = get_over($reference, @groups);
%targ = get_over($target, @groups);

foreach $group (@groups)
{
    printf "Newsgroup: $group\n";
    foreach $message_id (keys %{$total_message_ids{$group}})
    {
        if (!defined($targ{$group}{$message_id}))
        {
            printf "- $message_id   $ref{$group}{$message_id}{bytes}\n";
            if (defined ($show_missing_headers) || defined
($show_missing_articles))
            {
                $retrieve{$group}{$message_id} = $ref{$group}{$message_id}
            }
        }
        elsif ($targ{$group}{$message_id}{bytes} !=
$ref{$group}{$message_id}{bytes})
        {
            printf "! $message_id   $ref{$group}{$message_id}{bytes} !=
$targ{$group}{$message_id}{bytes}\n";
            if (defined ($show_missing_headers) || defined
($show_missing_articles))
            {
                $retrieve{$group}{$message_id} = $ref{$group}{$message_id}
            }
        }
        elsif (defined ($verbose) && !defined($ref{$group}{$message_id}))
        {
            printf "+ $message_id   $targ{$group}{$message_id}{bytes}\n";
        }
        elsif (defined ($veryverbose) && $targ{$group}{$message_id}{bytes}
== $ref{$group}{$message_id}{bytes})
        {
            printf "= $message_id   $ref{$group}{$message_id}{bytes} ==
$targ{$group}{$message_id}{bytes}\n";
        }
    }
}

if (defined $show_missing_headers)
{
    $NntpPtr = Net::NNTP->new("$reference")
        or die "Failed to open NNTP connection to $reference\n";
    foreach $group (@groups)
    {
        my ($NumArts, $NumFirstArt, $NumLastArt, $XGroupname);
        ($NumArts, $NumFirstArt, $NumLastArt, $XGroupname) =
            $NntpPtr->group($group);
        printf "\n\nShow missing headers\nNewsgroup: $group\n";
        foreach $message_id (keys %{$retrieve{$group}})
        {
            my $hdr = $NntpPtr->head($message_id);
            foreach $line (@{$hdr})
            {
                printf "$line";
            }
            printf "\n\n";
        }
    }
    $NntpPtr->quit;
}
elsif (defined $show_missing_articles)
{
    $NntpPtr = Net::NNTP->new("$reference")
        or die "Failed to open NNTP connection to $reference\n";
    foreach $group (@groups)
    {
        my ($NumArts, $NumFirstArt, $NumLastArt, $XGroupname);
        ($NumArts, $NumFirstArt, $NumLastArt, $XGroupname) =
            $NntpPtr->group($group);
        printf "\n\nShow missing articles\nNewsgroup: $group\n";
        foreach $message_id (keys %{$retrieve{$group}})
        {
            my $art = $NntpPtr->head($message_id);
            foreach $line (@{$art})
            {
                printf "$line\n";
            }
            printf "\n\n";
        }
    }
    $NntpPtr->quit;
}

sub get_over
{

    my ($site, @groups) = @_;
    my (%data);

    $NntpPtr = Net::NNTP->new("$site")
    or die "Failed to open NNTP connection to $site\n";

    my (%oview_fmt);
    my $i = 0;
    for ( @{ $NntpPtr->overview_fmt } )
    {
        $oview_fmt{$_} = $i++;
    }

    foreach $group (@groups)
    {
        my ($NumArts, $NumFirstArt, $NumLastArt, $XGroupname);
        ($NumArts, $NumFirstArt, $NumLastArt, $XGroupname) =
            $NntpPtr->group($group);
        my($xoverdata) = $NntpPtr->xover("$NumFirstArt-$NumLastArt");

        while (my($num,$head) = each %$xoverdata)
        {
            my ($message_id) = $head->[$oview_fmt{"Message-ID:"}];
            my ($bytes) = $head->[$oview_fmt{"Bytes:"}];
            $data{$group}{$message_id} = $message_id;
            $data{$group}{$message_id}{bytes} = $bytes;
            if (!defined($total_message_ids{$group}{$message_id}))
            {
                $total_message_ids{$group}{$message_id} = $message_id;
            }
        }
    }

    $NntpPtr->quit;

    return %data;

}

sub usage
{
    my @prog=split(/\//, $0);
    my $prog=$prog[$#prog];
    print "Usage: $prog -r <reference> -t <target> -g <groups> [-ahvV]\n";
    print "\n";
    print "Where:\n";
    print "<reference> is the hostname of a reference news server\n";
    print "<target>    is the hostname of the target news server\n";
    print "<groups>    is a newsgroup or comma separated list of
newsgroups to compare\n";
    print "\n";
    print "Message-ids found on <reference> but not on <target> are
indicated with a \"-\"\n";
    print "at the start of the line.  Message-ids that refer to messages
with differing\n";
    print "sizes according to <reference> and <target> are indicated with
a \"!\"\n";
    print "\n";
    print "Use -v to indicate message-ids on <target> but not on
<reference> with \"+\"\n";
    print "Use -V to also indicate message-ids of articles on <target> for
messages\n";
    print "that are the same size as the corresponding message on
<reference> with \"=\"\n";
    print "\n";
    print "Use -a to display ARTICLE BODIES on reference but not on target\n";
    print "Use -h to display HEADERS of ARTICLES on reference but not on
target\n";
    print "\n";
    print "WARNING!!!  Use of -h is very intensive on <reference>, as
articles\n";
    print "are referenced by message-id.  Use of -a is even *MORE*
intensive, as it\n";
    print "displays entire articles and not just article headers!!!\n";
}

-- 
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>
    <http://wwwkeys.pgp.net:11371/pks/lookup?op=get&search=0xE38CCEF1>

Are you looking for a news feed from a site in the Freenix Top 200?
If so, contact me via private e-mail for details.


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

Date: Thu, 25 Mar 1999 18:40:02 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Urgent: Document contains no data
Message-Id: <36fd82ad.1292275@news.skynet.be>

Shade L. Jenifer wrote:

>Document contains no data.
>
>Normally, this tells me that I have a syntax error in
>my script.  However, when I run the script from the
>command line, I get no errors.  Are there any other
>reasons why such an alert is generated?
>
>Quick response is greatly appreciated.

Maybe put an extra line in.

	print "<PRE>Finished!</PRE>";

And if, when run,  that's all you see, you forgot to output something.
Anything.

	Bart.


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

Date: 25 Mar 1999 19:16:15 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Urgent: Document contains no data
Message-Id: <slrn7fl3ed.42e.fl_aggie@stat.fsu.edu>

On Thu, 25 Mar 1999 10:40:55 -0500, Shade L. Jenifer
<sjenifer@geo.census.gov> wrote:

+ I have a problem that needs immediate attention and
+ our resources here (ie books) are scarce.

Ummm...at the government? I'll propose that you wander into your favorite
bookstore, get a cup o' your favorite beverage, grab the appropriate book,
and read.

+ (Netscape 4.0 running on an SGI/IRIX OS)

I'm sorry.

+ Normally, this tells me that I have a syntax error in
+ my script.  However, when I run the script from the
+ command line, I get no errors.  Are there any other
+ reasons why such an alert is generated?

<url:http://language.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html>

See also the other responses in this thread.

James


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

Date: 25 Mar 1999 18:53:06 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Values of 'true' and 'false'?
Message-Id: <7de0mi$726$1@pegasus.csx.cam.ac.uk>

Philip Newton  <Philip.Newton@datenrevision.de> wrote:
>Philip Newton wrote:
>> 
>> first *non-zero* operand.
>
>make that: first false operand ('' or '0' or 0).

Oops.   I think you mean first *true* operand.


Mike Guy


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

Date: 25 Mar 1999 18:57:33 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Values of 'true' and 'false'?
Message-Id: <7de0ut$75b$1@pegasus.csx.cam.ac.uk>

Larry Rosler <lr@hpl.hp.com> wrote:
>In article <36f9304f@csnews> on 24 Mar 1999 11:34:55 -0700, Tom 
>Christiansen <tchrist@mox.perl.com> says...
>> 
>> You are correct, but you should rely on the docs.  Do not compare 
>> with true and false.  
>
>Of course.  But as I read the question, he wants to do further 
>manipulation on the value returned by a Boolean operator.  In that case, 
>the values are well defined.

Well, the values are only well defined to the extent of being true or
false.    So further manipulation using boolean operators is well
defined.    But you shouldn't do things like

     length($a==$b)
     ($a>$b) * 17


Mike Guy


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

Date: Thu, 25 Mar 1999 11:36:55 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Values of 'true' and 'false'?
Message-Id: <MPG.11643035d6cd07509897c8@nntp.hpl.hp.com>

In article <7de0ut$75b$1@pegasus.csx.cam.ac.uk> on 25 Mar 1999 18:57:33 
GMT, M.J.T. Guy <mjtg@cus.cam.ac.uk> says...
> Larry Rosler <lr@hpl.hp.com> wrote:
 ...
> > ...  But as I read the question, he wants to do further 
> >manipulation on the value returned by a Boolean operator.  In that case, 
> >the values are well defined.
> 
> Well, the values are only well defined to the extent of being true or
> false.    So further manipulation using boolean operators is well
> defined.    But you shouldn't do things like
> 
>      length($a==$b)

Maybe one shouldn't.  But it is well defined.  As we have seen from the 
rest of this thread, in string context, the value is "" or '1', so the 
length is 0 or 1.

>      ($a>$b) * 17

($a>$b) is not an lvalue.

In numeric context, the situation is exactly the same as in C, where the 
values of a Boolean are explicitly 0 or 1.

  $number_of_matches = ($a eq $x) + ($a eq $x);

is 0 or 2, depending on whether $a in fact the same as $x.  This is well 
defined, hence valid Perl.

The only thing missing is explicit documentation of this behavior.

-- 
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 25 Mar 1999 08:27:09 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Way to find out if a regex matched?
Message-Id: <djddd7.dl4.ln@magna.metronet.com>

Philip Newton (Philip.Newton@datenrevision.de) wrote:
: I have a regex in a module to calculate die rolls. I'm not sure how to
: satisfy both of the following simultaneously: (1) I want to assign $1 ..
: $4 from capturing parens, and (2) I want to see whether the regex
: matched at all (and return undef if not). 


   Ahh, but you *do* know how to do that!


: At the moment I have code like
: this:

:     $line =~ m{ (some (regex) with (capturing parens)) }x;
:     return undef if not defined $+;

: This works for me 


   It has worked by accident so far then.

   One of these days it will stop working...


: -- the =~ m// causes $1 .. $4 to be filled with the
: appropriate values (or undef, if that subexpression didn't match) 
                         ^^^^^  ^^                    ^^^^^^^^^^^^

   Wrong!

   The dollar-digit variables are *not changed* with 
   unsuccessful matches.

: if the
: whole expression matches, and $+ is then the contents of $4. If the
: whole expression doesn't match, $+ is undef, so I can test 'defined $+'
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^

   The description for $+ in perlvar.pod says nothing about what
   happens on UNsuccessful matches. (because that is what happens,
   nothing!)


   Let's spend 120 seconds and write a Perl program to test
   that out:

--------------------------
#!/usr/bin/perl -w
use strict;

my $line = 'foo bar';
$line =~ /(\w+)/;

$line = 'this is the good stuff here';
$line =~ /([A-Z]).*([A-Z])/;             # unsuccessful match
print "undef\n" if not defined $+;       # doesn't get printed...

print "\$1 = '$1'\n";                    # prints 'foo',  Uh oh...
--------------------------


: if I want to know whether the whole expression matches.

: I suppose I could also test whether the whole expression matches using
: something like

:     return undef unless $line =~ m{ bla bla }x;


   That's the way to do it.


: but I am not sure whether this will fill in $1 .. $4. 


   It will.  You could just try it and see for yourself you know...


: So for now, I am
: using the way I described above, which seems to work.
                                         ^^^^^^^^

   "seems to" is the operative part there.


: Is there a way to get both of my goals at once? Thanks in advance for
: your help.


   Yes, as you have it above (the second one).


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 25 Mar 1999 14:12:10 -0500
From: "Craig David" <craig.david@mt.com>
Subject: Win32::API Question
Message-Id: <7de24l$kl6@news1.ee.net>

This will be an easy question to answer. I am new to Perl. What I want to do
is call an API. What I need to do is call the API and also pass parameters
to it.

What I have been able to do is call an API without passing a parameter with
the following syntax:

use Win32::API;
$GetPID = new Win32::API("kernel32", "GetCurrentProcessId", [], N);
$PID = $GetPID->Call();

Questions:

1. In the above example what are "[],N"  - stand for on the end of the line
2. What is the syntax for passing one or more parameters.

Thanks in advance

Craig









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

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 5227
**************************************

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