How to skip all tests while using CPAN

2004-09-14 Thread Ramprasad A Padmanabhan
I am installing some perlmodules using CPAN on commandline. Since I am
doing this on multiple machines of the same architecture , I want to
avoid "make tests" in CPAN , how can I do this ? 

Thanks
Ram



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: declaring with my

2004-09-14 Thread John W. Krahn
Gunnar Hjalmarsson wrote:
John W. Krahn wrote:
Errin Larsen wrote:
my @numbers;
push @numbers, split while <>;

why can't I put that variable
declaration in the push function?  like this:
push my @numbers, split while <>;
The original code could be written as:
my @numbers;
while ( <> ) {
push @numbers, split;
}
Is that really identical to the original code as regards scoping?
No it isn't.
perldoc perlsyn
[snip]
NOTE: The behaviour of a "my" statement modified with a statement modifier
conditional or loop construct (e.g. "my $x if ...") is undefined.  The
value of the "my" variable may be "undef", any previously assigned value,
or possibly anything else.  Don't rely on it.  Future versions of perl
might do something different from the version of perl you try it out on.
Here be dragons.
If you declare @numbers inside the while loop it will only be seen 
inside the loop.
use warnings;
push my @numbers, split while <>;
my @numbers = (1,2,3);
generates the warning: ""my" variable @numbers masks earlier declaration 
in same scope at ...".
Yes, the first declaration is in the same scope as the second declaration 
however, as it says in perlsyn, the value could be anything.

Since this is a beginners list I didn't want to get into all the gory details 
but this issue has been discussed in comp.lang.perl.misc and the perl5-porters 
mailing list if you want more details.  :-)


John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



How to extract the exact URL

2004-09-14 Thread Franklin Zhang
Hello: 
 
Now, there are three kind of URL that I want to extract:
1.2
2.2abcd
2.3
 
I just want to extract the first URL which fits my condition, so I use:
if($line=~m/href="((?:[^"\\]|\\.)*)">2/)
But use this method the second also fit it.
How can I extact the first URL from the three ind of lines?
 
Thank you very much!
Franklin

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: declaring with my

2004-09-14 Thread Errin Larsen
> Because the push() statement is in a loop, and my() would empty
> the variable at each iteration.
> 
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl

Hi Gunnar ... Thanks for the help.

I assure the list, the following is the code EXACTLY as I was using it to test:
#!/usr/bin/perl

use warnings;
use strict;

my @numbers;
push @numbers, split while <>;
foreach (sort { $a <=> $b } @numbers) {
  printf "%20g\n", $_;
}

This works flawlessly, with no warnings or error messages.

I tried to modify the script, as seen below:

#!/usr/bin/perl

use warnings;
use strict;

push my @numbers, split while <>;
foreach (sort { $a <=> $b } @numbers) {
  printf "%20g\n", $_;
}

This code produces no output ... not even any warnings or errors.

Gunnar, I believe your explanation makes the most sense to me.  With
the my operator (function?) reseting the value of the @numbers
variable each time the loop is run, the output would not be in error,
it would just be empty.

So, now my question becomes, is there a way to watch this variable,
before, throughout and after the loop to confirm that it is being
reset each time.  More specifically, my problem now is, if the
variable is being reset throughout the loop, shouldn't the final
iteration of the loop have produced SOME output, albeit only the last
bits?  Maybe it has something to do with the precedence of the actual
line of code in the loop.  the:

  push my @numbers, split;

--Errin

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: First module

2004-09-14 Thread Randy W. Sims
On 9/14/2004 8:22 PM, Johnstone, Colin wrote:
Gidday all,
I have written a module to be used with our CMS 'Teamsite'
I wonder if any of you Perl gurus can see any holes in this.
It has methods to return the following
1) branch path
2) branch name
3) workarea
4) local path
any help appreciated thank you
Colin
given the following file path for example
/.iwmnt/default/main/det/oli-intranet.admin.tafe/WORKAREA/work/templatedata/Navigation/PrimaryMenu/data/primarymenu
#!/web/teamsite/iw-home/iw-perl/bin/iwperl
package detir::SystemData;
sub new
{
my ($proto, $dcrPath) = @_;
my $class = ref($proto) || $proto;
my $self = {};
( $self->{BR_PATH}, 
$self->{BR_NAME},
$self->{WA_NAME},
$self->{L_PATH}) = $self->getParts($dcrPath);
Does the above call actualy work? At this point $self is just a 
reference to a hash. You need to bless it before you can call methods on it.

bless $self, $class;
return $self;
}

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



