[19786] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1981 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 22 11:05:56 2001

Date: Mon, 22 Oct 2001 08:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1003763108-v10-i1981@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 22 Oct 2001     Volume: 10 Number: 1981

Today's topics:
    Re: \Z regexp behavior different with $& in program (Jason Secosky)
        accessing class-level variables (Paul Faulstich)
        alarm and termination before timeout <perrot@NOSPAM.fluxus.net>
    Re: array or hash to do this sort <tamm@scotlegal.com>
    Re: Calculating abitrary root? Gordon.Haverland@gov.ab.ca
        Calling a sub rutine in another package or module <sasha_lui@yahoo.com>
    Re: Calling a sub rutine in another package or module <jasper@guideguide.com>
    Re: Good Literature (Dave Cross)
    Re: Good Literature <uri@sysarch.com>
    Re: Good Literature <tsee@gmx.net>
    Re: Good Literature <tsee@gmx.net>
    Re: I can use some help... please ... <tsee@gmx.net>
    Re: IO::Socket broken on win (Rocco Caputo)
    Re: Need multiple matches in a regular expression (Linux_303)
        New posters to comp.lang.perl.misc <gbacon@cs.uah.edu>
        problem with pods <edgue@web.de>
    Re: problem with pods (Rafael Garcia-Suarez)
    Re: Reading two variables from a file (Jon Bell)
    Re: Separating data from a long string <Graham.T.Wood@oracle.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 22 Oct 2001 06:55:38 -0700
From: secosky@attglobal.net (Jason Secosky)
Subject: Re: \Z regexp behavior different with $& in program
Message-Id: <64a73ed6.0110220555.66bce4a6@posting.google.com>

Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote in message news:<9qqfs4$u2u$1@agate.berkeley.edu>...
> Does it?  I do not think that @- after an unsuccessful match should be
> of any particular value.  In my testing the old value of @- preserved
> after an unsuccessful match.
> 
> perl5.6.0 -wle '$_= "a\nb\n"; /b$/m or print 11; print $-[0]; /a\Z/ and print 12; print $-[0]'
> 2
> 2
> 
> 
> Is the test marked as skipped-as-bug or what?
> 
> Ilya

Ilya, thanks for the reply.  I agree, @- shouldn't be any particular
value after an unsuccessful search.  Try the following invokations
that use the /m modifier.  When $& is used a match is not found. 
Using the same regexp without $& a match is found:

perl5.6.0 -wle '$_= "a\nb\n"; /b$/m or print 11; /a\Z/m and print 12;
print $&'
b

perl5.6.0 -wle '$_= "a\nb\n"; /b$/m or print 11; /a\Z/m and print 12;'
12

I would have expected the second script to not print anything. 
Instead, 12 is output indicating that the match was successful.

Your question about whether the test for this in re_tests is
skipped-as-bug is right on.  When I read what you wrote, a light
turned on in my head and I realized that "bn" in re_tests means
skipped-as-bug.  So, this is a known issue.  No need to take this any
further.  Thanks again.

Jason


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

Date: 22 Oct 2001 07:55:24 -0700
From: pfaulstich@llbean.com (Paul Faulstich)
Subject: accessing class-level variables
Message-Id: <c9c77658.0110220655.a81cc80@posting.google.com>

I am running into problems accessing a child class's class-level
variables from the parent class.  Essentially, I would like to have an
inherited parent method refer to some variable and have it use the
child's variable, not the parent's.

"Class Context and the Object" in the Camel book touches on something
close to this, but in the case described there, a method in the child
class references the variable, rather than a method in the parent
class referencing the variable.

The best option I could come up with was to have every child class
which overrides that variable also override a method to access the
variable.  I then use that method to get at the variable, rather than
accessing it directly.  While I suppose this might actually be a
preferred approach, I am lazy and would rather not have to override
this method (since it is identical in every class).  Is there a way
from within the parent's method that I can specify the package to
reference?  I can obviously hard-code it with packagename::, but I
don't seem to be able to do something like $packagename:: because it
interprets this as $(packagename::) rather than ($packagename)::
(where the parenthesis are to show ordering, not valid perl.)  Seems
like this must be possible (and maybe even common) and I'm just
missing it as I learn OO perl.

Here is an example:

package Parent;
my %object_list;

sub register {  #register an object - thus its an object-level method
    my $self = shift;
    my $id = shift;
    my $class = ref($self);
    my $objects_ref = $class->get_my_objects;
    #would rather have something like $objects_ref =
\%($class)::my_objects
    return $$objects_ref{$id} = $self if (! $$objects_ref{$id});
    return 0; #we already have such an object
}

