[28208] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9572 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 7 18:10:20 2006

Date: Mon, 7 Aug 2006 15:10:12 -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           Mon, 7 Aug 2006     Volume: 10 Number: 9572

Today's topics:
        How to integrate other scripts with Test::Harness? <yusufm@gmail.com>
    Re: How to integrate other scripts with Test::Harness? <mritty@gmail.com>
    Re: How to integrate other scripts with Test::Harness? <yusufm@gmail.com>
    Re: How to use OO and package? <bik.mido@tiscalinet.it>
    Re: How to use OO and package? <john@castleamber.com>
        Net FTP -- Size showing different results on AIX system <fmbright@gmail.com>
    Re: Net FTP -- Size showing different results on AIX sy usenet@DavidFilmer.com
    Re: Net FTP -- Size showing different results on AIX sy <fmbright@gmail.com>
    Re: Net FTP -- Size showing different results on AIX sy <1usa@llenroc.ude.invalid>
    Re: Net FTP -- Size showing different results on AIX sy usenet@DavidFilmer.com
    Re: Perl hash of hash efficiency. <scobloke2@infotop.co.uk>
    Re: Proc::Daemon and Sockets <jgibson@mail.arc.nasa.gov>
    Re: Public/Private Data/Funcion in Perl OO? <clarke@n_o_s_p_a_m_hyperformix.com>
    Re: Public/Private Data/Funcion in Perl OO? anno4000@radom.zrz.tu-berlin.de
    Re: Public/Private Data/Funcion in Perl OO? <uri@stemsystems.com>
    Re: Simple file list in directory to array <jgibson@mail.arc.nasa.gov>
    Re: skip path prune <jgibson@mail.arc.nasa.gov>
    Re: skip path prune <1usa@llenroc.ude.invalid>
        Test::Harness and test values. <yusufm@gmail.com>
    Re: Test::Harness and test values. <1usa@llenroc.ude.invalid>
    Re: What bless() do actually? <rvtol+news@isolution.nl>
    Re: Zero'ing out an array <dha@panix.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 7 Aug 2006 11:23:53 -0700
From: "yusuf" <yusufm@gmail.com>
Subject: How to integrate other scripts with Test::Harness?
Message-Id: <1154975033.320317.43480@n13g2000cwa.googlegroups.com>

Hi,

I was trying to use Test::Harness to gather output from my bash scripts
as well, and I'm having problems with items being printed by the
script.

How do I get all stdout and stderr from the script to be just printed
by the Test::Harness, rather than disappearing?

Thanks.



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

Date: 7 Aug 2006 11:33:29 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: How to integrate other scripts with Test::Harness?
Message-Id: <1154975609.426798.143840@i3g2000cwc.googlegroups.com>

yusuf wrote:

> I was trying to use Test::Harness to gather output from my bash scripts
> as well, and I'm having problems with items being printed by the
> script.
>
> How do I get all stdout and stderr from the script to be just printed
> by the Test::Harness, rather than disappearing?

In the past, you've been asked by several people - myself included - to
post a SHORT but COMPLETE script when you have difficulties.  Why do
you continue to refuse to do that?  Why do you continue to expect free
help without following even the most simple of requests?

Additionally, please read the documentation for the module you are
using.  In this case, perldoc Test::Harness shows:
==============================
STOP! If all you want to do is write a test script, consider using
Test::Simple. Test::Harness is the module that reads the output from
Test::Simple, Test::More and other modules based on Test::Builder. You
don't need to know about Test::Harness to use those modules.

Test::Harness runs tests and expects output from the test in a certain
format. That format is called TAP, the Test Anything Protocol. It is
defined in Test::Harness::TAP.
==============================

So, are you sure you know what you're doing?  Doesn't really sound like
your tests *should* be outputting anything other than TAP formatted
messages.

If you were to keep reading, you would find:
==============================
$Test::Harness::Verbose
The package variable $Test::Harness::Verbose is exportable and can be
used to let runtests() display the standard output of the script
without altering the behavior otherwise. The prove utility's -v flag
will set this.
===============================

Did you try that?

Paul Lalli



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

Date: 7 Aug 2006 12:54:06 -0700
From: "yusuf" <yusufm@gmail.com>
Subject: Re: How to integrate other scripts with Test::Harness?
Message-Id: <1154980446.271671.327580@h48g2000cwc.googlegroups.com>