First module

2004-09-14 Thread Johnstone, Colin
Gidday all,

I have written a module to be used with our CMS 'Teamsite'

I wonder if any of you Perl gurus can see any holes in this.

It has methods to return the following
1) branch path
2) branch name
3) workarea
4) local path
any help appreciated thank you
Colin

given the following file path for example

/.iwmnt/default/main/det/oli-intranet.admin.tafe/WORKAREA/work/templatedata/Navigation/PrimaryMenu/data/primarymenu

#!/web/teamsite/iw-home/iw-perl/bin/iwperl

package detir::SystemData;

sub new
{
my ($proto, $dcrPath) = @_;
my $class = ref($proto) || $proto;

my $self = {};

( $self->{BR_PATH}, 
$self->{BR_NAME},
$self->{WA_NAME},
$self->{L_PATH}) = $self->getParts($dcrPath);

bless $self, $class;

return $self;
}

sub getParts
{

my ( $self, $dcrPath ) = @_;

$dcrPath =~ s!(^.*)/(.*)/WORKAREA/(.*?)/(.*$)!!;

return ($1, $2, $3, $4);

}

sub getBranchPath
{
my ( $self ) = @_; 
return $self->{BR_PATH};
}

sub getBranchName{
my ( $self ) = @_; 
return $self->{BR_NAME};
}

sub getWorkareaName{
my ( $self ) = @_;
return $self->{WA_NAME};
}

sub getLocalPath{
my ( $self ) = @_;
return $self->{L_PATH};
}

return 1;




This E-Mail is intended only for the addressee. Its use is limited to that
intended by the author at the time and it is not to be distributed without the
author's consent. Unless otherwise stated, the State of Queensland accepts no
liability for the contents of this E-Mail except where subsequently confirmed in
writing. The opinions expressed in this E-Mail are those of the author and do
not necessarily represent the views of the State of Queensland. This E-Mail is
confidential and may be subject to a claim of legal privilege.

If you have received this E-Mail in error, please notify the author and delete this 
message immediately.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: declaring with my

2004-09-14 Thread Gunnar Hjalmarsson
John W. Krahn wrote:
Errin Larsen wrote:
my @numbers;
push @numbers, split while <>;

why can't I put that variable
declaration in the push function?  like this:
push my @numbers, split while <>;
The original code could be written as:
my @numbers;
while ( <> ) {
push @numbers, split;
}
Is that really identical to the original code as regards scoping?
If you declare @numbers inside the while loop it will only be seen 
inside the loop.
use warnings;
push my @numbers, split while <>;
my @numbers = (1,2,3);
generates the warning: ""my" variable @numbers masks earlier 
declaration in same scope at ...".

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: declaring with my

2004-09-14 Thread John W. Krahn
Errin Larsen wrote:
Hi all, straight out of the Learning Perl book (3rd edition, page 275)
is this code:
my @numbers;
push @numbers, split while <>;
foreach (sort { $a <=> $b } @numbers) {
   printf "%20g\n", $_;
}
This works flawlessly.  My question is why can't I put that variable
declaration in the push function?  like this:
push my @numbers, split while <>;
foreach (sort { $a <=> $b } @numbers) {
   printf "%20g\n", $_;
}
When I run this code, nothing is output.  It seems I see this kind of
variable-declaration-in-a-function all the time.  Why is it not
working here?
The original code could be written as:
my @numbers;
while ( <> ) {
push @numbers, split;
}
If you declare @numbers inside the while loop it will only be seen inside the 
loop.  What you want is this:

my @numbers = map split, <>;
Although that has to read the entire file first in order to process it while 
the while loop only reads one line at a time.


John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: declaring with my

2004-09-14 Thread Gunnar Hjalmarsson
Errin Larsen wrote:
Hi all, straight out of the Learning Perl book (3rd edition, page
275) is this code:
my @numbers;
push @numbers, split while <>;
foreach (sort { $a <=> $b } @numbers) {
   printf "%20g\n", $_;
}
This works flawlessly.  My question is why can't I put that
variable declaration in the push function?  like this:
push my @numbers, split while <>;
foreach (sort { $a <=> $b } @numbers) {
   printf "%20g\n", $_;
}
Because the push() statement is in a loop, and my() would empty
the variable at each iteration.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: output to one changing line

2004-09-14 Thread JupiterHost.Net