sub find { #find an object and return it - this can be called
           #as an object-level or class-level method
    my $arg1 = shift;
    my $id = shift;
    my $class = ref($arg1) ? ref($arg1) : $arg1;
    my $objects_ref = $class->get_my_objects;
    #would rather have something like $objects_ref =
\%($class)::my_objects
    return $$objects_ref{$id};
}
   
sub new {
    my $class = shift;
    my $name = shift;
    my $self = {};
    bless $self, $class;
    $self->register($name) or die "an object with name $name already
exists";
}

sub get_my_objects { #every child must override this
    return \%my_objects;
}

package Son;
@ISA = qw ( Parent);
my %my_objects;

sub get_my_objects {
    return \%my_objects;
}

package Daughter;
@ISA = qw ( Parent);
my %my_objects;

sub get_my_objects {
    return \%my_objects;
}

package main;
$a = Son->new("allen");
$b = Son->new("bob");
$c = Daughter->new("chris");
$c2 = Son->new("chris");      #should be ok
$r1 = Son->get_my_objects;
$r2 = Daughter->get_my_objects;
print "sons: ".join(",",keys %$r1)." & daughters: ".join(",",keys
%$r2)."\n";
$b2 = Son->new("bob");        #should die


Any thoughts on this are appreciated!

TIA,

Paul Faulstich
L.L. Bean, Inc.


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

Date: Mon, 22 Oct 2001 15:53:33 +0200
From: "Gildas PERROT" <perrot@NOSPAM.fluxus.net>
Subject: alarm and termination before timeout
Message-Id: <9r18jp$b03$1@wanadoo.fr>

Hi,

To be sure to really use alarm and SIG{ALRM} correctly, I used example 16.21
of Perl Cookbook The only difference with that example is that I need to
terminate long-time operations when a condition is obtained. Here is my
example :

#!/usr/bin/perl
use strict;

my $timeout = 5;
my $find = 0;
$SIG{ALRM} = sub { die "TIMEOUT" };
my $cmd = "/bin/ping host";

open(CMD, "$cmd |") or die "Can't execute \"$cmd\"\n";
eval {
        alarm($timeout);
        while (<CMD>) {
                print $_;
                if (/icmp_seq=2/) {
                        print "PATTERN FOUND\n";
                        last;
                }
        }
        alarm(0);
};
close(CMD);

if ($@) {
        if ($@ =~ /TIMEOUT/) {
                print "TIMEOUT\n";
        }
        else {
                print "NORMAL END\n";
        }
}

With that example,  "FOUND" is printed but not "NORMAL END" nor "TIMEOUT".
How can I exit from the while loop in order for the program to continue
normally ?

Thanks in advance for your help.            Gildas.




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

Date: Mon, 22 Oct 2001 14:13:27 +0100
From: "Tam McLaughlin" <tamm@scotlegal.com>
Subject: Re: array or hash to do this sort
Message-Id: <md71r9.u7l.ln@mail.scotlegal.com>

Thanks for all the help.
This  worked exactly as I wanted.
"table 1" was a typo, and I know it would have made a big difference to the
perl code.
I guess I do not know enough perl to start with in order to relearn it.
I should probably try converting my shell scripts to perl to give me
something to
practice on.