Paul Lalli wrote:
> yusuf wrote:
>
> > I was trying to use Test::Harness to gather output from my bash scripts
> > as well, and I'm having problems with items being printed by the
> > script.
> >
> > How do I get all stdout and stderr from the script to be just printed
> > by the Test::Harness, rather than disappearing?
>
> In the past, you've been asked by several people - myself included - to
> post a SHORT but COMPLETE script when you have difficulties.  Why do
> you continue to refuse to do that?  Why do you continue to expect free
> help without following even the most simple of requests?
>
> Additionally, please read the documentation for the module you are
> using.  In this case, perldoc Test::Harness shows:
> ==============================
> STOP! If all you want to do is write a test script, consider using
> Test::Simple. Test::Harness is the module that reads the output from
> Test::Simple, Test::More and other modules based on Test::Builder. You
> don't need to know about Test::Harness to use those modules.
>
> Test::Harness runs tests and expects output from the test in a certain
> format. That format is called TAP, the Test Anything Protocol. It is
> defined in Test::Harness::TAP.
> ==============================
>
> So, are you sure you know what you're doing?  Doesn't really sound like
> your tests *should* be outputting anything other than TAP formatted
> messages.
>
> If you were to keep reading, you would find:
> ==============================
> $Test::Harness::Verbose
> The package variable $Test::Harness::Verbose is exportable and can be
> used to let runtests() display the standard output of the script
> without altering the behavior otherwise. The prove utility's -v flag
> will set this.
> ===============================
>

Thanks for you help. I didn't post code, because this didn't seem to be
a code issue. I'll do that next time.



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

Date: 7 Aug 2006 15:24:57 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: How to use OO and package?
Message-Id: <c1fed2ta28t6vqvjdjthoicqlg2djibeke@4ax.com>

On 7 Aug 2006 03:44:18 -0700, "Davy" <zhushenli@gmail.com> wrote:

>Thanks! But why the program need a return value, what's the function
>means??

You're welcome! But why do you top-post? This is annoying, you know...

Re your actual question... I can hardly make any sense of it. We're
*not* speaking of a program's return value. And I don't have the
slightest idea of which means of which function you're referring to.

To come back on the topic we were dealing with: you can have multiple
packages in a file. Thus

  #!/usr/bin/perl -l
  
  use strict;
  use warnings;
  
  {
      package Foo;
      sub bar { 'baz' }
  }
  
  print Foo->bar;
  
  __END__

But if you plan of making Foo a proper module in a separate file, then
you'll need to use() or require() it. If you check

  perldoc -f require

you'll notice this paragraph:

  The file must return true as the last statement to indicate
  successful execution of any initialization code, so it's cus-
  tomary to end such a file with "1;" unless you're sure it'll
  return true otherwise.  But it's better just to put the "1;",
  in case you add more statements.

Are you asking why it is so? Well, there are good reasons, but I think
you won't be interested in knowing. You may want to know that there's
people who whish there were a way to use the actual return value, thus
allowing one to put there something more interesting than a
generically true (or false) value.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: 7 Aug 2006 15:57:50 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: How to use OO and package?
Message-Id: <Xns98186F86D8BF9castleamber@130.133.1.4>

Michele Dondi <bik.mido@tiscalinet.it> wrote:

> Are you asking why it is so? Well, there are good reasons, but I think
> you won't be interested in knowing. You may want to know that there's
> people who whish there were a way to use the actual return value

perldoc -f do:

"returns undef and sets an error message in $@. If the file is
 successfully compiled, "do" returns the value of the last
 expression evaluated.
"

The perldoc -f for require shows that do is used, so I would say that you 
actually might be able to get the value returned (at least by require).

Testing:


C:\Documents and Settings\John\My Documents>type rtest.pl
use strict;
use warnings;

print require 'RTest.pm';
C:\Documents and Settings\John\My Documents>type RTest.pm
10;

C:\Documents and Settings\John\My Documents>rtest.pl
10

-- 
John Bokma          Freelance software developer
                                &
                    Experienced Perl programmer: http://castleamber.com/


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

Date: 7 Aug 2006 12:54:48 -0700
From: "fmbright" <fmbright@gmail.com>
Subject: Net FTP -- Size showing different results on AIX system and Linux system
Message-Id: <1154980488.268872.30470@75g2000cwc.googlegroups.com>

To All:

This is my first post.  My name is Frank.  I have been using  Net FTP
to create an automated FTP process.  I developed it on an AIX box (AIX
5.2.0.7)  and now want to move it to our Linux box (Redhat).  The size
subroutine gives different results when running on the AIX version
Linux box.  On the AIX the size functions returns the size of the file
on the FTP while the call on the Linux box returns undefined.