Chris Devers wrote:
On Tue, 14 Sep 2004, JupiterHost.Net wrote:

I'd like the line to change as it runs, sort of an animated delivery:

I've seen a Damian Conway presentation where he faked out this behavior 
by prefixing all output with enough backspace ("\h") characters to wipe 
out the previous output and display a new line. 
Sneaky :) I can't even seem to fake it:
$ perl -mstrict -we 'my @l = qw(abc 123 dfg);for(@l) { print "\h\h\h$_"; 
}print "\n";'
Unrecognized escape \h passed through at -e line 1.
Unrecognized escape \h passed through at -e line 1.
Unrecognized escape \h passed through at -e line 1.
hhhabchhh123hhhdfg
$

\h doesn't seem to act like \n does...
The "right" way to do this may be one of the Term::* modules, but this 
approach worked well enough to fool a room full of Perl mongers into 
thinking he was doing something much more clever than he really was...
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: output to one changing line

2004-09-14 Thread Chris Devers
On Tue, 14 Sep 2004, JupiterHost.Net wrote:

> I'd like the line to change as it runs, sort of an animated delivery:

I've seen a Damian Conway presentation where he faked out this behavior 
by prefixing all output with enough backspace ("\h") characters to wipe 
out the previous output and display a new line. 

The "right" way to do this may be one of the Term::* modules, but this 
approach worked well enough to fool a room full of Perl mongers into 
thinking he was doing something much more clever than he really was...




-- 
Chris Devers

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




declaring with my

2004-09-14 Thread Errin Larsen
Hi all, straight out of the Learning Perl book (3rd edition, page 275)
is this code:

my @numbers;
push @numbers, split while <>;
foreach (sort { $a <=> $b } @numbers) {
   printf "%20g\n", $_;
}

This works flawlessly.  My question is why can't I put that variable
declaration in the push function?  like this:

push my @numbers, split while <>;
foreach (sort { $a <=> $b } @numbers) {
   printf "%20g\n", $_;
}

When I run this code, nothing is output.  It seems I see this kind of
variable-declaration-in-a-function all the time.  Why is it not
working here?

--Errin

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




output to one changing line

2004-09-14 Thread JupiterHost.Net
Hello list,
I've seen this done, but am not sure what its called or where to start 
looking...

Instead of the output of a script via CLI being:
# perl script.pl
line1
line2
line3
etc
#
I'd like the line to change as it runs, sort of an animated delivery:
As soon as its run it'd look like this:
# perl script.pl
line1
and then change to this:
# perl script.pl
line2
and then change to this:
# perl script.pl
line3
And end up like this:
# perl script.pl
ect
#
Does that make sense :) ??
TIA
Lee.M - JupiterHost.Net
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: String to Numeric of an Array

2004-09-14 Thread Gunnar Hjalmarsson
Charles K. Clarkson wrote:
Edward WIJAYA <[EMAIL PROTECTED]> wrote:
I am terribly sorry to have asked such a trivial question.
Never be sorry for asking questions. Trivial or complex. We answer
questions. If you feel intimidated to ask future questions then we
have failed.
Even if I see nothing wrong with Edward's question in this thread,
please allow me to partly disagree. "Questions" that actually are
requests that somebody writes a script based on a specification should
indeed be discouraged. The questioners should be expected to make own
efforts before posting to the list.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RE: bundle install fails

2004-09-14 Thread u235sentinel
Looks ok to me.

What you are probably seeing are the tests usually associated with the CPAN install.  
It may also find a new version the CPAN.pm module and upgrade it on the fly.  It does 
that every now and then. 

I didn't see anything to worry about.  Looks like the 'make install' worked just fine. 
 You might want to go ahead and create some test programs to make sure it's working.  
Otherwise you should be good to go.