"Tam McLaughlin" <tamm@scotlegal.com> wrote in message
news:v8u0r9.9mc.ln@mail.scotlegal.com...
> I  do not know much perl, just use it for small simple sysadmin tasks.
> I usually have to relearn each time I go to use perl. I wish to sort a
> file and getting confused as to how to do this.
> The file consists of tablenames and associated disk usage:
>
> table1  1234
> table 1 999
> table2 234
> table2 3333
> table2 888
> table3 1234
> table3 555
>
> I wish to add the values in the second column for each tablename.
> I thought  could read 1 line at a time into a 2D array and then
> itterate through the array summing the second element
>
> e.g.
>
> while ( $line = <IN> ) {
>   @row[$i,$j] = split (/ /,$line);
>   $i++;
>   $j++;
>
>
> but when I do:
>
>   print "$row[$i,$j] \n";
>
> I do not get anything
>
>
> any help on how I should approach this would be appreciated
>
>




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

Date: Mon, 22 Oct 2001 13:21:37 GMT
From: Gordon.Haverland@gov.ab.ca
Subject: Re: Calculating abitrary root?
Message-Id: <3bd41c21.934425545@news.gov.ab.ca>

On Mon, 22 Oct 2001 04:16:57 GMT, "Michael A Mayo"
<michael-a-mayo@att.net> wrote:

>How do I calculate an arbitrary root of a number?  For example, 3rd root (or
>cube root)?

You will have to be careful about domains, for instance if your answer
must be a "real number" (not complex), you can't take the even root of
a negative number.  But if you take the log of the number, divide it
be the "power" you are interested in, and then exponentiate the
answer; you will have the root you are looking for.  

For example, the cube root:
$ans = exp( (log( $number ) / 3 );

In general, there can be an indefinite number of N'th roots of a
number, if you allow for complex answers (answers involving the square
root of -1).  A book on numerical methods may point this out in a
better way than I have.

Gord


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

Date: Mon, 22 Oct 2001 16:12:01 +0200
From: "sasha" <sasha_lui@yahoo.com>
Subject: Calling a sub rutine in another package or module
Message-Id: <9r188r$31e$1@newstoo.ericsson.se>

 Hi
 How can  i call a subrutine in another modul or a pckage ? I have a very
simple program which calls a routine in anther module or package, I am
getting an error saying that Info.pm didnot return true value at InfoTest.pl
line 2. BEGIN failed...., even they are in the same directory.

My working directory is : /home/sasha/PerlTest/

and my program is :

#Here is my package with the sub rutine showinfo

package Info;

sub showinfo{

my $number = 12;
print "Number is : $number \n";

}


-----

# this is my main program calling showinfo in Info package

#!/usr/local/bin/perl -w
use Info;

use strict;
my $anInfo = Info->showinfo();





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

Date: Mon, 22 Oct 2001 15:21:58 +0100
From: Jasper McCrea <jasper@guideguide.com>
Subject: Re: Calling a sub rutine in another package or module
Message-Id: <3BD42B86.65B8F367@guideguide.com>

sasha wrote:
> 
>  Hi
>  How can  i call a subrutine in another modul or a pckage ? I have a very
> simple program which calls a routine in anther module or package, I am
> getting an error saying that Info.pm didnot return true value at InfoTest.pl
> line 2. BEGIN failed...., even they are in the same directory.
> 
> My working directory is : /home/sasha/PerlTest/
> 
> and my program is :
> 
> #Here is my package with the sub rutine showinfo
> 
> package Info;
> 
> sub showinfo{
> 
> my $number = 12;
> print "Number is : $number \n";
> 
> }

the clue is in the error, as always.

put this at the bottom of your Info.pm

return 'true value';

and it ought to work.

This is in perlfaq 7, isn't it? Perhaps you should have looked in
there..

Jasper
-- 
      split//,'019617511192'.
      '17011111610114101114'.
      '21011141011840799901'.
            '17101174';
            foreach(0..         # my
            $#_){$_[$_          # signature is too
            ++]^=$_[$_          # bignature
            --]^=$_[$_
]^=$_[++    $_]if!($_%
2)}$g.=$_  ,chr($g)=~
 /(\w)/&&($o.=$1and
   $g='')foreach@_;
      print"$o\n"


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

Date: 22 Oct 2001 06:38:38 -0700
From: dave@dave.org.uk (Dave Cross)
Subject: Re: Good Literature
Message-Id: <9d3debce.0110220538.1c5d5618@posting.google.com>

Uri Guttman <uri@sysarch.com> wrote in message 

[about www.cgi101.com]

> i can't go on reading this. please don't recommend this site to anyone.

Hey Uri :)

Did you know that this site is based on a "best-selling" book. "CGI
101" regularly outsells other, much better, Perl books (not that I'm
bitter, off course).

I've been in contact with the author over the last couple of months
and I'm currently working on a (very long) list of technical errors
and suggestions on improvements. Jaqueline has already indicated that
she'll be happy to include my fixes in the next edition. Hopefully,
this will end up with another much improved beginners book on the
bookshelves.

It's very easy to just point out the errors in these books, but I
think it's far more positive to do something about it. From my
experience many of these authors are happy to work with more
experienced programmers to improve their books.

Mind you, I've still not had a response from Matt Wright and Craig
Prachett :)

Dave...


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

Date: Mon, 22 Oct 2001 14:14:04 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Good Literature
Message-Id: <x77ktn4v8o.fsf@home.sysarch.com>

>>>>> "DC" == Dave Cross <dave@dave.org.uk> writes:

  DC> Uri Guttman <uri@sysarch.com> wrote in message 
  DC> [about www.cgi101.com]

  >> i can't go on reading this. please don't recommend this site to anyone.

  DC> Hey Uri :)

  DC> Did you know that this site is based on a "best-selling" book. "CGI
  DC> 101" regularly outsells other, much better, Perl books (not that I'm
  DC> bitter, off course).

sure. marketing beats quality in many areas. ever heard of redmond? :)

also according to what i read, the site came first and the hardcopy was
created due to popular demand.

  DC> I've been in contact with the author over the last couple of months
  DC> and I'm currently working on a (very long) list of technical errors
  DC> and suggestions on improvements. Jaqueline has already indicated that
  DC> she'll be happy to include my fixes in the next edition. Hopefully,
  DC> this will end up with another much improved beginners book on the
  DC> bookshelves.

good luck. it needs much improvement.

  DC> It's very easy to just point out the errors in these books, but I
  DC> think it's far more positive to do something about it. From my
  DC> experience many of these authors are happy to work with more
  DC> experienced programmers to improve their books.

