[25511] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7755 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 8 18:05:39 2005

Date: Tue, 8 Feb 2005 15:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 8 Feb 2005     Volume: 10 Number: 7755

Today's topics:
    Re: 'Subroutine redefined' annoyance (Anno Siegel)
    Re: A question on output of flip flop operator <tadmc@augustmail.com>
        back references <bogus@nowhere.net>
    Re: back references (Anno Siegel)
    Re: back references <jgibson@mail.arc.nasa.gov>
    Re: back references <abigail@abigail.nl>
    Re: Counting column delimiters per row in a text file hbar21@gmail.com
    Re: Counting column delimiters per row in a text file hbar21@gmail.com
    Re: Counting column delimiters per row in a text file <tadmc@augustmail.com>
    Re: Counting column delimiters per row in a text file <1usa@llenroc.ude.invalid>
    Re: Counting column delimiters per row in a text file <toreau@gmail.com>
    Re: Counting column delimiters per row in a text file hbar21@gmail.com
    Re: Counting column delimiters per row in a text file <1usa@llenroc.ude.invalid>
    Re: Exception handling in class: question <tassilo.von.parseval@rwth-aachen.de>
    Re: Exception handling in class: question (Anno Siegel)
    Re: Generate UUID (Anno Siegel)
        Getting a hash into a savable format <yyusenet@yahoo.com>
    Re: Net::SSH::Perl sending output to STDOUT ryanmhuc@yahoo.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 8 Feb 2005 20:51:48 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: 'Subroutine redefined' annoyance
Message-Id: <cub8p4$drb$1@mamenchi.zrz.TU-Berlin.DE>

bill  <please_post@nomail.edu> wrote in comp.lang.perl.misc:
> In <cu929g$1oi$1@mamenchi.zrz.TU-Berlin.DE>
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
> >bill  <please_post@nomail.edu> wrote in comp.lang.perl.misc:
> >> In <cu8kug$ljr$3@mamenchi.zrz.TU-Berlin.DE>
> >> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:

[...]

> >A module doing double-time as a script?
> 
> Yeah.  It's pretty common in the Python world, although the use
> I've typically seen for the "executable script code" in Python
> modules is devoted to tests of the module.
> 
> Frankly, I'm surprised it is not more common to see Perl modules
> that do double-duty as scripts.  It happens to me all the time that

Ready-to-run scripts aren't much distributed at all in the Perl world.
One alternative is for the module to offer a shell that is exported
by default.  CPAN is an example, but there are others. An interactive
session is started through "perl -MCPAN -e shell".  OTOH command-line
callable modules aren't unknown, my own Vi::QuickFix is an example.

> >Besides the obvious shebang line,
> >check caller() to see if you want to execute the "script code" (untested):
> 
> >    if ( caller ) {
> >        OddsAndEnds->import(); # parameters as needed
> >        require Getopt::STD; # for instance
> >        # more script code here
> >    }
> 
> I assume you meant "unless ( caller )"?

Yes, of course.  Sorry.

> >Stuff that only the
> >script needs should be require'd, not use'd.  Since imports in the
> >script happen at run time...
> 
> You'd also need explicit import statements, no?  (Or use
> package-qualified subs?)

I have written an import statement, but you can also compile the script in
the module package (just put the package-statement above the script).
If it is an exporting module, the script should probably call ->import,
if only for a crude test.

> >If you want the script first and the module later (I prefer it that way)
> 
> Just out of curiosity, is that preference a matter of aesthetics
> alone, or is there a functional rationale for putting the script
> before? (I think my preference was shaped by all the Python scripts
> I've seen with the "script code" at the end.)

The arrangement (script first, module later) has no functional advantage,
even a bit to the contrary.

I like to maintain a top-down direction in a source.  As a general rule,
that means writing first the calls to subs, then the definition of subs.
Ultimately, directly executable code goes first, hence the positioning
of the script.  Compilers like it the other way 'round and Perl punishes
you by forcing you to use parens with your sub calls, and problems with
prototypes and whatnot.  It's not an immutable rule.

The other way 'round you get a source that begins with the most low-level
auxiliaries until you get to see how they fit together.  I find that less
convenient.  I realize that "my" way, what you get to read first is parameter
passing and checking, but it does come to the point faster :)