> >Sorry for the newbie question, but from where and how do I install the
> >Convert::BinHex code and build it?
> >  
> >
> No worries.  I usually go to cpan.org.
> 
> Here is the direct link to the info page. Lots of good details on how it 
> works.
> 
> http://search.cpan.org/~eryq/Convert-BinHex-1.119/lib/Convert/BinHex.pm
> 
> Here is where you can download the source
> 
> http://search.cpan.org/CPAN/authors/id/E/ER/ERYQ/Convert-BinHex-1.119.tar.gz
> 
> 
> ~~~
> Hello,
> 
> Thanks for all the help and info. After downloading the tarball I ran, 'perl
> Makefile.PL', and 'make', then 'make install', but I am not sure if this is
> all I need to do. When running the install from CPAN so much more seems to
> take place (as far as the verbose output on the terminal shows). Below is
> the output from tarball build. Is this everything for an install or am I
> missing something? 
> 
> Thanks again for your help.
> 
> [EMAIL PROTECTED] Convert-BinHex-1.119]# perl Makefile.PL
> Checking if your kit is complete...
> Looks good
> Writing Makefile for Convert::BinHex
> [EMAIL PROTECTED] Convert-BinHex-1.119]# ls
> bin/  COPYING  docs/  lib/  Makefile  Makefile.PL*  MANIFEST  README
> README-TOO  t/  test/  testin/  testout/
> [EMAIL PROTECTED] Convert-BinHex-1.119]# make
> cp lib/Convert/BinHex.pm blib/lib/Convert/BinHex.pm
> Manifying blib/man3/Convert::BinHex.3pm
> [EMAIL PROTECTED] Convert-BinHex-1.119]# ls
> bin/  blib/  blibdirs  COPYING  docs/  lib/  Makefile  Makefile.PL*
> MANIFEST  pm_to_blib  README  README-TOO  t/  test/  testin/  testout/
> [EMAIL PROTECTED] Convert-BinHex-1.119]# make install
> Installing /usr/lib/perl5/site_perl/5.8.3/Convert/BinHex.pm
> Installing /usr/share/man/man3/Convert::BinHex.3pm
> Writing
> /usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi/auto/Convert/BinHex/.
> packlist
> Appending installation info to
> /usr/lib/perl5/5.8.3/i386-linux-thread-multi/perllocal.pod
> 
> ~~~
> ~James 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
> 
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: bundle install fails

2004-09-14 Thread James D. Parra
>Sorry for the newbie question, but from where and how do I install the
>Convert::BinHex code and build it?
>  
>
No worries.  I usually go to cpan.org.

Here is the direct link to the info page. Lots of good details on how it 
works.

http://search.cpan.org/~eryq/Convert-BinHex-1.119/lib/Convert/BinHex.pm

Here is where you can download the source

http://search.cpan.org/CPAN/authors/id/E/ER/ERYQ/Convert-BinHex-1.119.tar.gz


~~~
Hello,

Thanks for all the help and info. After downloading the tarball I ran, 'perl
Makefile.PL', and 'make', then 'make install', but I am not sure if this is
all I need to do. When running the install from CPAN so much more seems to
take place (as far as the verbose output on the terminal shows). Below is
the output from tarball build. Is this everything for an install or am I
missing something? 

Thanks again for your help.

[EMAIL PROTECTED] Convert-BinHex-1.119]# perl Makefile.PL
Checking if your kit is complete...
Looks good
Writing Makefile for Convert::BinHex
[EMAIL PROTECTED] Convert-BinHex-1.119]# ls
bin/  COPYING  docs/  lib/  Makefile  Makefile.PL*  MANIFEST  README
README-TOO  t/  test/  testin/  testout/
[EMAIL PROTECTED] Convert-BinHex-1.119]# make
cp lib/Convert/BinHex.pm blib/lib/Convert/BinHex.pm
Manifying blib/man3/Convert::BinHex.3pm
[EMAIL PROTECTED] Convert-BinHex-1.119]# ls
bin/  blib/  blibdirs  COPYING  docs/  lib/  Makefile  Makefile.PL*
MANIFEST  pm_to_blib  README  README-TOO  t/  test/  testin/  testout/
[EMAIL PROTECTED] Convert-BinHex-1.119]# make install
Installing /usr/lib/perl5/site_perl/5.8.3/Convert/BinHex.pm
Installing /usr/share/man/man3/Convert::BinHex.3pm
Writing
/usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi/auto/Convert/BinHex/.
packlist
Appending installation info to
/usr/lib/perl5/5.8.3/i386-linux-thread-multi/perllocal.pod

~~~
~James 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: String to Numeric of an Array

2004-09-14 Thread Charles K. Clarkson
Edward WIJAYA <[EMAIL PROTECTED]> wrote:

: 
: I am terribly sorry to have asked such a trivial
: question.


Never be sorry for asking questions. Trivial or
complex. We answer questions. If you feel intimidated
to ask future questions then we have failed.


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: String to Numeric of an Array

2004-09-14 Thread Edward WIJAYA

If you treat the elements of the array as numbers,
won't things Just Work ?