now why couldn't this have happened BEFORE it was published? why don't
these authors and publishers get competent tech reviewers? why do they
operate outside of the active perl community? where and who are the
masses who buy those books and why don't they participate in the
community and learn better perl habits? it is a puzzle to me how there
is a known very active community and then this much larger shadow perl
world where bad cgi code r00lz, learning proper programming and perl
is never encouraged and mattwright is the one eyed king.

  DC> Mind you, I've still not had a response from Matt Wright and Craig
  DC> Prachett :)

make sure you get in front of his one good eye. :)

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs  --------------------------  http://jobs.perl.org


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

Date: Mon, 22 Oct 2001 16:18:49 +0200
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: Good Literature
Message-Id: <9r19p9$2i7$05$1@news.t-online.com>

"Dave Cross" <dave@dave.org.uk> schrieb im Newsbeitrag
news:9d3debce.0110220538.1c5d5618@posting.google.com...
| Mind you, I've still not had a response from Matt Wright and Craig
| Prachett :)

Give up on Matt.

Steffen
--
$_=q;33352987319029872958319011313364356732192639127636833335345138283712
3712336415083973397340602842912;;s;\n;;;print"\n";$o=$_;push@o,substr($o,
$_*4,4)for(0..24);pop@o;for(@o){$i++;print' 'x(26-$i).(chr$_/29-$i)."\n"}





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

Date: Mon, 22 Oct 2001 16:23:03 +0200
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: Good Literature
Message-Id: <9r1a17$h2l$02$1@news.t-online.com>

"Uri Guttman" <uri@sysarch.com> schrieb im Newsbeitrag
news:x77ktn4v8o.fsf@home.sysarch.com...
| now why couldn't this have happened BEFORE it was published? why don't
| these authors and publishers get competent tech reviewers? why do they
| operate outside of the active perl community? where and who are the
| masses who buy those books and why don't they participate in the
| community and learn better perl habits? it is a puzzle to me how there
| is a known very active community and then this much larger shadow perl
| world where bad cgi code r00lz, learning proper programming and perl
| is never encouraged and mattwright is the one eyed king.

You just stated the reason why Perl is often falsely considered hard to
read, prone to errors, and a mere "CGI scripting language."[1]

Oh, and you mentioned one of the reasons why users & new programmers
generally tend to know very little about security. It's from Redmond and a
beast to secure.

[1] meaning "not suitable for anything but..."

Steffen
--
$_=q;33352987319029872958319011313364356732192639127636833335345138283712
3712336415083973397340602842912;;s;\n;;;print"\n";$o=$_;push@o,substr($o,
$_*4,4)for(0..24);pop@o;for(@o){$i++;print' 'x(26-$i).(chr$_/29-$i)."\n"}





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

Date: Mon, 22 Oct 2001 16:36:41 +0200
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: I can use some help... please ...
Message-Id: <9r1are$ijk$02$1@news.t-online.com>

"Bas Voordendag" <basv@ozemail.com.au> schrieb im Newsbeitrag
news:2LQA7.1886$G%4.134247@ozemail.com.au...
| I am working on a shopping cart and I'll have this problem  that bugs me
now
| for days.

You'll have much worse problems if you don't program using strict and
warnings.
CGI.pm would do you *a lot* of good, too.
Please excuse light sarcasm, but I just couldn't resist. Once more: use
strict. use warnings. Always. Read the newsgroup FAQ. Read the Perl FAQ.
Always.

People aren't likely to actually help you fix the problem you *see* unless
you first try to help yourself.

| This is how it works;

So far. Expect it to break if you leave it this way.

| The user has a uniek cart file : $mycookies{'sessionid'}.dat
| It contains the shopping cart items, and I want to be able for the
quantity
| to be changeable.
| The contents ir read and loaded into an array.
| Then the original cart file is erased.

Why erase it? Overwrite it once you have the new data ready.

[snip]

| The code:
|
| # Open the cart file for input
| if (!open (IN, "<user_carts\\$mycookies{'sessionid'}.dat")) {
| print "<p>Error opening catalogue file</p>";
| exit;
| }

Why not die?

[snip]

| # Erase cart file cart.dat

Again: Why erase it? What if another window tries to access the file while
it's empty?

| open (CART, ">user_carts\\$mycookies{'sessionid'}.dat");
| flock (CART, 2);

# not portable.

| seek (CART, 0, 2);

seek CART, 0, 0;

| print CART "";

truncate.

| flock (CART, 8);

# *Never* do that. It will bring problems. Close removes the flock.

| close CART;

[snip]