Anno


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

Date: Tue, 8 Feb 2005 13:10:49 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: A question on output of flip flop operator
Message-Id: <slrnd0i3lp.19m.tadmc@magna.augustmail.com>

phaylon <phaylon@dunkelheit.at> wrote:
> Tad McClellan wrote:
> 
>> Why do you set X-No-Archive on your posts?
> 
> Because I forgot to take it out after copying another profile, thanks!


Cool, that will make it easier to see your posts.  :-)


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Tue, 8 Feb 2005 16:54:11 -0500
From: "REH" <bogus@nowhere.net>
Subject: back references
Message-Id: <cubce4$huf1@cui1.lmms.lmco.com>

How to a specify a back reference immediately followed by a number without
Perl thinking its part of the back reference?




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

Date: 8 Feb 2005 22:28:51 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: back references
Message-Id: <cubef3$drb$5@mamenchi.zrz.TU-Berlin.DE>

REH <bogus@nowhere.net> wrote in comp.lang.perl.misc:
> How to a specify a back reference immediately followed by a number without
> Perl thinking its part of the back reference?

One way:

    $_ = 'aba2';
    /(.).\1(?:2)/ and print "ok\n";

There are others...

Anno


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

Date: Tue, 08 Feb 2005 14:32:02 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: back references
Message-Id: <080220051432021454%jgibson@mail.arc.nasa.gov>

In article <cubce4$huf1@cui1.lmms.lmco.com>, REH <bogus@nowhere.net>
wrote:

> How to a specify a back reference immediately followed by a number without
> Perl thinking its part of the back reference?

I am guessing you mean backreferences within a regular expression, such
as the \1 in m/(.)\1/ to match any doubled character. (It would have
been nice to have posted a program demonstrating the problem.)

Surround the backreference in parentheses, either capturing or
non-capturing:

   m/(.)(\1)2/
or
   m/(.)(?:\1)2/

to match any doubled-character followed by a 2.


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---


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

Date: 08 Feb 2005 22:59:11 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: back references
Message-Id: <slrnd0ih1u.g2.abigail@alexandra.abigail.nl>

REH (bogus@nowhere.net) wrote on MMMMCLXXIX September MCMXCIII in
<URL:news:cubce4$huf1@cui1.lmms.lmco.com>:
!!  How to a specify a back reference immediately followed by a number without
!!  Perl thinking its part of the back reference?


In order of length, and more or less in order of my preference:


    /(.)\1[2]/

    /(.)\1 2/x

    /(.)\1\x32/

    /(.)\1{1}2/

    /(.)\1(?:2)/

    /(.)(?:\1)2/

    /(.)\1(?=)2/

    /(.)(??{$1})2/



Abigail
-- 
print v74.117.115.116.32;
print v97.110.111.116.104.101.114.32;
print v80.101.114.108.32;
print v72.97.99.107.101.114.10;


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

Date: 8 Feb 2005 11:03:55 -0800
From: hbar21@gmail.com
Subject: Re: Counting column delimiters per row in a text file
Message-Id: <1107889435.651395.17530@c13g2000cwb.googlegroups.com>


A. Sinan Unur wrote:
> "hbar" <hbar21@gmail.com> wrote in news:1107885124.542726.326620
> @l41g2000cwc.googlegroups.com:
>
> > Ok, so I've got this text file which is supposed to have 6 columns
per
> > row.
>
> ...
>
> > Can anyone either help me, or at least point me in the right
> > directions?
> 
> perldoc -q delimited
> 
> Sinan

Wow, that was easy.  Thanks!!!



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

Date: 8 Feb 2005 13:02:46 -0800
From: hbar21@gmail.com
Subject: Re: Counting column delimiters per row in a text file
Message-Id: <1107896566.817073.315850@o13g2000cwo.googlegroups.com>