Thanks a lot for the reply.
The reason I asked this because, in one
of my regex operation I doubted that the
results are correct. Turns out that I am wrong :(
I guess I am still living in C-world.
I am terribly sorry to have asked
such a trivial question.
Regards,
Edward WIJAYA
SINGAPORE

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: net::ssh & expect

2004-09-14 Thread Wiggins d Anconia
> On Tue, 14 Sep 2004 07:36:38 -0600, Wiggins d Anconia
> <[EMAIL PROTECTED]> wrote:
> > > I have a script that I use to ssh to a list of servers to run a few
> > > commands. I'm trying to find a way su up & run a command - however I'm
> > > in need of some inspiration as to how to pull this off.
> > >
> > 
> > Have you considered 'sudo' instead?  It would make this task much
> > easier, would eliminate the need to handle passwords and would provide
> > further security by limiting the command that can be run.  I would look
> > into using it first, if you can't let us know and we might be able to
> > come up with something.
> > 
> 
> I don't have complete control over the remote server, so I am limited
> in some ways. 

Ironically you do, but I take your meaning.

Theres no sudo available, however wouldn't this require
> an interactive response anyway ?.

Not if configured properly. You can tell sudo to accept a command from a
particular user without requiring the password be provided, I do this so
that I can access a root shell with 'sudo bash' on my personal machines.

 I've considered a few options from
> stuid to hostkeys & I really want to run this interactively to some
> extent. At the moment I do something like:-
> $for N in 2 - 8; do ssh mta0${N}.fqdn; done & su -
> /usr/local/bin/run_cmd at each server. I have to watch the output, to
> ensure theres no mishaps and don't want to put too much logic into
> this script.
> 

Fair enough, just wanted to make sure the option had been explored.  In
general you are going to have to handle the data at a lower level,
N::S::P allows you to do so by registering handlers, which will then
invoke functions depending on the data received.  I would suggest using
SSH2 for all of this, and then checking out the two example scripts
provided in the distribution, they can be seen online at:

http://search.cpan.org/src/DROLSKY/Net-SSH-Perl-1.25/eg/

They are almost identical for running 'su -' instead of 'passwd', though
you may need one extra level of indirection since you are running a
command in a command.  See if the example scripts help, if you are still
missing something, post back

http://danconia.org

> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
> 
> 
> 



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: String to Numeric of an Array

2004-09-14 Thread David Greenberg
In a few circumstances, such as binding parameters to a database, you
may need to do this, but on the whole, as everyone else has pointed
out, Perl will do this for you.

If you are using this for one of those few cases, you can change them
explicitly like this:
@array = ('1','2','3');
@arrayNum = map { $_ + 0 } (@array);

This maps every value in @array to its numeric equivalent because it
is used in an addition operation.  The values are pushed into
@arrayNum for later use.

This is a hack, so only use it if you need to.  In most cases, just
let Perl do it for you.

-David


On Tue, 14 Sep 2004 11:02:13 -0300, Shaw, Matthew <[EMAIL PROTECTED]> wrote:
> Edward:
> 
> What you have there is an array with only one scalar element (an array
> reference containing 3 values). Note that $array[1] & $array[2] would be
> undefined in your example. I think what you intended was to do:
> 
> @array = ('1','2','3'); # An array containing three elements, '1', '2',
> '3'
> (Or more simply: @array = (1..3); )
> 
> With regards to switching between string & numeric values, perl will do
> this automagically for you. You can just perform whatever math you want
> as per normal. Consider the following:
> 
> @array = ( '1', '2', '3');
> print $array[0] + 1;
> 
> Output: 2
> 
> Hope this helps.
> 
> Matt Shaw
> http://www.thinktechnology.ca/
> 
> > -Original Message-
> > From: Edward WIJAYA [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, September 14, 2004 10:12 PM
> > To: [EMAIL PROTECTED]
> > Subject: String to Numeric of an Array
> >
> > Hi,
> >
> > How can I change the value of this array:
> >
> > @array = ['1','2','3']; #which contain "string" numeric
> >
> > to
> >
> > @arrayNum = [1,2,3];  #as pure numeric
> > 
> > Regards,
> > Edward WIJAY
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >  
> >
> 
> 
> 
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
> 
>

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: net::ssh & expect

2004-09-14 Thread john smith
On Tue, 14 Sep 2004 07:36:38 -0600, Wiggins d Anconia
<[EMAIL PROTECTED]> wrote:
> > I have a script that I use to ssh to a list of servers to run a few
> > commands. I'm trying to find a way su up & run a command - however I'm
> > in need of some inspiration as to how to pull this off.
> >
> 
> Have you considered 'sudo' instead?  It would make this task much
> easier, would eliminate the need to handle passwords and would provide
> further security by limiting the command that can be run.  I would look
> into using it first, if you can't let us know and we might be able to
> come up with something.
> 

I don't have complete control over the remote server, so I am limited
in some ways. Theres no sudo available, however wouldn't this require
an interactive response anyway ?. I've considered a few options from
stuid to hostkeys & I really want to run this interactively to some
extent. At the moment I do something like:-
$for N in 2 - 8; do ssh mta0${N}.fqdn; done & su -
/usr/local/bin/run_cmd at each server. I have to watch the output, to
ensure theres no mishaps and don't want to put too much logic into
this script.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: String to Numeric of an Array

2004-09-14 Thread Shaw, Matthew
Edward:

What you have there is an array with only one scalar element (an array
reference containing 3 values). Note that $array[1] & $array[2] would be
undefined in your example. I think what you intended was to do:

@array = ('1','2','3'); # An array containing three elements, '1', '2',
'3'
(Or more simply: @array = (1..3); )

With regards to switching between string & numeric values, perl will do
this automagically for you. You can just perform whatever math you want
as per normal. Consider the following:

@array = ( '1', '2', '3');
print $array[0] + 1;

Output: 2

Hope this helps.

Matt Shaw
http://www.thinktechnology.ca/

> -Original Message-
> From: Edward WIJAYA [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, September 14, 2004 10:12 PM
> To: [EMAIL PROTECTED]
> Subject: String to Numeric of an Array
> 
> Hi,
> 
> How can I change the value of this array:
> 
> @array = ['1','2','3']; #which contain "string" numeric
> 
> to
> 
> @arrayNum = [1,2,3];  #as pure numeric
> 
> Regards,
> Edward WIJAY
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
> 


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: split function

2004-09-14 Thread John W. Krahn
c r wrote:
Hi!
Hello,
Can the perl split function split a random 40 character string into five 8 character strings?
No.
With random I mean that there is no special pattern in the 40 character string that can be used as split markers.
You should probably use a match operator.
my @strings = $string =~ /.{1,8}/sg;
Of course you could use substr or unpack as well.
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: String to Numeric of an Array

2004-09-14 Thread Chris Devers
On Wed, 15 Sep 2004, Edward WIJAYA wrote:

> How can I change the value of this array:
> 
> @array = ['1','2','3']; #which contain "string" numeric
> 
> to
> 
> @arrayNum = [1,2,3];  #as pure numeric
 
Does this even need to be done?

If you treat the elements of the array as numbers,
won't things Just Work ? 


-- 
Chris Devers

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: split function

2004-09-14 Thread Jim
 
> Can the perl split function split a random 40 character 
> string into five 8 character strings?
>  
> With random I mean that there is no special pattern in the 40 
> character string that can be used as split markers.

How about unpack?

@eights = unpack("A8" x (length($string)/8), $string);

Thanks
Jim

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.745 / Virus Database: 497 - Release Date: 8/27/2004
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: String to Numeric of an Array

2004-09-14 Thread John W. Krahn
Edward WIJAYA wrote:
Hi,
Hello,
How can I change the value of this array:
@array = ['1','2','3']; #which contain "string" numeric
to
@arrayNum = [1,2,3];  #as pure numeric
As far as perl is concerned they are the same.  If you use a string in numeric 
context it becomes a number and if you use a number in string context it 
becomes a string.

John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: split function

2004-09-14 Thread Chris Devers
On Tue, 14 Sep 2004, c r wrote:

> Can the perl split function split a random 40 character string into 
> five 8 character strings?
>
> With random I mean that there is no special pattern in the 40 
> character string that can be used as split markers.

Wouldn't substr make more sense, or a regex?

$ cat ~/bin/test.pl
#!/usr/bin/perl -w

use strict;

my $string = qq[a2345678b2345678c2345678d2345678e2345678];

my ($a,$b,$c,$d,$e) = $string =~ m/(.{8})(.{8})(.{8})(.{8})(.{8})/;

print qq[
\$string = $string

\$a = $a
\$b = $b
\$c = $c
\$d = $d
\$e = $e

];

$ perl ~/bin/test.pl

$string = a2345678b2345678c2345678d2345678e2345678

$a = a2345678
$b = b2345678
$c = c2345678
$d = d2345678
$e = e2345678

$


This seems to be what you want, right ?


-- 
Chris Devers

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: split function

2004-09-14 Thread Gunnar Hjalmarsson
C r wrote:
Can the perl split function split a random 40 character string into
five 8 character strings?
With random I mean that there is no special pattern in the 40
character string that can be used as split markers.
Don't know, but in any case the m// operator is a better way to do that:
my @parts = $string =~ /.{8}/g;
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: split function

2004-09-14 Thread Wiggins d Anconia
> 
> Hi!
>  
> Can the perl split function split a random 40 character string into
five 8 character strings?
>  
> With random I mean that there is no special pattern in the 40
character string that can be used as split markers.
> 

This smells like homework?  (just a reminder to the gurus, it is that
time of the year again)...

perldoc -f split
perldoc -f substr
perldoc -f unpack

Just one way


#!/usr/local/bin/perl

use strict;
use warnings;

my $long_string = "01234567" x 5;
my @strings = unpack('A8' x 5, $long_string);
print join(',', @strings) . "\n";

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: String to Numeric of an Array

2004-09-14 Thread Gunnar Hjalmarsson
Edward WIJAYA wrote:
How can I change the value of this array:
@array = ['1','2','3']; #which contain "string" numeric
to
@arrayNum = [1,2,3];  #as pure numeric
Why would you need that?
my $string = '5';
my $number = 5;
print "Equal\n" if $string == $number;
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: net::ssh & expect

2004-09-14 Thread Wiggins d Anconia
> I have a script that I use to ssh to a list of servers to run a few
> commands. I'm trying to find a way su up & run a command - however I'm
> in need of some inspiration as to how to pull this off.
>

Have you considered 'sudo' instead?  It would make this task much
easier, would eliminate the need to handle passwords and would provide
further security by limiting the command that can be run.  I would look
into using it first, if you can't let us know and we might be able to
come up with something.

http://danconia.org
 
> Heres the script template for reference:-
> 
> #!/usr/bin/perl -w
> 
> use strict;
> use Term::ReadKey;
> use  Net::SSH::Perl;
> 
> my $cmd1 = 'uname -a';
> 
> # Get user/pass for session
> print "Enter your username for this session: ";
> chomp(my $user = );
> print "And your password: ";
> ReadMode('noecho');
> chomp(my $passwd = ReadLine(0));
> ReadMode('restore');
> print "\n";
> 
> while (  ) {
>chomp $_;
>my $host = $_;
>my $ssh = Net::SSH::Perl->new($_, 2,1);
>$ssh->login($user, $passwd);
>my($stdout, $stderr, $exit) = $ssh->cmd($cmd1);
>
>
> 
>my $out = $stdout;
>print "$out\n";
> }
> __DATA__
> host1
> host2
> host3
> 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




String to Numeric of an Array

2004-09-14 Thread Edward WIJAYA
Hi,
How can I change the value of this array:
@array = ['1','2','3']; #which contain "string" numeric
to
@arrayNum = [1,2,3];  #as pure numeric
Regards,
Edward WIJAY
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



split function

2004-09-14 Thread c r
Hi!
 
Can the perl split function split a random 40 character string into five 8 character 
strings?
 
With random I mean that there is no special pattern in the 40 character string that 
can be used as split markers.


Yahoo! Mail - Gratis: 6 MB lagerplads, spamfilter og virusscan

Problem with ssh and STDIN

2004-09-14 Thread Ohad Ohad
I encounter a weird problem.
When I try to execute : system( ssh -x server_name command)
It seems to close my STDIN
Any idea why that happens and how can I solve it?
_
Tired of spam? Get advanced junk mail protection with MSN 8. 
http://join.msn.com/?page=features/junkmail

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RE: Regex help

2004-09-14 Thread Jim
  
> So in short the regex must remove any characters from the 
> anchor text e.g the & in 'News & events'
> and any spaces, basically any characters that cannot be used 
> in a filename if they have been inadvertently entered by the users.

What kind of file names? DOS, UNIX, Other? 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.745 / Virus Database: 497 - Release Date: 8/27/2004
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




net::ssh & expect

2004-09-14 Thread john smith
I have a script that I use to ssh to a list of servers to run a few
commands. I'm trying to find a way su up & run a command - however I'm
in need of some inspiration as to how to pull this off.

Heres the script template for reference:-

#!/usr/bin/perl -w

use strict;
use Term::ReadKey;
use  Net::SSH::Perl;

my $cmd1 = 'uname -a';

# Get user/pass for session
print "Enter your username for this session: ";
chomp(my $user = );
print "And your password: ";
ReadMode('noecho');
chomp(my $passwd = ReadLine(0));
ReadMode('restore');
print "\n";

while (  ) {
   chomp $_;
   my $host = $_;
   my $ssh = Net::SSH::Perl->new($_, 2,1);
   $ssh->login($user, $passwd);
   my($stdout, $stderr, $exit) = $ssh->cmd($cmd1);
   
   

   my $out = $stdout;
   print "$out\n";
}
__DATA__
host1
host2
host3

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Regex help

2004-09-14 Thread Chris Devers
On Tue, 14 Sep 2004, Johnstone, Colin wrote:

> I found this regex by searching on google and I assumed the guy who 
> wrote it knew more than me.

>From the look of this regex, that ain't necessarily so.

The thing with regular expressions is that they tend to be crafted for 
very specific purposes, and unless this guy was trying to solve the 
exact same problem you are, the regex he wrote may not do what you need.
 
> I guess I was looking for a general purpose regex to remove invalid 
> characters from filenames to add to my developers toolkit to take from 
> project to project.

Shouldn't a toolkit consist of things you actually understand. 

It's like the old "give a man a fish" saying -- if as a result of this 
discussion you come away with a regex that solves this specific problem 
today, then you will be able to eat today. If on the other hand you 
start learning how regular expressions work, you'll be able to write 
your own ones and won't have to rely on questionable canned examples.
 
> Specifically for this project I would like to remove spaces and 
> ampersands apostrophes, quotes should users enter them.

That's nice.

As others asked you, what would you like to *keep* ? 

This regular expression can be much more simply expressed in terms of 
matching everything other than that which you know you want. You 
probably want letters, digits, and maybe some punctuation, right? Try to 
list all the characters that are valid in filenames on all the platforms 
that Teamsite currently or could potentially run on, and then you'll be 
most of the way to the regex you want. 


Also, if you just want to strip out bad characters a substitution regex 
(one with s/.../.../ syntax) may be much more complicated than a simple 
tr/...// statement. Have you tried doing it that way ?



-- 
Chris Devers

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Regex help

2004-09-14 Thread Jenda Krynicky
From: "Johnstone, Colin" <[EMAIL PROTECTED]>
> rather than re-invent the wheel I would prefer if you could fix this
> regex I believe it covers all invalid characters one would encounter
> 
> s/[\w\&%'[EMAIL PROTECTED](\)&_\\+,\.=\[\]]//g;
> 
> I would then use it as a general purpose regex for validating
> filenames.

Never ever "remove invalid characters". Always "remove everything 
except the safe characters". What if someone sends you a newline? Or 
a character with code 0? Or ...

Your regexp makes very little sense. You definitely should go read 
perlretut or something. The [] denotes a character class, there is no 
difference whatsoever between [] and [<>ups]!

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Regex help

2004-09-14 Thread Gunnar Hjalmarsson
[ Please type your reply below the quoted part of the message you
reply to. ]
Colin Johnstone wrote:
Jim wrote:
Colin Johnstone wrote:
I firstly need to remove any invalid characters (including
spaces)
$filename = 'News & events';
$filename =~
s/[\w\&%'[EMAIL PROTECTED](\)&_\\+,\.=\[\]]//g;
then convert it to lowercase.
$filename =~ s/[^A-Za-z]//g; #use only alpha chars
print lc($filename); # convert to lower case
# or if you want to strip out non printing (control) chars:
$filename = " News \r \n \x01 even ts";
$filename =~ s/[[:cntrl:]]//g;
$filename =~ s/\s//g;
rather than re-invent the wheel I would prefer if you could fix
this regex I believe it covers all invalid characters one would
encounter
s/[\w\&%'[EMAIL PROTECTED](\)&_\\+,\.=\[\]]//g;
In this case, re-inventing the wheel, as you put it, is much more
convenient than using that regex as the starting-point for solving
your problem.
I would then use it as a general purpose regex for validating
filenames.
The main problem is that your approach, i.e. trying to identify
"invalid characters", is not the best choice. Generally it is
advisable to do it the other way around: Decide which characters you
want to accept, and remove the rest.
Drop the regex you "found on the web" and start listen to the
suggestions given.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]