| # Process form data
| foreach $pair (@form_data) {
| ($name, $myvalue) = split (/=/, $pair);
| $form_data{$name} = $myvalue;
| #

use CGI;

Use param()!

| # Process each record
| foreach $item (@cart) {
| # Remove newline character from end of record
| chop;

chomp is better for this. Read the FAQ, I think there's something about that
in there, too.

| # Split out record fields
| ($field, $description, $unit, $price, $content, $row_total) = split (/:/,
| $item);
| }

use strict;
Use my for scoping.

| # Allocate new value
| $content = $myvalue;

Why copy it?

[snip]

| open (CART, ">>user_carts\\$mycookies{'sessionid'}.dat");
| flock (CART, 2);
| seek (CART, 0, 2);
| print CART "$field:$description:$unit:$price:$content:$row_total\n";

print CART join(':', $field, $description, ...), "\n" ;

| flock (CART, 8);

Again: never.

| close CART;
| }

Do not use this code. It is very broken. A shopping cart may be easy to
program, but is pretty hard to secure.
I consider myself an intermediate programmer, but would still be very wary
when programming something that directly deals with money (as in:
numbers/data) because (security) bugs can directly affect capital. With all
due respect, your (Perl) programming skills do not seem to be up to this
task. No insult intended.

HTH,

Steffen
--
$_=q;33352987319029872958319011313364356732192639127636833335345138283712
3712336415083973397340602842912;;s;\n;;;print"\n";$o=$_;push@o,substr($o,
$_*4,4)for(0..24);pop@o;for(@o){$i++;print' 'x(26-$i).(chr$_/29-$i)."\n"}





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

Date: 22 Oct 2001 14:29:43 GMT
From: troc@netrus.net (Rocco Caputo)
Subject: Re: IO::Socket broken on win
Message-Id: <slrn9t8bal.11o.troc@eyrie.homenet>

On Mon, 22 Oct 2001 06:25:27 -0400, Benjamin Goldberg wrote:
>Fe wrote:
>> 
>[snip]
>> also i am missing a lot of error constants (even ubiquitous
>> EWOULDBLOCK)
>
>When you 'use Errno', you don't get this constant?

I'm not sure in recent ActiveState Perl builds, but traditionally no.
From POE::Kernel and POE::Wheel::SocketFactory...

  if ($^O eq 'MSWin32') {
    eval '*EINPROGRESS = sub { 10036 };';
    eval '*EWOULDBLOCK = sub { 10035 };';
    eval '*F_GETFL     = sub {     0 };';  # so code compiles
    eval '*F_SETFL     = sub {     0 };';
  }

Supporting non-blocking errno values may be a low priority considering
that recent ActiveState Perl builds don't support the corresponding
fcntl() calls:

  http://bugs.activestate.com/cgi-bin/bugzilla/show_bug.cgi?id=14518
  http://bugs.activestate.com/cgi-bin/bugzilla/show_bug.cgi?id=14560

PerlIO may work around this.

-- Rocco Caputo / troc@netrus.net / poe.perl.org / poe.sourceforge.net


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

Date: 22 Oct 2001 07:43:20 -0700
From: linux_303@yahoo.com (Linux_303)
Subject: Re: Need multiple matches in a regular expression
Message-Id: <77aaac7e.0110220643.1b64599e@posting.google.com>

Thank you all for your help!
Chris Fedde's solution would have worked except that the log is
concatonated into one line.
I used Mark's solution and it worked great!
Here is what I did....

$passed = 0;
                                                              
open(VIEW,"viewtrip_test.asp.$date");
@lines = <VIEW>;
LINE:
foreach $line (@lines) {
while ($line =~ /Server passed tests/g) {
$passed++;
if ($passed == 3) { last LINE }
        }
}
                                                              
if ($passed == 3) {
          print "Passed\n";
        } else {
          print "Failed\n";  
        }


Tested it and it works like a charm!

Thank you all....

Sistem




mjd@plover.com (Mark Jason Dominus) wrote in message news:<3bd36552.1b9f$17f@news.op.net>...
> In article <77aaac7e.0110211436.34a4524e@posting.google.com>,
> Linux_303 <linux_303@yahoo.com> wrote:
> >open(VIEW,"file.$date");
> >@lines = <VIEW>;
> >foreach $line (@lines) {
> >if ($line =~ /Server passed checks/g) {
> >print "Passed\n";
> >}
> >else {
> >      print "Failed\n";
> >}
> >}
> >
> >As written, it does report with a Passed but it is only parsing the
> >first "Server passed checks" and reporting it as Passed.  I need to
> >make sure it finds three though.
> 
> You mean you want to find 'Server passed checks' three times, but the
> three appearances might be in different places in the file, yes?
> 
> Try this:
> 
>         $passed = 0;
> 
>         LINE:
>         foreach $line (@lines) {
>           while ($line =~ /Server passed checks/g) {
>             $passed++;
>             if ($passed >= 3) { last LINE }            
>           }
>         }
> 
>         if ($passed >= 3) {
>           print "Passed\n";
>         } else {
>           print "Failed\n";
>         }
> 
> 
> If "Server passed checks" will appear no more than once per line, you
> can make the code a little simpler:
> 
>         $passed = 0;
> 
>         LINE:
>         foreach $line (@lines) {
>           if ($line =~ /Server passed checks/) {
>             $passed++;
>             if ($passed >= 3) { last LINE }            
>           }
>         }
> 
>         if ($passed >= 3) {
>           print "Passed\n";
>         } else {
>           print "Failed\n";
>         }
> 
> I hope this is helpful.


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