Well, that seems to have got me about 98% of the way there.  Thanks.
However, I still have a problem.

#!/user/bin/perl

use Text::ParseWords;

my @fields;
my @data;

my $fldcnt = 15;
my $rownum = 0;
my $errCount = 0;

$file="test.txt";

open file or die "Cannot open $file for read:$!";

while(<file>)
{
    $rownum++;

    chomp;
    @fields = quotewords("~", 0, $_);

    if ($#fields != $fldcnt) {
        $errCount++;
        print "row $rownum is missing fields.\n";
        print "\n";
    }
    else {
        print "row $rownum is ok\n";
    }
}

print "There were $errCount total errors.\n";

close file;

__END__

Well, I thought I had the problem licked....but it seems that if a
tick, quote, or slash (I'm sure there are others, but that's all my
working test turned up) appears in a field, the script returns that row
as one that does not have the correct # of delimiters.  So I guess I
now have a new question.  How can I make it ignore what is between the
delimiters?

Thanks again.



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

Date: Tue, 8 Feb 2005 15:12:56 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Counting column delimiters per row in a text file
Message-Id: <slrnd0iaqo.1h0.tadmc@magna.augustmail.com>

hbar21@gmail.com <hbar21@gmail.com> wrote:
> A. Sinan Unur wrote:
>> "hbar" <hbar21@gmail.com> wrote in news:1107885124.542726.326620
>> @l41g2000cwc.googlegroups.com:

>> > Can anyone either help me, or at least point me in the right
>> > directions?
>> 
>> perldoc -q delimited


> Wow, that was easy.  Thanks!!!


That is exactly the point of compiling Frequently Asked Questions,
so that you can get the answer easily.

It all falls apart when folks do not have the courtesy to check
the FAQ before posting though.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Tue, 08 Feb 2005 21:40:48 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Counting column delimiters per row in a text file
Message-Id: <Xns95F7A9B955321asu1cornelledu@127.0.0.1>

hbar21@gmail.com wrote in news:1107896566.817073.315850
@o13g2000cwo.googlegroups.com:

> Well, that seems to have got me about 98% of the way there.  Thanks.
> However, I still have a problem.
> 
> #!/user/bin/perl
> 
> use Text::ParseWords;

I guess I should have been more obvious. I would have used Text::CSV_XS

Consider the word 'comma' in comma separated to be a placeholder for 
things like pipe, semi-colon, dash etc etc.

When you construct the object, specify what you want to be interpreted 
as quote and escape characters etc. Then parse (see the parse method) 
your input line by line, look at the number of fields. Record the line 
number if the number of fields does not match what you were expecting.

This can't be more than 20 lines or so including use strict and use 
warnings.

Post a sample of your data along with the code if you run into problems. 
Put the data in the __DATA__ section of your script.

As for your script:

use strict;
use warnings;

missing.

> my @fields;
> my @data;

No need to declare these variables in this scope.
 
> my $fldcnt = 15;

use constant EXPECTED_FIELDS => 15;

> my $rownum = 0;

Please see perldoc perlvar for the $. variable.

> my $errCount = 0;
> 
> $file="test.txt";

my $file = shift;
$file ||= 'test.txt';

> open file or die "Cannot open $file for read:$!";

Are you trying to take advantage of:

            If EXPR is omitted, the scalar variable of the same name as
            the FILEHANDLE contains the filename. (Note that lexical
            variables--those declared with "my"--will not work for this
            purpose; so if you're using "my", specify EXPR in your call 
            to open.)

I do have a feeling that this might be error prone, and I personally 
prefer:

open my $fh, '<', $file or die "Cannot open $file: $!";