I am calling the same FTP site each time and using the same version of
the script.  What else would need to be done to get these version in
sync??

Thanks!


Frank Bright
Univ. of the Arts
215.717.6081
fbright@uarts.edu



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

Date: 7 Aug 2006 13:12:14 -0700
From: usenet@DavidFilmer.com
Subject: Re: Net FTP -- Size showing different results on AIX system and Linux system
Message-Id: <1154981534.040125.107900@h48g2000cwc.googlegroups.com>

fmbright wrote:
> This is my first post.  My name is Frank.

Hi, Frank. Being new here, you are probably not aware of the posting
guidelines for this group, which you may read online at:

   http://www.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html

You will notice that the guidelines suggest posting a small, functional
program which demonstrates your problem.

If you had done that, I would be happy to cut-and-paste your code into
my editor and try to reproduce your results (as I have access to both
AIX and Linux systems).  Because (had you followed the posting
guidelines) you would have made it very easy to help you.

But you have not made it easy for me to help you.  In fact, any help I
would be able to offer would be limited to idle speculation, as I have
no idea what your code looks like.

The posting guidelines are for your benefit - they help you ask a good
question and thus increase the chances of getting a good answer.  You
would do well to read them prior to your next posting.

-- 
David Filmer (http://DavidFilmer.com)



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

Date: 7 Aug 2006 13:41:52 -0700
From: "fmbright" <fmbright@gmail.com>
Subject: Re: Net FTP -- Size showing different results on AIX system and Linux system
Message-Id: <1154983312.270157.160070@n13g2000cwa.googlegroups.com>

Sorry All!!

My bad....  here is the snipett of the problem.  Forgive my spelling,
that is why I went into computers!!

You will see the vars $filetime and $filesize.  They record the calls
to mdtm and size.   On our AIX box the calls return info.  On our linux
box these calls return undef.  And we are testing to the same ftp site.

Any suggestions the same calls on two boxes would give two different
results??

FMB

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

#!/usr/bin/perl -w
use strict;
use Getopt::Long;
use Net::FTP;
use Time::Local;

use Carp ();
local $SIG{__WARN__} = \&Carp::cluck;

## Variables
my($ftp)        = "";     my $login       = "";    my $passwd      =
"";
my $host        = "";    my $host_dir    = "";  my $binary      = 0;
my $quiet       = 0;     my $ftp_get     = 1;   my $ftp_put     = 0;
my $localdir    = "";   my $debug       = 0;  my $ascii       = 0;
my $date_name   = 0;   my @rlist       = ();  my $help        = "";
my $anonymous   = "";  my $chown       = "";  my $chmod       = "";
my $before_date = 0;   my $after_date  = 0;

##  Get Command Line Options!
do_get_options();

if ($debug) {
        print "Printing settings\n";
        print "\t\$login       = ".$login      ."\n";
        print "\t\$passwd      = ".$passwd     ."\n";
        print "\t\$host        = ".$host       ."\n";
        print "\t\$host_dir    = ".$host_dir   ."\n";
        print "\t\$localdir    = ".$localdir   ."\n";
        print "\t\$binary      = ".$binary     ."\n";
        print "\t\$quiet       = ".$quiet      ."\n";
        print "\t\$ftp_get     = ".$ftp_get    ."\n";
        print "\t\$ftp_put     = ".$ftp_put    ."\n";
        print "\t\$debug       = ".$debug      ."\n";
}

## Check Options -- print help if necessary!
check_options();

## Try getting files (default)
do_get_ftp() unless $ftp_put;

## decrypt with gpg if asekd!
do_decrypt(@rlist) if $decrypt;


exit;

#  FTP files from site!
sub do_get_ftp {
        $login = "anonymous" if $anonymous;    #  Set anonymous login.
$anonymou
s
        $passwd = $anonymous if $anonymous;    #  will have user's
email address
!

        print "\nStarting FTP!\nAttempting to connect to host ...
".$host if !$q
uiet;
        $ftp = Net::FTP->new($host, Debug => $debug)
                || die "\nCannot connect to ".$host.$ftp->message."\n";

        print "   (Connected!)\nAttempting to login as ... ".$login if
!$quiet;
        $ftp->login($login,$passwd)
                || die "\nCannot login to ".$host." -
".$ftp->message."\n";

        print "   (Logged in!)\n";
        print "Changing directory to ".$host_dir."\n" if !$quiet &&
$host_dir;
        $ftp->cwd($host_dir) || die "Cannot change to directory
".$host_dir." -
".$ftp->message if $host_dir;
        $host_dir = $ftp->pwd if !$host_dir;
        print "Current directory ".$host_dir."\n" if !$quiet;

        print "Setting transfer mode to binary\n" if !$quiet &&
$binary;
        $ftp->binary || die "Cannot set transfer mode to binary -
".$ftp->messag
e if $binary;

        print "Setting transfer mode to ASCII\n" if !$quiet && $ascii;
        $ftp->ascii || die "Cannot set transfer mode to ascii -
".$ftp->message
if $ascii;

        print "Retrieving files ...\n" if !$quiet;
        print "  ...saving to folder $localdir\n" if $localdir &&
!$quiet;
        print "  ...before ".&print_time($before_date) if $before_date
&& !$quie
t;
        print "  ...after ".&print_time($after_date) if !$quiet &&
$after_date;
        print "  ...using filter -> ".$ftp_patt."\n" if $ftp_patt &&
!$quiet;
        my($list)=$ftp->ls() || die "Cannot retrieve files from
directory - ".$h
ost_dir."\n".$ftp->message."\n";
        $ftp_patt =~ s/\.\.\./.*/g if $ftp_patt;   $ftp_patt =~
s/\?/.?/g if $ft
p_patt;
        @$list = grep(/$ftp_patt/, @$list) if $ftp_patt;   #  Apply
pattern filt
er!
        foreach my $get (@$list) {
                my $local_put = ($localdir) ? $localdir."/".$get :
$get;
                my $filetime = $ftp->mdtm($get);
                my $filesize = $ftp->size($get);
                my $y = &pass_date_filter($filetime);
                if ($y)  {
                        $ftp->get("$get", $local_put) || die "\nFailed
retrievin
g $_  ->".$ftp->message."\n";
                        print "   ".$get."  ".&print_time($filetime)."
".$files
ize."\n" if !$quiet;
                        push @rlist,$local_put;
                }
        }
        print "No files were retrieved!\n" if !$quiet && !@rlist;
        print "Finished retrieving files!\n" if !$quiet && @rlist;
        print "Disconnecting!\n" if !$quiet;
        $ftp->quit() || die "Failed to quit ftp!\n", $ftp->message;
}

sub print_time {
        my $x = shift;
        my @x = localtime($x);
        return sprintf("%02d.%02d.%04d", $x[4]+1, $x[3], $x[5]+1900);
}

sub get_date_name {
        my @x = localtime(time);
        return sprintf("_%02d%02d%4d",$x[4]+1,$x[3],$x[5]+1900);
}

sub pass_date_filter {
        my $x = shift;
        return 1 if !$before_date && !$after_date;
        return 1 if $before_date && $after_date && $x < $before_date &&
$x > $af
ter_date;
        return 1 if $before_date && $x < $before_date && !$after_date;
        return 1 if $after_date && $x > $after_date && !$before_date;
        return 0;
}


fmbright wrote:
> To All:
>
> This is my first post.  My name is Frank.  I have been using  Net FTP
> to create an automated FTP process.  I developed it on an AIX box (AIX
> 5.2.0.7)  and now want to move it to our Linux box (Redhat).  The size
> subroutine gives different results when running on the AIX version
> Linux box.  On the AIX the size functions returns the size of the file
> on the FTP while the call on the Linux box returns undefined.
>
> I am calling the same FTP site each time and using the same version of
> the script.  What else would need to be done to get these version in
> sync??
>
> Thanks!
>
> 
> Frank Bright
> Univ. of the Arts
> 215.717.6081
> fbright@uarts.edu



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

Date: Mon, 07 Aug 2006 21:06:30 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Net FTP -- Size showing different results on AIX system and Linux system
Message-Id: <Xns9818AE2131223asu1cornelledu@127.0.0.1>

"fmbright" <fmbright@gmail.com> wrote in news:1154983312.270157.160070
@n13g2000cwa.googlegroups.com:

> My bad....  here is the snipett of the problem.  Forgive my spelling,
> that is why I went into computers!!

There are other things I feel disinclined to forgive though. For 
example, you are expected to post the shortest script that still 
exhibits the problem, not an uncompilable mess. Line wraps, missing 
routines do not make the task of helping you any easier.

Also, I am pondering why you would not run a very short script that just 
logs on to the site, and uses the problem methods *with* Net::FTP's 
debugging turned on. Since we can't actually try logging on the FTP 
server you are using, that information might be of some benefit in 
diagnosing your problem.

> ---------------
> 
> #!/usr/bin/perl -w

#!/usr/bin/perl

use warnings;
> use strict;
> use Getopt::Long;
> use Net::FTP;
> use Time::Local;
> 
> use Carp ();
> local $SIG{__WARN__} = \&Carp::cluck;
> 
> ## Variables
> my($ftp)        = "";     my $login       = "";    my $passwd      =
> "";
> my $host        = "";    my $host_dir    = "";  my $binary      = 0;
> my $quiet       = 0;     my $ftp_get     = 1;   my $ftp_put     = 0;
> my $localdir    = "";   my $debug       = 0;  my $ascii       = 0;
> my $date_name   = 0;   my @rlist       = ();  my $help        = "";
> my $anonymous   = "";  my $chown       = "";  my $chmod       = "";
> my $before_date = 0;   my $after_date  = 0;

What the heck is this? Do we have any idea where each of these variables 
gets used? Declare variables in the smallest applicable scope. Group 
related config variables in a hash.
 
> ##  Get Command Line Options!
> do_get_options();

Why the exclamation?

> 
> if ($debug) {
>         print "Printing settings\n";
>         print "\t\$login       = ".$login      ."\n";
>         print "\t\$passwd      = ".$passwd     ."\n";
>         print "\t\$host        = ".$host       ."\n";
>         print "\t\$host_dir    = ".$host_dir   ."\n";
>         print "\t\$localdir    = ".$localdir   ."\n";
>         print "\t\$binary      = ".$binary     ."\n";
>         print "\t\$quiet       = ".$quiet      ."\n";
>         print "\t\$ftp_get     = ".$ftp_get    ."\n";
>         print "\t\$ftp_put     = ".$ftp_put    ."\n";
>         print "\t\$debug       = ".$debug      ."\n";
> }

See, now, if you had just put all the options in a hash, you could have 
replaced this mess with:

print map { "$_ => $myconfig{$_}\n"} keys %myconfig if $debug;

> ## Check Options -- print help if necessary!

What's up with all the exclamation points?

Anyway, moving on ...

>         my($list)=$ftp->ls() || die "Cannot retrieve files from
> directory - ".$host_dir."\n".$ftp->message."\n";

Oh crap!

Let's read the docs together, shall we?

    ls ( [ DIR ] )

         Get a directory listing of DIR, or the current directory.

         In an array context, returns a list of lines returned from 
         the server. In a scalar context, returns a reference to a list.

Well, by typing my ($list) = $ftp->ls, you just put the ls call in list 
context. What do you think $list now holds?


>         $ftp_patt =~ s/\.\.\./.*/g if $ftp_patt;
>         $ftp_patt =~ s/\?/.?/g if $ftp_patt;
>         @$list = grep(/$ftp_patt/, @$list) if $ftp_patt;

Of course, you could write this for humans:

if ( $ftp_patt ) {
   $ftp_patt =~ s{\.\.\.}{.*}g;
   $ftp_patt =~ s{\?}{.?}g;
   ...
}

At this point, I have to wonder, why you didn't just type:

my @list = $ftp->ls
   or die "No files in $host_dir\n", $ftp->message, "\n";

>         foreach my $get (@$list) {

Again, the crucial question is, what is in $list?


I am getting really tired trying to read this spaghetti. Please make 
more of an effort when you post your third and final try.

Do read the guidelines, they really, really are helpful.

Sinan
-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html



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

Date: 7 Aug 2006 14:07:37 -0700
From: usenet@DavidFilmer.com
Subject: Re: Net FTP -- Size showing different results on AIX system and Linux system
Message-Id: <1154984857.335422.160840@m73g2000cwd.googlegroups.com>

fmbright wrote:
> Sorry All!!
>
> My bad....  here is the snipett of the problem.

Your bad again.  That's not a snippet.  That's over 100 lines, many of
which wrap.

I think you missed the point of the suggestion in the guidelines. Let's
review:

>> First make a short (less than 20-30 lines) and complete program that
>> illustrates the problem you are having. People should be able to run
>> your program by copy/pasting the code from your article. (You will
>> find that doing this step very often reveals your problem directly.

That doesn't mean cut-and-paste your entire program. That means pare
your program down into the smallest and simplest program which
demonstrates the problem.  That would not include dozens of lines of
debugging code or subroutines to do date and time manipulation (as
these are not relevant to your question).

There have been many times that I have considered posting a question to
usenet. In the process of preparing my question, I have rewritten my
code per the guidelines and, in doing so, have discovered the answer to
my own question.  I have found that this is a great debugging
technique.

Also, the CLPMisc guidelines first refer you to general guidelines
which are applicable to any technical group (namely
http://www.catb.org/~esr/faqs/smart-questions.html). Those guidelines
wisely suggest that you limit your linewidth.  Some newsreaders
(including your own 'reader', GoogleGroups) wrap long lines, which
impedes readability, and if cut-and-pasted into an editor, those would
come in as two different lines. It's wise to not exceed 70 columns
(that gives a few spare columns if someone wants to quote-back code
without it wrapping).

-- 
David Filmer (http://DavidFilmer.com)



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

Date: Mon, 07 Aug 2006 15:15:26 +0100
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Re: Perl hash of hash efficiency.
Message-Id: <272dnYzTvY1j10rZRVnygw@bt.com>

tak wrote:
>>>you are not in a
>>>position to say i wasted your time trying to guess what my issue was.
>>
>>How many responses did take the diagnose the issue? How many responses
>>would it have taken had you posted code in the first place? The difference
>>corresponds to wasted time because you did not take time to post enough
>>information.
> 
> 
> Mister, look at the replies list. when you replied for the first time -
> the issue was already resolved. That was what i was trying to explain
> to you. And the code that I posted AFTER you replied - was the original

<snip>

Tak,

If you are not already familiar with it, I think you will find it 
helpful to read this:
   http://www.catb.org/~esr/faqs/smart-questions.html
Especially
   http://www.catb.org/~esr/faqs/smart-questions.html#keepcool

I think it pays to read the posting guidelines for comp.lang.perl.misc 
that others have pointed out earlier in this discussion.
   http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html

When someone posts a clear example and quickly gets a clear solution 
then I might also benefit by learning something about the subject. When 
the newsgroup is filled with vagueness, misunderstandings and 
recriminations, we all lose.


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

Date: Mon, 07 Aug 2006 12:30:16 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Proc::Daemon and Sockets
Message-Id: <070820061230169865%jgibson@mail.arc.nasa.gov>

In article <1154911628.443030.162550@h48g2000cwc.googlegroups.com>,
<"shrike@cyberspace.org"> wrote:

> This is my error:
> 
> Listen failed: $! = Address already in use $@ = IO::Socket::INET:
> Address already in use.
> 
> At first I thought it was a userid problem so I did this:
> 
>         warn $> ; #
>         warn $< ; #
>         my $foo = IO::Socket::INET->new(Listen    => 1,
>                   LocalPort => $self->{'l'},
>                   Reuse => 1,
>                   Blocking => 0,
>                   Proto     => 'tcp')
>          || die "The socket will not listen." ;
> 
> And it seems to clear the failure. Why I have no clue. I'd rather not
> depend on that fix. Is there a way to more explicity clear the "Address
> already in use" problem ? I'm using the latest libs for everything
> except the core libraries with perl 5.8.7. 

Does the problem fix itself after a few minutes? IP addresses are kept
around for 2-4 minutes in case stray packets are still drifting around
the internet. Setting SO_REUSEADDR on the socket (after creation but
before binding) is supposed to disable that wait. The Reuse option
should cause that to happen. The documentation for my copy of
IO::Socket::INET (v. 1.27) says the Reuse is 'deprecated, use ReuseAddr
instead'. Maybe Reuse doesn't work any more.

What does netstat say about your socket after your program terminates?

-- 
Jim Gibson

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


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

Date: Mon, 7 Aug 2006 08:35:40 -0500
From: "AC" <clarke@n_o_s_p_a_m_hyperformix.com>
Subject: Re: Public/Private Data/Funcion in Perl OO?
Message-Id: <44d74141$0$1014$39cecf19@news.twtelecom.net>


<anno4000@radom.zrz.tu-berlin.de> wrote in message 
news:4jok7qF8spemU2@news.dfncis.de...
> Davy <zhushenli@gmail.com> wrote in comp.lang.perl.misc:
>> Hi all,
>>
>> I am a C++ programmer and new to Perl.
>> Is there some equal idea like Public/Private Data/Funcion in Perl OO?
>> I found the tutorial provided by Perldoc show all the Data is public??
>
> Right about methods (and subs in general).  There is only the convention
> to let the names of private methods begin with an underscore (_private).
> That doesn't stop anyone from using them, but at least they'll know they
> are doing something wrong.
>
> Data stored in lexical variables are inaccessible from outside their scope
> so they are truly private.  This is not true for package variables.
>
> Anno

You should check out Damian Conway'a "Perl Best Practices". It covers these 
issues exactly. You can use "inside out" objects to hide data and you can 
use anonymous code refs to achieve private methods. Its been a while since I 
read the book, so I'm not sure about how to get protected behavior.

Allan 




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

Date: 7 Aug 2006 13:52:51 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Public/Private Data/Funcion in Perl OO?
Message-Id: <4joutjF8q6t7U1@news.dfncis.de>

AC <clarke@n_o_s_p_a_m_hyperformix.com> wrote in comp.lang.perl.misc:
> 
> <anno4000@radom.zrz.tu-berlin.de> wrote in message 
> news:4jok7qF8spemU2@news.dfncis.de...
> > Davy <zhushenli@gmail.com> wrote in comp.lang.perl.misc:
> >> Hi all,
> >>
> >> I am a C++ programmer and new to Perl.
> >> Is there some equal idea like Public/Private Data/Funcion in Perl OO?
> >> I found the tutorial provided by Perldoc show all the Data is public??
> >
> > Right about methods (and subs in general).  There is only the convention
> > to let the names of private methods begin with an underscore (_private).
> > That doesn't stop anyone from using them, but at least they'll know they
> > are doing something wrong.
> >
> > Data stored in lexical variables are inaccessible from outside their scope
> > so they are truly private.  This is not true for package variables.
> >
> > Anno
> 
> You should check out Damian Conway'a "Perl Best Practices". It covers these 
> issues exactly. You can use "inside out" objects to hide data

Right.  There is no possible access to the data of an inside-out object,
except through the accessors you provide.

> and you can 
> use anonymous code refs to achieve private methods. Its been a while since I 
> read the book, so I'm not sure about how to get protected behavior.

I don't have the book to hand (don't books have a way of being where you
aren't?), but I don't see how anonymous code refs could ever participate
in inheritance.  For inheritance, methods *must* be named and can't be
strictly private.

Anno


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

Date: Mon, 07 Aug 2006 13:13:19 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Public/Private Data/Funcion in Perl OO?
Message-Id: <x764h4jwpc.fsf@mail.sysarch.com>

>>>>> "D" == Davy  <zhushenli@gmail.com> writes:

  D> I am a C++ programmer and new to Perl.

we know you are new to perl already so stop saying it.

and you should really read a good book on perl before you continue your
education via usenet. it will be much more efficient for both you and
us. learn.perl.org has a good free book and the perl docs are very good
too. read a bunch first before you continue posting again and you will
feel much better. :)

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Mon, 07 Aug 2006 12:42:23 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Simple file list in directory to array
Message-Id: <070820061242233485%jgibson@mail.arc.nasa.gov>

In article <pan.2006.08.07.06.01.09.594000@nospam.net>, darkmoo
<nospam@nospam.net> wrote:

> Thanks to all that have helped with my previous question.  
> 
> Now one more question. I've completely forgetten how to grab a list of all
> files in a directory and load it up into an array. 

In addition to the other, more recommended ways, there is always:

   my @array = `ls /my/directory`;

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


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

Date: Mon, 07 Aug 2006 12:34:09 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: skip path prune
Message-Id: <070820061234093867%jgibson@mail.arc.nasa.gov>

In article <eb3o0c$8hv$1@reader2.panix.com>, David Combs
<dkcombs@panix.com> wrote:

[advice against multi-posting snipped]

> Man, whenever *I* try that (crossposting), do I get flamed!

You were advised against 'multi-posting', not 'cross-posting'. Do you
know the difference?

> 
> Like it's some religious principle, "Thou shalt never crosspost".

No, most Usenauts would say 'Thou shalt never multi-post'.

> 
> I always thought crossposting was really useful, by
> enabling members of several newsgroups to communicate
> amongst each other on a given topic.

Yes, cross-posting can be useful in limited circumstances. Did anyone
tell you otherwise?

> 
> Especially when the groups are somewhat unrelated, perhaps
> perl and php and lisp, or engineering and physics.
> 
> Broadens the scope of idea-sources.

Please make sure you know the difference between multi-posting and
cross-posting, and why one is bad and the other is OK. OK?

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


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

Date: Mon, 07 Aug 2006 20:19:04 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: skip path prune
Message-Id: <Xns9818A6172F2ABasu1cornelledu@127.0.0.1>

Jim Gibson <jgibson@mail.arc.nasa.gov> wrote in
news:070820061234093867%jgibson@mail.arc.nasa.gov: 

> In article <eb3o0c$8hv$1@reader2.panix.com>, David Combs
> <dkcombs@panix.com> wrote:
> 
> [advice against multi-posting snipped]
> 
>> Man, whenever *I* try that (crossposting), do I get flamed!

 ...
 
> Please make sure you know the difference between multi-posting and
> cross-posting, and why one is bad and the other is OK. OK?

FYI, I am pretty sure David's post a humor piece.

Sinan
-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html


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

Date: 7 Aug 2006 13:06:55 -0700
From: "yusuf" <yusufm@gmail.com>
Subject: Test::Harness and test values.
Message-Id: <1154981214.962061.299710@p79g2000cwp.googlegroups.com>

Heres a file t.pl:

#!/usr/bin/perl



use Test::Harness;
$Test::Harness::Verbose=true;
$|=1;
print "before\n";



my $allok = runtests("tests.pl");






print  " all ok? :" . $allok ." \n";



print "total ran: ".$total;
print "\nfailed: ".$failed;

and the file tests.pl is:

#!/usr/bin/perl
  use Test::More tests => 1;



  ok( $foo eq $bar, 'foo is bar' );



  print "hello owlrd!";



  print STDERR "hello err";
  ok( $foo eq $bar, 'foo is bar2' );
1;

My problem is that in t.pl, the print "before" gets printed, but not
the other print statements after the runtests(). I want to be able to
determine after a test run, how many tests passed, failed and errored.
So I can log them to a server.

Thanks.



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

Date: Mon, 07 Aug 2006 20:31:14 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Test::Harness and test values.
Message-Id: <Xns9818A826DAFE3asu1cornelledu@127.0.0.1>

"yusuf" <yusufm@gmail.com> wrote in news:1154981214.962061.299710
@p79g2000cwp.googlegroups.com:

You really like crapping on us, don't ya?

> Heres a file t.pl:
> 
> #!/usr/bin/perl

use strict;
use warnings; 

missing.

> use Test::Harness;
> $Test::Harness::Verbose=true;
> $|=1;
> print "before\n";
> 
> my $allok = runtests("tests.pl");
>
> print  " all ok? :" . $allok ." \n";
> 
> print "total ran: ".$total;
> print "\nfailed: ".$failed;

Where did these magic variables $total and $failed come from?
 
> and the file tests.pl is:
> 
> #!/usr/bin/perl

use strict;
use warnings;

missing.

>   use Test::More tests => 1;
> 
>   ok( $foo eq $bar, 'foo is bar' );
>
>   print "hello owlrd!";
>
> 
> 
>   print STDERR "hello err";
>   ok( $foo eq $bar, 'foo is bar2' );
> 1;

Notice that you have planned only one test, yet there are two here.

> My problem is that ...

I really don't think it is acceptable to post code with obvious problems 
(the kind that would have been solved by following the posting 
guidelines). Bye.

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html



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

Date: Mon, 7 Aug 2006 15:04:13 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: What bless() do actually?
Message-Id: <eb7ku7.1co.1@news.isolution.nl>

Davy schreef:

> I found I have to bless($self) in new subroutine. If not do that,
> there is a error: "can't call method on unblessed methods".
>
> I guess if it is before bless($self), only private data pointer to
> $self; and after bless($self), method pointer to $self. Is it right?
> If not, please give me some intuitive explaination on bless, thanks!

Read chapter 11 of http://www.perl.org/books/beginning-perl

-- 
Affijn, Ruud

"Gewoon is een tijger."




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

Date: Mon, 7 Aug 2006 16:40:07 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: Zero'ing out an array
Message-Id: <slrneder77.sm8.dha@panix2.panix.com>

On 2006-08-07, Mumia W. <mumia.w.18.spam+nospam.usenet@earthlink.net> wrote:
> On 08/06/2006 10:04 PM, darkmoo wrote:
>> How does one do so?
>
> Unlike arrays in the C programming language, Perl arrays do 
> not need to be zero-ed out to clear them; just undefine the array:
>
> undef @myarray;

Unless by "Zero'ing out an array" you mean setting each element to 0 (as
noted in this thread), or have it hold an empty list.

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Despite his tendency to become sidetracked in debates with invisible
giraffes, he was an exemplary player, and rarely licked anyone without
prior permission    - Diablo on Shazam Twix 


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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