Date: Mon, 22 Oct 2001 14:31:47 -0000
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: New posters to comp.lang.perl.misc
Message-Id: <tt8bejqiclfr9a@corp.supernews.com>

Following is a summary of articles from new posters spanning a 7 day
period, beginning at 15 Oct 2001 15:26:06 GMT and ending at
22 Oct 2001 14:58:17 GMT.

Notes
=====

    - A line in the body of a post is considered to be original if it
      does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
    - All text after the last cut line (/^-- $/) in the body is
      considered to be the author's signature.
    - The scanner prefers the Reply-To: header over the From: header
      in determining the "real" email address and name.
    - Original Content Rating (OCR) is the ratio of the original content
      volume to the total body volume.
    - Find the News-Scan distribution on the CPAN!
      <URL:http://www.perl.com/CPAN/modules/by-module/News/>
    - Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.
    - Copyright (c) 2001 Greg Bacon.
      Verbatim copying and redistribution is permitted without royalty;
      alteration is not permitted.  Redistribution and/or use for any
      commercial purpose is prohibited.

Totals
======

Posters:  112 (33.2% of all posters)
Articles: 202 (18.4% of all articles)
Volume generated: 411.8 kb (19.8% of total volume)
    - headers:    157.8 kb (3,241 lines)
    - bodies:     248.8 kb (8,637 lines)
    - original:   182.7 kb (6,480 lines)
    - signatures: 5.0 kb (146 lines)

Original Content Rating: 0.734

Averages
========

Posts per poster: 1.8
    median: 1.0 post
    mode:   1 post - 65 posters
    s:      1.7 posts
Message size: 2087.3 bytes
    - header:     799.9 bytes (16.0 lines)
    - body:       1261.3 bytes (42.8 lines)
    - original:   926.3 bytes (32.1 lines)
    - signature:  25.1 bytes (0.7 lines)

Top 10 Posters by Number of Posts
=================================

         (kb)   (kb)  (kb)  (kb)
Posts  Volume (  hdr/ body/ orig)  Address
-----  --------------------------  -------

    8    17.6 (  6.7/ 10.9/  6.0)  =?ISO-8859-1?Q?sh=F2wd=F6g?= <showdog@my-deja.com>
    6    11.8 (  4.5/  7.2/  5.8)  "George Jempty" <jemptyg@rwmc.net>
    5    27.9 (  4.5/ 23.3/ 20.6)  "Diehard Duck" <diehard@nospam.userve.co.uk>
    5    11.7 (  4.7/  5.6/  2.7)  Ilmari Karonen <usenet11616@itz.pp.sci.fi>
    4     5.6 (  3.2/  2.4/  1.6)  "Dr. Kokinis" <doctor_pericles@hotmail.com>
    4     7.2 (  3.3/  3.9/  1.6)  andrew.hutchinson@mcmail.vanderbilt.edu
    4     9.5 (  3.7/  5.8/  4.0)  John English <je@brighton.ac.uk>
    4     7.9 (  4.3/  3.6/  2.2)  theother1@REMOVEhotmail.com
    4     5.9 (  2.4/  3.4/  1.2)  Arnuga <arnuga@yahoo.com>
    4     7.1 (  3.1/  4.0/  3.0)  "Neal E. Coombes" <Neal.Coombes@telus.net>

These posters accounted for 4.4% of all articles.

Top 10 Posters by Volume
========================

  (kb)   (kb)  (kb)  (kb)
Volume (  hdr/ body/ orig)  Posts  Address
--------------------------  -----  -------

  27.9 (  4.5/ 23.3/ 20.6)      5  "Diehard Duck" <diehard@nospam.userve.co.uk>
  17.9 (  0.9/ 17.0/ 16.9)      1  "Stephane Barizien" <NOSPsbaAM@ocegr.fr>
  17.6 (  6.7/ 10.9/  6.0)      8  =?ISO-8859-1?Q?sh=F2wd=F6g?= <showdog@my-deja.com>
  11.8 (  4.5/  7.2/  5.8)      6  "George Jempty" <jemptyg@rwmc.net>
  11.7 (  1.9/  9.8/  2.3)      2  "Matthew Lock" <matthew@perthonline.net>
  11.7 (  4.7/  5.6/  2.7)      5  Ilmari Karonen <usenet11616@itz.pp.sci.fi>
  10.6 (  2.2/  8.4/  6.7)      3  "DocDodge" <DocDodge@hotmail.com>
   9.5 (  3.7/  5.8/  4.0)      4  John English <je@brighton.ac.uk>
   9.5 (  2.1/  7.4/  6.4)      3  Vince <zambak76@yahoo.com>
   9.3 (  2.4/  4.0/  2.0)      3  Thomas Goebel <goebelt@herpa.de>