> while(<file>)
> {
>     $rownum++;

You want to use $. here.

> 
>     chomp;
>     @fields = quotewords("~", 0, $_);
> 
>     if ($#fields != $fldcnt) {

@fields in scalar context would return the number of elements in 
@fields. That would be a more natural comparison. This also means the 
constant I defined above should have been 16 rather than 15. I am going 
to leave it that way, however. That is for you to fix.

Sinan.


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

Date: Tue, 08 Feb 2005 23:20:15 +0100
From: Tore Aursand <toreau@gmail.com>
Subject: Re: Counting column delimiters per row in a text file
Message-Id: <tWaOd.8093$IW4.190928@news2.e.nsc.no>

hbar21@gmail.com wrote:
> #!/user/bin/perl

Is the directory really called 'user'? I've never seen that one before. 
You're still missing these two, though;

   use strict;
   use warnings;

> use Text::ParseWords;

Don't use Text::ParseWords for this task. Instead, have a look at the 
excellent Text::CSV_XS module.

> my @fields;
> my @data;

Don't declare your variables before you actually use them!

> my $fldcnt = 15;

Constants should be declared as constants;

   use constant FIELDS_EXPECTED => 15;

> my $rownum = 0;

No need to; Perl keeps track of that for you in the $. variable.

> $file="test.txt";

No need to use double quotes here;

   my $file = 'test.txt';

> open file or die "Cannot open $file for read:$!";

Bad way of opening files, and I don't really think you want to do it. 
Please read 'perldoc -f open' for more information;

   open my $fh, '<', $file or die "$!\n";

> while(<file>)
> {
>     $rownum++;
> 
>     chomp;
>     @fields = quotewords("~", 0, $_);
> 
>     if ($#fields != $fldcnt) {
>         $errCount++;
>         print "row $rownum is missing fields.\n";
>         print "\n";
>     }
>     else {
>         print "row $rownum is ok\n";
>     }
> }

By using Text::CSV_XS, something like this should work;

   my $CSV = Text::CSV_XS->new();

   while ( <$fh> ) {
       my $status = $CSV->parse( $_ );
       my @fields = $CSV->fields();

       unless ( @fields == FIELDS_EXPECTED ) {
           $errCount++;
           print "Row $. is missing fields!\n";
       }
       else {
           print "Row $. is OK!\n";
       }
   }


-- 
Tore Aursand <tore@aursand.no>
"There are three kinds of lies: lies, damn lies, and statistics."
  (Benjamin Disraeli)


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

Date: 8 Feb 2005 14:39:33 -0800
From: hbar21@gmail.com
Subject: Re: Counting column delimiters per row in a text file
Message-Id: <1107902373.447820.234170@z14g2000cwz.googlegroups.com>

Wow.  This started as an excercise to get comfortable in perl.  I was
mostly learning from a few examples I found lying around here.  Clearly
not my best source of info.   Thanks for all your help, even those who
took the time out of their busy day to tell me to RTFFAQ.  I'll digest
this, and hopefully will not have to bother you any further.

Oh, one more question.  I checked the FAQ, but I still don't know where
to find full docs on the packages like CSV_XS, and all the methods,
etc.  Where can I find that stuff?

And /user/bin/perl is definitely a typo.  Odd that it still ran.

Thanks again.



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

Date: Tue, 08 Feb 2005 22:47:56 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Counting column delimiters per row in a text file
Message-Id: <Xns95F7B51BA7839asu1cornelledu@127.0.0.1>

hbar21@gmail.com wrote in news:1107902373.447820.234170
@z14g2000cwz.googlegroups.com:

> Wow.  This started as an excercise to get comfortable in perl.  I was
> mostly learning from a few examples I found lying around here.  Clearly
> not my best source of info.   Thanks for all your help, even those who
> took the time out of their busy day to tell me to RTFFAQ.  I'll digest
> this, and hopefully will not have to bother you any further.
> 
> Oh, one more question.  I checked the FAQ, but I still don't know where
> to find full docs on the packages like CSV_XS, and all the methods,
> etc.  Where can I find that stuff?

perldoc perldoc
perldoc perltoc
perldoc Text::CSV_XS

In case you are using ActiveState Perl on Windows, the documentation is 
also available in HTML format in the Start menu.

Finally, you are going to need to start quoting some context in your 
posts. See http://groups.google.com/googlegroups/posting_style.html

Sinan.


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

Date: Tue, 8 Feb 2005 21:41:17 +0100
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: Exception handling in class: question
Message-Id: <slrnd0i8vd.qs.tassilo.von.parseval@localhost.localdomain>

Also sprach mjl69:

>>     my @result = eval { $obj->meth };
>>     if ($@) {
>> 	die $@->msg;
>>     }
>> 
>> The advantage besides mimicking the exception handling seen in other
>> languages is that '$obj' does not need an additional '_error' slot. It's
>> always nice not to have to change the structure of existing code.
>> 
>> Tassilo
>
> I think I have a feeling for the overall problem here, but please
> correct me if I'm wrong. It seems that exception handling is a form of
> error handling and that's where the confusion comes up.  A class could
> be set up to generate error messages and put them somewhere, or, it
> could return undef or an error code (like 'system', which creates
> logic problems), or it could generate an exception which will
> propagate up until it is handled or not handled.

Right. And what exactly a method does when signalling errors is a matter
of documentation. Documentations are supposed to be read by those using
a library.

> In Java, exception handling is an integral part of the language.  In
> many cases, you are forced to handle exceptions, even if your handling
> involves just passing them along.  In a language like Perl, where
> there are so many different ways to do things and things are done in
> so many different ways, there is no real standard to error handling by
> all.  For example, if I do this:
>
> my @result = eval { $dbh->do($query) };
> if ($@) 
> {
>    die "DBI error: $dbh->errstring();
> }
>
> the die function will never be called because DBI objects do not throw
> exceptions.  Which leads back to my original question.  If I make my
> class fail-proof and it never fails, it may mess up someone else's
> error handling who wants to use my class.

Now, and that can only arise from not reading a class' documentation,
can't it? If I learn that a method/function might die under certain
circumstances, I certainly wrap it into a BLOCK-eval. If I learn that it
returns 'undef' on error, I check for undefinedness. Off the top of your
head, you can't know what means a method deploys to indicate failure. It
could be a false value, 'undef', it could die, it could even be -1. I
know of libraries whose constructors return an error string instead of a
blessed reference when something goes wrong. 

The upshot of all that: There is no canonical way of error-reporting in
Perl. Asking for one wont let it spring into existence.

Tassilo
-- 
use bigint;
$n=71423350343770280161397026330337371139054411854220053437565440;
$m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);


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

Date: 8 Feb 2005 21:13:38 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Exception handling in class: question
Message-Id: <cuba22$drb$2@mamenchi.zrz.TU-Berlin.DE>

Tassilo v. Parseval <tassilo.von.parseval@rwth-aachen.de> wrote in comp.lang.perl.misc:
> Also sprach Anno Siegel:
> > mjl69  <mjl69mjl69@myaccmyacc.net> wrote in comp.lang.perl.misc:

> >> {	
> >> 	push @{$invocant->{_error}}, now().
> >> 	'Record not found for: '.$querystring;
> >> 	return undef;
> >> }
> >
> > Just one point.  It is usually better to signal an error by returning
> > nothing instead of returning undef.  It's how *you* recognize the error,
> > the user should be able to do the same:
> >
> >     if ( my @result = $obj->meth( ...) ) {
> >         # use @result
> >     } else {
> >         my $msg = $obj->error;
> >         # deal with error
> >     }
> 
> When looking at this, I think that a BLOCK-eval wouldn't be that bad
> afterall.  What people like to forget is that die/croak's argument
> doesn't have to be a string. It may also be an object which will then be
> in $@.  So if 'meth' is this:
> 
>     package Class;
>     ...
>     sub meth {
> 	my $self = shift;
> 	...
> 	if (BAD_THING) {
> 	    croak Class::Exception->new(STRING);
> 	}
>     }
>     
>     package Class::Exception;
>     sub new { my ($class, $msg) = @_; bless \$msg => __PACKAGE__ }
>     sub msg { ${$_[0]} }
>     
> This could become:
> 
>     my @result = eval { $obj->meth };
>     if ($@) {
> 	die $@->msg;
>     }
> 
> The advantage besides mimicking the exception handling seen in other
> languages is that '$obj' does not need an additional '_error' slot. It's
> always nice not to have to change the structure of existing code.

Hmmm...  From this code I don't see the point in using an exception
object.  Wouldn't a plain string do?  I mean, if there were no
Class::Exception, and Class did

    if (BAD_THING) {
        croak STRING;
    }

and the client did

    my @result = eval { $obj->meth };
    if ($@) {
       die $@;
    }

what would be the difference?

Anno


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

Date: 8 Feb 2005 22:13:23 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Generate UUID
Message-Id: <cubdi3$drb$4@mamenchi.zrz.TU-Berlin.DE>

John Silver <SPAMMERSandante@DIEtotaliseALONE.co.uk> wrote in comp.lang.perl.misc:
> 
> "John Silver" <SPAMMERSandante@DIEtotaliseALONE.co.uk> wrote in message 
> news:nEIMd.147342$K7.74779@news-server.bigpond.net.au...
> >I need toi generate unique file names for a series of interface access 
> >processes.
> >
> > I have the code to perform this, using the  data::UUID  module.
> >
> > However, it fails on my machine, it seems that is missing from the 
> > package.
> >
> > Can someone point me at a pre compiled  UUID  module I can add to a Perl 
> > installation on Windows NT4?

Do a CPAN search for Data::UUID, follow the links to see if Activestate
supports it. (They do.)

Anno


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

Date: Tue, 08 Feb 2005 15:51:10 -0700
From: YYUsenet <yyusenet@yahoo.com>
Subject: Getting a hash into a savable format
Message-Id: <cubfp3$hr2$1@news.xmission.com>

I am rather new to Perl, so this may be a very easy to answer question. 
  I looked through the FAQ <perldoc -q hash> but it didn't give a direct 
way to do it.  Under the section "How do I process an entire hash?" it 
gave a way to go through the whole hash, which I could save each thing 
individually (maybe comma delimited).  But this seems to me to be a very 
unefficiant way to do it.  I was wondering if there was a way to get it 
saved to a file.  Trying "print %hash" gives me everything in the hash 
all bundled together, which I don't think will work.  Any help will be 
greatly appreciated.

Thanks,
YYusenet
-- 
yyusenet (at) yahoo (dot) com


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

Date: 8 Feb 2005 13:33:30 -0800
From: ryanmhuc@yahoo.com
Subject: Re: Net::SSH::Perl sending output to STDOUT
Message-Id: <1107898410.551026.241790@f14g2000cwb.googlegroups.com>

Thanks for the script but it does the same thing. If the password is
incorrect for the login i get:
"Permission denied at test.pl line 43"
and then it stops the program. The issue is I need to catch this. The
script I'm trying to create logins into about 16 different servers.
These servers passwords are not supposed to change but every once in a
while one does. I want the program to not die when it can't login to
the server but instead trap it, let me know and then continue with the
script.  ANYBODY?

Martin Kissner wrote:
> ryanmhuc@yahoo.com wrote :
> > I'm using Net::SSH::Perl to connect to remote server but when every
I
> > run commands it is sending output to STDOUT.
> >
> > $ssh = Net::SSH::Perl->new($ip);
> > $ssh->login($user, $pass);
> > ($out, $err, $ext) = $ssh->cmd("ls -l");
> >
> > So when I run the command instead of the the command output being
put
> > into $out it goes straight to STDOUT. Furthermore if the password
is
> > incorrect the $ssh->cmd stops my program.  Anyone know how to get
> > around this?
>
> I used this module, too.
> I only get an output after 'print $out'
>
> There is a good example script at
>
> 	http://search.cpan.org/src/DROLSKY/Net-SSH-Perl-1.25/eg/cmd.pl
>
> to start from.
>
> Don't forget to say
> 	debug => 0
> if you don't want to see the debug messages.
>
> HTH
> Martin
>
> --
> perl -e 'print
7.74.117.115.116.11.32.13.97.110.111.116.104.101.114.11
> .32.13.112.101.114.108.11.32.13.104.97.99.107.101.114.10.7'



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

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


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