These posters accounted for 6.6% of the total volume.

Top 10 Posters by OCR (minimum of three posts)
==============================================

         (kb)    (kb)
OCR      orig /  body  Posts  Address
-----  --------------  -----  -------

1.000  (  1.5 /  1.5)      3  David Filmer <ineverreadanythingsenttome@hotmail.com>
1.000  (  1.9 /  1.9)      3  "ad2ndhand" <ad2ndhand@yahoo.com>
0.881  ( 20.6 / 23.3)      5  "Diehard Duck" <diehard@nospam.userve.co.uk>
0.864  (  6.4 /  7.4)      3  Vince <zambak76@yahoo.com>
0.799  (  5.8 /  7.2)      6  "George Jempty" <jemptyg@rwmc.net>
0.791  (  6.7 /  8.4)      3  "DocDodge" <DocDodge@hotmail.com>
0.739  (  3.0 /  4.0)      4  "Neal E. Coombes" <Neal.Coombes@telus.net>
0.704  (  2.1 /  3.0)      3  Alessandro Augusto <ra990866@ic.unicamp.br>
0.692  (  4.0 /  5.8)      4  John English <je@brighton.ac.uk>
0.673  (  2.1 /  3.2)      3  Ng Chze Yong <CYNg@ntu.edu.sg>

Bottom 10 Posters by OCR (minimum of three posts)
=================================================

         (kb)    (kb)
OCR      orig /  body  Posts  Address
-----  --------------  -----  -------

0.553  (  6.0 / 10.9)      8  =?ISO-8859-1?Q?sh=F2wd=F6g?= <showdog@my-deja.com>
0.490  (  2.0 /  4.0)      3  Thomas Goebel <goebelt@herpa.de>
0.480  (  1.8 /  3.7)      3  "Marco Guazzone" <sguazt@infodrome.net>
0.471  (  2.7 /  5.6)      5  Ilmari Karonen <usenet11616@itz.pp.sci.fi>
0.442  (  1.6 /  3.7)      3  Roger Levy <rog@stanford.edu>
0.414  (  1.2 /  2.8)      4  jh123@nc.rr.com
0.408  (  1.6 /  3.9)      4  andrew.hutchinson@mcmail.vanderbilt.edu
0.344  (  1.2 /  3.4)      4  Arnuga <arnuga@yahoo.com>
0.292  (  1.1 /  3.9)      3  Martial Chateauvieux <chawig@eplus-online.de>
0.089  (  0.2 /  2.7)      3  John Imrie <johni@pa.press.net>

24 posters (21%) had at least three posts.

Top 10 Targets for Crossposts
=============================

Articles  Newsgroup
--------  ---------

      20  comp.lang.perl.modules
       5  comp.lang.perl.moderated
       5  comp.protocols.snmp
       5  alt.perl
       4  comp.lang.perl
       2  alt.comp.perlcgi.freelance
       2  comp.os.linux.x
       1  comp.lang.tcl
       1  comp.lang.scheme

Top 10 Crossposters
===================

Articles  Address
--------  -------

       4  Thomas Wilson <tewilson@mitre.org>
       2  "Steven" <steven@steven.com>
       2  "Jim Jones" <jsjones@acm.org>
       2  "Matthew Lock" <matthew@perthonline.net>
       2  David Rush <kumo@bellsouth.net>
       2  ajohnson_no_spam@purplemountain.net
       2  Sean Egan <sean.egan@eei.ericsson.se>
       1  Dave Lehman <dlehman+USENET@redhat.com>
       1  Kévin Roussel <Kevin.Roussel@pharma.u-nancy.fr>
       0  "Bob Dover" <dover@nortelnetworks.com>


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

Date: Mon, 22 Oct 2001 16:43:09 +0200
From: Edwin =?iso-8859-1?Q?G=FCnthner?= <edgue@web.de>
Subject: problem with pods
Message-Id: <3BD4307D.2811A424@web.de>

Hi there,

I am currently documenting some modules and I wrote
stuff like that here:

=head1 FUNCTIONS

=over 8

=item init

 C<init> does this and that ....

I used pod2html to create a HTML version - and I was
quite surprised to see that "C<init>" was not 
translated into another font - the string that
appears in HTML is still "C<init>" ...

any idea whats wrong?

thx,
eg


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

Date: 22 Oct 2001 14:50:55 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: problem with pods
Message-Id: <slrn9t8cio.3ch.rgarciasuarez@rafael.kazibao.net>

Edwin Günthner wrote in comp.lang.perl.misc:
> 
> I am currently documenting some modules and I wrote
> stuff like that here:
> 
> =head1 FUNCTIONS
> 
> =over 8
> 
> =item init
> 
>  C<init> does this and that ....
  ^
That's a space, isn't it ?

> I used pod2html to create a HTML version - and I was
> quite surprised to see that "C<init>" was not 
> translated into another font - the string that
> appears in HTML is still "C<init>" ...
> 
> any idea whats wrong?

Remove the space at the beginning of your paragraph.
Lookup 'verbatim paragraph' in the perlpod manpage for the full story.

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
Owner: There, he moved!
Customer: No, he didn't, that was you hitting the cage!
    -- Monty Python, The Pet Shop


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

Date: Mon, 22 Oct 2001 13:19:36 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: Reading two variables from a file
Message-Id: <GLLzop.C5M@presby.edu>

In article <9r0gtl$i0h$1@newstoo.ericsson.se>,
Peter <peter_laranc@yahoo.com> wrote:
>
>My input file has following format:
>
># Line with # should be ignored
>
>192.168.0.1                       PC1234
>
>192.168.0.2                       PC1235

I'd like to comment on your file-reading logic here:

>open (FILE,'device.cfg') or die "Cant open device.cfg $! ";

The following statement reads a line from the file, and throws it away, 
because you don't do anything with $data before reading the next line.

>my $data = <FILE>;

Next, you read another line from the file, and enter the loop if you 
haven't hit the end of file.  You read another line here each time you go 
round the loop.

>while(defined (my $data =<FILE>)){
>
># I should discard line with # and only reads a line having IP and hostname.
>
>if ($line =~ m/^((\d+)\S(\d+)\S(\d+)\S(\d+))\S+(\s*)$/) {
>print "The IP is : ",$1," and the host name is  : ",$2," \n";
>}
> else {print "The input data did not contains IP and hostname \n"; }

And now you read *another* line on each trip around the loop, and throw it 
away when you go back to the beginning of the loop and get another line.

> $data = <FILE>;
>
>
>}

If the first, third, fifth, etc. lines of your file are all blank (or you 
can otherwise ignore them), then you're OK.  But this seems like a major 
restriction on the format of the file.  Why not simply skip over any 
blank lines you encounter, or lines that begin with #?

open (FILE, 'device.cfg') or die "Can't open device.cfg $!";

# read one line each time around the loop

while (defined (my $data = <FILE>)) {

    # process only lines that do not begin with #, and that contain
    # non-whitespace characters (i.e. are not completely blank)

    if (($data !~ /^#/) && ($data =~ /\S+/) {

        my ($IP, $name) = split (/\s+/, $data);  # split on whitespace

        # do something with $IP and $name here

    }
}

-- 
Jon Bell <jtbell@presby.edu>                        Presbyterian College
Dept. of Physics and Computer Science        Clinton, South Carolina USA


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

Date: Mon, 22 Oct 2001 14:52:07 +0100
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: Separating data from a long string
Message-Id: <3BD42487.F0F92424@oracle.com>

This is a multi-part message in MIME format.
--------------173B6ECB11711C80A4571DE1
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

Martin wrote:

> $msg   = "Seq.No.=100, Id=20, Name=Advanced Perl, Desc=Student Book, Aval=
> Not Avalable, Ack=Very Good Book, Authors=Steve, Publisher=Printice Hall";
>
> And I want to save these data in my variables :
>
>  my ($Seq, $Id, $Name, $Desc, $Aval, $Ack, $Authors, $Publisher);

my ($Seq, $Id, $Name, $Desc, $Aval, $Ack, $Authors, $Publisher) =
$msg =~ /=([^,]+),?/g;

matches an "=" then returns all non "," characters between the "=" and the
next "," into the next variable in the list.  This assumes you have no commas
in your values, that all values are separated from the following variable name
by a comma and that the values always appear in this order.  The final ? means
match zero or one of the previous character (ie the comma).  This catches the
final value "Printice Hall" which doesn't have a terminating comma.

Hope this helps

Graham Wood

--------------173B6ECB11711C80A4571DE1
Content-Type: text/x-vcard; charset=UTF-8;
 name="Graham.T.Wood.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Graham Wood
Content-Disposition: attachment;
 filename="Graham.T.Wood.vcf"

begin:vcard 
n:;Graham
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:Graham.T.Wood@oracle.com
fn:Graham Wood
end:vcard

--------------173B6ECB11711C80A4571DE1--



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

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


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