log for script

2008-04-16 Thread Irfan.Sayed
Hi All,

 

Is there any mechanism where I can take the log of entire Perl script. I
mean to say that I need the log of each and every step which I am doing
in Perl script. That step may include 

1: input from user

2: internal Perl script commands

 

Ultimately whatever Perl script is doing , I should know.

 

Is there any way. Please help.

 

Regards,

Irfan

 



Concatenate similar data in array

2008-04-16 Thread anthony brooke
Hello, my logic is really bad, here is I want to do. 

my @list = qw(a b a a d e e );

I want to compact the array by concatenating the adjacent vowels and consonant 
together, like for the above it should become,

my @list2 = qw(ab aa d ee);

How do I get the @list2 ? Thanks.




Send instant messages to your online friends http://uk.messenger.yahoo.com

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: about a statement

2008-04-16 Thread Jialin Li
comma operator has a higher precedence than 'or' operator,
so when require fails, eval returns undef and perl will
continue to set the status then return 0,

so your rewritten code will work exactly the same as the original code.

On Wed, Apr 16, 2008 at 9:02 PM, Jennifer G. <[EMAIL PROTECTED]>
wrote:

> what's this statement?
>
>  eval {
>require MIME::Base64;
>require Authen::SASL;
>  } or $self->set_status(500, ["Need MIME::Base64 and Authen::SASL
> todo auth"]), return 0;
>
> why ', return 0' can be used? I think maybe it should be ';' instead of
> ',' .
> Can I rewrite it as below?
>
>  eval {
>require MIME::Base64;
>require Authen::SASL;
>  };
>
> if ($@) {
>$self->set_status(500, ["Need MIME::Base64 and Authen::SASL todo
> auth"]);
>return 0;
> }
>
> Thanks!
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/
>
>
>


about a statement

2008-04-16 Thread Jennifer G.
what's this statement?

  eval {
require MIME::Base64;
require Authen::SASL;
  } or $self->set_status(500, ["Need MIME::Base64 and Authen::SASL
todo auth"]), return 0;

why ', return 0' can be used? I think maybe it should be ';' instead of ',' .
Can I rewrite it as below?

  eval {
require MIME::Base64;
require Authen::SASL;
  };

if ($@) {
$self->set_status(500, ["Need MIME::Base64 and Authen::SASL todo auth"]);
return 0;
}

Thanks!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Perl Modules

2008-04-16 Thread Chas. Owens

On Apr 16, 2008, at 13:33, Monty wrote:

Hope this is the right forum for this.

I recently downloaded Curses-1.23.tar from CPAN for installation on to
my Solaris 8 system.  I installed the module in the same area as all
my other perl modules: /usr/local/lib/perl5/5.8.5, but I noticed
there's also a directory named /usr/local/lib/perl5/site_perl.

Under the directory 5.8.5, I untarred the file and it created a
directory named Curse-1.23 and put everything under it.  I moved the
Curses.pm module up to the 5.8.5 directory and renamed the Curses-1.23
directory to Curses, so I can "use Curses" in my scripts.

Is this the correct way to install this module?  My scripts can't seem
to find it.

snip

No, this is not the proper way to install a Perl module.  You have  
four common routes to installing a module:

1. become root and use CPAN
2. become root and install manually
3. use CPAN as a normal user and set PERL5_LIB (or use the lib pragma)
4. install manually as a normal user and set PERL5_LIB (or use the lib  
pragma)


1. become root and use CPAN:
su -
perl -MCPAN -e "install Curses"
#answer all of the questions, the defaults tend to be correct

2. become root and install manually
su -
gzip -dc module-version.tar.gz | tar xvf
cd module-version
perl Makefile.pl
make
make test
make install
#stop if at any step where you get errors


3. use CPAN as a normal user and set PERL5_LIB (or use the lib pragma)
#like 1., but you should set PREFIX=/some/directory/you/countrol
perl -MCPAN -e "install Curses"
echo "export PERL5_LIB=/some/directory/you/countrol" >> .profile

4. install manually as a normal user and set PERL5_LIB (or use the lib  
pragma)

gzip -dc module-version.tar.gz | tar xvf
cd module-version
perl Makefile.pl PREFIX=/some/directory/you/countrol
make
make test
make install
#stop if at any step where you get errors
echo "export PERL5_LIB=/some/directory/you/countrol" >> .profile



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Perl Modules

2008-04-16 Thread Rob Dixon
Monty wrote:
> Hope this is the right forum for this.
> 
> I recently downloaded Curses-1.23.tar from CPAN for installation on to
> my Solaris 8 system.  I installed the module in the same area as all
> my other perl modules: /usr/local/lib/perl5/5.8.5, but I noticed
> there's also a directory named /usr/local/lib/perl5/site_perl.
> 
> Under the directory 5.8.5, I untarred the file and it created a
> directory named Curse-1.23 and put everything under it.  I moved the
> Curses.pm module up to the 5.8.5 directory and renamed the Curses-1.23
> directory to Curses, so I can "use Curses" in my scripts.
> 
> Is this the correct way to install this module?  My scripts can't seem
> to find it.


No. You should let the module install itself rather than moving files
around yourself. Take a look at

  perldoc perlmodinstall

for an explanation of the process.

Rob

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Perl Modules

2008-04-16 Thread John W. Krahn

Monty wrote:

Hope this is the right forum for this.

I recently downloaded Curses-1.23.tar from CPAN for installation on to
my Solaris 8 system.  I installed the module in the same area as all
my other perl modules: /usr/local/lib/perl5/5.8.5, but I noticed
there's also a directory named /usr/local/lib/perl5/site_perl.

Under the directory 5.8.5, I untarred the file and it created a
directory named Curse-1.23 and put everything under it.  I moved the
Curses.pm module up to the 5.8.5 directory and renamed the Curses-1.23
directory to Curses, so I can "use Curses" in my scripts.

Is this the correct way to install this module?  My scripts can't seem
to find it.


After you untar the file read the INSTALL file for directions on how to 
properly install the module.




John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.-- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Perl Modules

2008-04-16 Thread Monty
Hope this is the right forum for this.

I recently downloaded Curses-1.23.tar from CPAN for installation on to
my Solaris 8 system.  I installed the module in the same area as all
my other perl modules: /usr/local/lib/perl5/5.8.5, but I noticed
there's also a directory named /usr/local/lib/perl5/site_perl.

Under the directory 5.8.5, I untarred the file and it created a
directory named Curse-1.23 and put everything under it.  I moved the
Curses.pm module up to the 5.8.5 directory and renamed the Curses-1.23
directory to Curses, so I can "use Curses" in my scripts.

Is this the correct way to install this module?  My scripts can't seem
to find it.

Thanks


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: algorithm/permute.pm

2008-04-16 Thread Rob Dixon
Sharan Basappa wrote:
> Rob,
> 
> I replied to Chas' mail with steps I have followed to install the module.
> I have also tried omitting Algorithm to PREFIX, but that does not help.
> 
> perl Makefile.PL PREFIX=/u/basappas/local/perl/iter2/Algorithm-Permute-0.11
> make install
> setenv PERL5LIB /u/basappas/local/perl/iter2/Algorithm-Permute-0.11
> perl Perm2.pl
> Can't locate Algorithm/Permute.pm in @INC (@INC contains:
> /u/basappas/local/perl/onemore/Algorithm-Permute-0.11
> 
> There are few parameters and I sure I am not using one of them properly.
> 1) argument to PREFIX (with or without Algorithm)
> 2) PERL5LIB path
> 3) use lib directive in my script

You don't need both to set PERL5LIB and 'use lib'. One or the other is fine.

My reply said,

> the log from 'make install' will show you where the module has been
> installed to

You still haven't published your installation log, so I can't help you
much further, but it's wrong to include the Algorithm folder in the path
you supply as the value of the PREFIX parameter

Why are you using

  PREFIX=/u/basappas/local/perl/iter2/Algorithm-Permute-0.11

when it could be just

  PREFIX=/u/basappas/local/perl

?

Look in the installation log for where it has put Algorithm/Permute.pm -
i.e. what is the path to the Algorithm folder. Use that path in your
'use lib' statement.

Rob




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: CSV duplicate

2008-04-16 Thread John W. Krahn

Manoj wrote:

Hello List,


Hello,


Scenario:
CSV file
Host=Nirus,TCPIP,inxcp011,connected,Serv=rxmcpp1
Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp2
Host=Rome,TCPIP,inxcp011,connected, Serv=rxmcpp1
Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1
Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp3
Host=Spring,TCPIP,inxcp011,connected, Serv=rxmcpp
Host=Spring,TCPIP,inxcp011,connected, Serv=rxmcpp1
Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1
Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1
Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1
Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1

Required output is 
Nirus

Spring

There is one more requirement I need to sort the 5th column and sort them
and fetch which ever is duplicate. So in this one I need to print 
rxmcpp1 to screen.


This should be close to what you want:

my %data;
while (  ) {
chomp;
for ( map [ split /=/ ], ( split /\s*,\s*/ )[ 0, -1 ] ) {
$data{ $_->[ 0 ] }{ $_->[ 1 ] }++;
}
}

for my $type ( keys %data ) {
print "Duplicate $type\n";
for my $key ( keys %{ $data{ $type } } ) {
print "$key\n" if $data{ $type }{ $key } > 1;
}
print "\n";
}



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.-- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: CSV duplicate

2008-04-16 Thread Jialin Li
#!/usr/bin/perl -w

my (%hosts, %servs);
while () {
  chomp;
  my ($host, $server) = (split /,\s*/)[0,4];
  $hosts{$host}++ if ($host);
  $servs{$server}++ if ($server);
}

my @dup_hosts = map { substr $_,0,5,''; $_ }
  grep { $hosts{$_} > 1 }  keys %hosts;

my @dup_servs = map { substr $_,0,5,''; $_ }
  grep { $servs{$_} > 1 }  keys %servs;

local $, = $/;
print "duplicate hosts:\n";
print @dup_hosts;
print "\n\nduplicate servers:\n";
print @dup_servs;






__DATA__

Host=Nirus,TCPIP,inxcp011,connected,Serv=rxmcpp1

Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp2

Host=Rome,TCPIP,inxcp011,connected, Serv=rxmcpp1

Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1

Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp3

Host=Spring,TCPIP,inxcp011,connected, Serv=rxmcpp

Host=Spring,TCPIP,inxcp011,connected, Serv=rxmcpp1

Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1

Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1

Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1

Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1

__END__

On Wed, Apr 16, 2008 at 2:16 PM, Wagner, David --- Senior Programmer Analyst
--- WGO <[EMAIL PROTECTED]> wrote:

>
> > -Original Message-
> > From: Manoj [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, April 16, 2008 12:00
> > To: 'Perl Beginners'
> > Subject: CSV duplicate
> >
> > Hello List,
> >
> >
> >
> > Scenario:
> >
> > CSV file
> >
> > Host=Nirus,TCPIP,inxcp011,connected,Serv=rxmcpp1
> >
> > Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp2
> >
> > Host=Rome,TCPIP,inxcp011,connected, Serv=rxmcpp1
> >
> > Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1
> >
> > Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp3
> >
> > Host=Spring,TCPIP,inxcp011,connected, Serv=rxmcpp
> >
> > Host=Spring,TCPIP,inxcp011,connected, Serv=rxmcpp1
> >
> > Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1
> >
> > Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1
> >
> > Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1
> >
> > Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1
> >
> >
> >
> > Required output is
> >
> > Nirus
> >
> > Spring
> >
> >
> So what are you searching on or looking at to determine that you
> want only those two? The last depends on the number of rcds and are you
> only concerned with the server name?
>
> Wags ;)
>
> >
> > There is one more requirement I need to sort the 5th column
> > and sort them
> > and fetch which ever is duplicate. So in this one I need to print
> >
> > rxmcpp1 to screen.
> >
> >
>
> **
> This message contains information that is confidential and proprietary to
> FedEx Freight or its affiliates.  It is intended only for the recipient
> named and for the express  purpose(s) described therein.  Any other use is
> prohibited.
> **
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/
>
>
>


RE: CSV duplicate

2008-04-16 Thread Wagner, David --- Senior Programmer Analyst --- WGO

> -Original Message-
> From: Manoj [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, April 16, 2008 12:00
> To: 'Perl Beginners'
> Subject: CSV duplicate
> 
> Hello List,
> 
>  
> 
> Scenario:
> 
> CSV file
> 
> Host=Nirus,TCPIP,inxcp011,connected,Serv=rxmcpp1
> 
> Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp2
> 
> Host=Rome,TCPIP,inxcp011,connected, Serv=rxmcpp1
> 
> Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1
> 
> Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp3
> 
> Host=Spring,TCPIP,inxcp011,connected, Serv=rxmcpp
> 
> Host=Spring,TCPIP,inxcp011,connected, Serv=rxmcpp1
> 
> Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1
> 
> Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1
> 
> Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1
> 
> Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1
> 
>  
> 
> Required output is 
> 
> Nirus
> 
> Spring
> 
>  
So what are you searching on or looking at to determine that you
want only those two? The last depends on the number of rcds and are you
only concerned with the server name?

Wags ;)

> 
> There is one more requirement I need to sort the 5th column 
> and sort them
> and fetch which ever is duplicate. So in this one I need to print 
> 
> rxmcpp1 to screen.
> 
> 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




CSV duplicate

2008-04-16 Thread Manoj
Hello List,

 

Scenario:

CSV file

Host=Nirus,TCPIP,inxcp011,connected,Serv=rxmcpp1

Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp2

Host=Rome,TCPIP,inxcp011,connected, Serv=rxmcpp1

Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1

Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp3

Host=Spring,TCPIP,inxcp011,connected, Serv=rxmcpp

Host=Spring,TCPIP,inxcp011,connected, Serv=rxmcpp1

Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1

Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1

Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1

Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1

 

Required output is 

Nirus

Spring

 

There is one more requirement I need to sort the 5th column and sort them
and fetch which ever is duplicate. So in this one I need to print 

rxmcpp1 to screen.



Fwd: setting unix command through perl script

2008-04-16 Thread Kenneth Wolcott
Oops -- did reply and instead of reply-all :-(

-- Forwarded message --
From: Kenneth Wolcott <[EMAIL PROTECTED]>
Date: Wed, Apr 16, 2008 at 11:33 AM
Subject: Re: setting unix command through perl script
To: [EMAIL PROTECTED]


Agreed that the parent process in which perl was invoked will not be changed
by the perl script.

What is the overall objective?

Try to do everything you need to do inside the perl script, or everything
you need to do outside the perl script.

HTH,
Ken Wolcott


On Wed, Apr 16, 2008 at 5:31 AM, Martin Barth <[EMAIL PROTECTED]> wrote:

> i think this is not possible.
>
> if you start a new process (shell) it gets the environment of its parent
> process. but if you manipulate the environment in a child the parent will
> not notice this..
>
> for example
>
> $ bash
> $ export FOO=BAR
> $ echo $FOO
> BAR
> $ exit
> $ echo $FOO
>
>
> Regards Martin
>
>
> On 14:20:18 16/04/2008 <[EMAIL PROTECTED]> wrote:
> > I tried the line : $ENV{CCASE_NO_FILE_HEADER} = 'yes';
> >
> > But still the value is not getting set.
> >
> > Please help.
> >
> > Regards,
> > Irfan
> >
> > Project Lead
> > TSINDIA - Production Line
> > Individual Software Solutions - UMO
> > T-Systems India Private Limited, Pune
> > Telephone: +91-20-30245000/25605000 (Extn: 5271)
> > Mobile: +91 9822 854 227
> > Fax: +91-020 25674090
> > Internet: http://www.t-systems.com
> >
> >
> > -Original Message-
> > From: Rodrick Brown [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, April 16, 2008 5:04 PM
> > To: Sayed, Irfan
> > Cc: beginners@perl.org
> > Subject: Re: setting unix command through perl script
> >
> > On Wed, Apr 16, 2008 at 7:05 AM,  <[EMAIL PROTECTED]> wrote:
> > >  Hi All,
> > >
> > >
> > >
> > >   I need to execute the "export CCASE_NO_FILE_HEADER=yes" command
> > >   through Perl script.
> > >
> > >
> > >
> > >   What I did is qx(export CCASE_NO_FILE_HEADER=yes); but still the
> > >   value for CCASE_NO_FILE_HEADER is not getting set to "yes"
> > >
> > >
> > >
> > >   Regards,
> > >
> > >   Irfan
> > >
> > >
> > >
> > >
> >
> > With Perl you can get and set environment variables through using %ENV
> > ie. $ENV{FOO} = 'bar'
> >
> > --
> > [ Rodrick R. Brown ]
> > http://www.rodrickbrown.com
> > http://www.linkedin.com/in/rodrickbrown
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > http://learn.perl.org/
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/
>
>
>


Re: algorithm/permute.pm

2008-04-16 Thread Sharan Basappa
Rob,

I replied to Chas' mail with steps I have followed to install the module.
I have also tried omitting Algorithm to PREFIX, but that does not help.

perl Makefile.PL PREFIX=/u/basappas/local/perl/iter2/Algorithm-Permute-0.11
make install
setenv PERL5LIB /u/basappas/local/perl/iter2/Algorithm-Permute-0.11
perl Perm2.pl
Can't locate Algorithm/Permute.pm in @INC (@INC contains:
/u/basappas/local/perl/onemore/Algorithm-Permute-0.11

There are few parameters and I sure I am not using one of them properly.
1) argument to PREFIX (with or without Algorithm)
2) PERL5LIB path
3) use lib directive in my script

TIA, Regards

On Tue, Apr 15, 2008 at 11:05 PM, Rob Dixon <[EMAIL PROTECTED]> wrote:
>
> Sharan Basappa wrote:
>  > On Fri, Apr 4, 2008 at 8:48 PM, Sharan Basappa <[EMAIL PROTECTED]> wrote:
>  >> Dont seem to have luck. I did make test followed by make install.
>  >>  Here is what I got:
>  >>  make install
>  >>  Installing 
> /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/Algorithm/Permute/Permute.so
>  >>  Installing 
> /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/Algorithm/Permute/Permute.bs
>  >>  Files found in blib/arch: installing files in blib/lib into
>  >>  architecture dependent library tree
>  >>  Installing 
> /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/Algorithm/Permute.pm
>  >>  Installing 
> /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/Algorithm/Permute/autosplit.ix
>  >>  Installing 
> /u/basappas/local/perl/Algorithm-Permute-0.06/share/man/man3/Algorithm::Permute.3pm
>  >>  Writing 
> /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/Algorithm/Permute/.packlist
>  >>  Appending installation info to
>  >>  
> /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/5.8.5/i386-linux-thread-multi/perllocal.pod
>  >>
>  >>  The issue still remains. That is:
>  >>  >perl Perm2.pl
>  >>
>  >> Can't locate Algorithm/Permute.pm in @INC (@INC contains:
>  >>
>  >> /u/basappas/local/perl/Algorithm-Permute-0.06
>  >>
>  >> /usr/lib/perl5/5.8.5/i386-linux-thread-multi /usr/lib/perl5/5.8.5
>  >>  /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi
>  >>  /usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi
>  >>  /usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi
>  >>  /usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi
>  >>  /usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi
>  >>  /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
>  >>  /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4
>  >>  /usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2
>  >>  /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0
>  >>  /usr/lib/perl5/site_perl
>  >>  /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi
>  >>  /usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi
>  >>  /usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi
>  >>  /usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi
>  >>  /usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi
>  >>  /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
>  >>  /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4
>  >>  /usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2
>  >>  /usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0
>  >>  /usr/lib/perl5/vendor_perl .) at Perm2.pl line 4.
>  >>  BEGIN failed--compilation aborted at Perm2.pl line 4.
>  >>
>  >>  Maybe I should rewind and start looking at this issue afresh now ...
>  >>
>  >>  Regards
>  >>
>  >>
>  >>
>  >>  On Tue, Apr 1, 2008 at 4:32 PM, sisyphus <[EMAIL PROTECTED]> wrote:
>  >>  > > I did the following:
>  >>  >  > perl Makefile.PL 
> PREFIX=/u/basappas/local/perl/Algorithm-Permute-0.06
>  >>  >
>  >>  >  That's probably where you've got the Algorithm-Permute source - I'm
>  >>  >  not so sure it's a good idea to install the module into the source
>  >>  >  folder, but if you want to do that then next run 'make test', followed
>  >>  >  by 'make install'.
>  >>  >
>  >>  >  Then, try this script:
>  >>  >
>  >>  >  #!/usr/bin/perl
>  >>  >  use warnings;
>  >>  >  use lib "/u/basappas/local/perl/Algorithm-Permute-0.06";
>  >>  >  use Algorithm::Permute;
>  >>  >
>  >>  >  my @array = (1..4);
>  >>  >
>  >>  > Algorithm::Permute::permute { print "@array\n" } @array;
>  >>  >
>  >>  >  Why are you installing version 0.06 when the latest version is 0.11 ?
>  >>  >
>  >>  >
>  >>  >
>  >>  >  Cheers,
>  >>  >  Rob
>  >>  >
>  >>  >
>  >>  >  --
>  >>  >  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  >>  >  For additional commands, e-mail: [EMAIL PROTECTED]
>  >>  >  http://learn.perl.org/
>  >>  >
>  >>  >
>  >>  >
>  >>
>  >
>  > Looking at the error once again, I did notice that I was probably not
>  > installing the module 

Re: algorithm/permute.pm

2008-04-16 Thread Sharan Basappa
On Tue, Apr 15, 2008 at 9:58 PM, Chas. Owens <[EMAIL PROTECTED]> wrote:
> Where/how did you install the module.  If it was not installed in the normal
> directory (ie the one it will be installed in if you installed as root) you
> will need to either set the PERL5_LIB environmental variable or use the lib
> pragma.
>

yes, the module is installed as a local library.
It is in path /u/basappas/local/perl/onemore/Algorithm-Permute-0.11

The following are the steps I followed:
perl Makefile.PL
PREFIX=/u/basappas/local/perl/onemore/Algorithm-Permute-0.11/Algorithm
-- this step completes normal
make install - this step completes normal

PERL5LIB is set to:
/u/basappas/local/perl/onemore/Algorithm-Permute-0.11/ (should it
point to Algorithm?)

My code snippet is:
#!/usr/bin/perl
use warnings;
use lib "/u/basappas/local/perl/onemore/Algorithm-Permute-0.11";
use Algorithm::Permute;

my @array = (1..4);
Algorithm::Permute::permute { print "@array\n" } @array;

The error I get is:
Can't locate Algorithm/Permute.pm in @INC (@INC contains:
/u/basappas/local/perl/onemore/Algorithm-Permute-0.11

Question:
- Am I right in adding Algorithm to the prefix arg
(PREFIX=/u/basappas/local/perl/onemore/Algorithm-Permute-0.11/Algorithm)?
- I was originally not adding Algorithm to the arg, but tried this
option since perl seem to be looking for Permute.pm inside Algorithm
dir (or  is it?)

Regards

>  --
>  Chas. Owens
>  wonkden.net
>  The most important skill a programmer can have is the ability to read.
>
>
>
>  On Apr 15, 2008, at 12:00, Sharan Basappa wrote:
>
>
> >
> >
> >
> > On Fri, Apr 4, 2008 at 8:48 PM, Sharan Basappa <[EMAIL PROTECTED]>
> wrote:
> >
> > > Dont seem to have luck. I did make test followed by make install.
> > > Here is what I got:
> > > make install
> > > Installing
> /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/Algorithm/Permute/Permute.so
> > > Installing
> /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/Algorithm/Permute/Permute.bs
> > > Files found in blib/arch: installing files in blib/lib into
> > > architecture dependent library tree
> > > Installing
> /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/Algorithm/Permute.pm
> > > Installing
> /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/Algorithm/Permute/autosplit.ix
> > > Installing
> /u/basappas/local/perl/Algorithm-Permute-0.06/share/man/man3/Algorithm::Permute.3pm
> > > Writing
> /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/Algorithm/Permute/.packlist
> > > Appending installation info to
> > >
> /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/5.8.5/i386-linux-thread-multi/perllocal.pod
> > >
> > > The issue still remains. That is:
> > >
> > > > perl Perm2.pl
> > > >
> > >
> > > Can't locate Algorithm/Permute.pm in @INC (@INC contains:
> > >
> > > /u/basappas/local/perl/Algorithm-Permute-0.06
> > >
> > > /usr/lib/perl5/5.8.5/i386-linux-thread-multi /usr/lib/perl5/5.8.5
> > > /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi
> > > /usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi
> > > /usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi
> > > /usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi
> > > /usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi
> > > /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
> > > /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4
> > > /usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2
> > > /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0
> > > /usr/lib/perl5/site_perl
> > > /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi
> > > /usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi
> > > /usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi
> > > /usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi
> > > /usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi
> > > /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
> > > /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4
> > > /usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2
> > > /usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0
> > > /usr/lib/perl5/vendor_perl .) at Perm2.pl line 4.
> > > BEGIN failed--compilation aborted at Perm2.pl line 4.
> > >
> > > Maybe I should rewind and start looking at this issue afresh now ...
> > >
> > > Regards
> > >
> > >
> > >
> > > On Tue, Apr 1, 2008 at 4:32 PM, sisyphus <[EMAIL PROTECTED]> wrote:
> > >
> > > >
> > > > > I did the following:
> > > > > perl Makefile.PL
> PREFIX=/u/basappas/local/perl/Algorithm-Permute-0.06
> > > > >
> > > >
> > > > That's probably where you've got the Algorithm-Permute source - I'm
> > > > not so sure it's a good idea to install the module into the source
> > > > folder, but if you want to do that t

Re: Regular Expression Help

2008-04-16 Thread Rob Dixon
Ley, Chung wrote:
> Hi,
> 
>  
> 
> I have a program that will take in a string that will resolve to a path
> where the output is going to store.
> 
>  
> 
> The path can includes "variables" in this format "%%".
> The acceptable variableNames that the program will support are fixed to
> a list such as "Person", "Class", "Dept".  This list may grow in the
> future; but for now it is fixed.
> 
>  
> 
> So, some of the acceptable strings are:
> 
> C:\Windows\%Person%\%Class%
> 
> C:\MyHomeDir\%Dept%\%Person%
> 
> C:\MyHomeDir\%Dept%_%Person%
> 
> and etc...
> 
>  
> 
> I like to develop a validate method to return false when the string in
> between the % pair don't belong to the acceptable list, and was trying
> to do that with an expression.
> 
> - Look for the string that is in between the "%" by the closest pair.
> 
> - The "%" pair must start at the "odd" occurrence and finish on the
> "next even" occurrence...  Don't know how to describe this exactly, but
> I don't want it to pack this up ("InBetween") from this
> (C:\MyHomeDir\%Dept%InBetween%Person) even though it is in between a %
> pair.
> 
> - Then compare the string within the "%" pair to see if it belongs to
> the "acceptable" list or not.
> 
>  
> 
> Is using a regular expression the right approach here?  or I should just
> iterate thru?

If the names are environment variable names, which is implied by your
syntax, then you can substitute the values of those variables as shown
in the program below.

HTH,

Rob


use strict;
use warnings;

my $str = '%windir%\system32';

$str =~ s/%(.*?)%/$ENV{uc $1}/g;

print $str;

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: CGI serverpush??

2008-04-16 Thread Gunnar Hjalmarsson

sanket vaidya wrote:

Kindly go through the code below.





use CGI::Push qw(:standard);

do_push(-next_page=>\&refresh,
-last_page=>\&done);





When I run this code typing "http://localhost/push.cgi"; in the browser I get
internal server error.

I  use Apache 2.2 on windows & perl 5.10.


Try setting the -nph parameter to a false value.

do_push (
-next_page => \&refresh,
-last_page => \&done,
-nph => 0,
);

See http://search.cpan.org/perldoc?CGI::Push#INSTALLING_CGI::Push_SCRIPTS

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: setting unix command through perl script

2008-04-16 Thread Martin Barth
i think this is not possible.

if you start a new process (shell) it gets the environment of its parent
process. but if you manipulate the environment in a child the parent will
not notice this..

for example

$ bash
$ export FOO=BAR
$ echo $FOO
BAR
$ exit
$ echo $FOO


Regards Martin


On 14:20:18 16/04/2008 <[EMAIL PROTECTED]> wrote:
> I tried the line : $ENV{CCASE_NO_FILE_HEADER} = 'yes';
>
> But still the value is not getting set.
>
> Please help.
>
> Regards,
> Irfan
>
> Project Lead
> TSINDIA - Production Line
> Individual Software Solutions - UMO
> T-Systems India Private Limited, Pune
> Telephone: +91-20-30245000/25605000 (Extn: 5271)
> Mobile: +91 9822 854 227
> Fax: +91-020 25674090
> Internet: http://www.t-systems.com
>
>
> -Original Message-
> From: Rodrick Brown [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, April 16, 2008 5:04 PM
> To: Sayed, Irfan
> Cc: beginners@perl.org
> Subject: Re: setting unix command through perl script
>
> On Wed, Apr 16, 2008 at 7:05 AM,  <[EMAIL PROTECTED]> wrote:
> >  Hi All,
> >
> >
> >
> >   I need to execute the "export CCASE_NO_FILE_HEADER=yes" command
> >   through Perl script.
> >
> >
> >
> >   What I did is qx(export CCASE_NO_FILE_HEADER=yes); but still the
> >   value for CCASE_NO_FILE_HEADER is not getting set to "yes"
> >
> >
> >
> >   Regards,
> >
> >   Irfan
> >
> >
> >
> >
>
> With Perl you can get and set environment variables through using %ENV
> ie. $ENV{FOO} = 'bar'
>
> --
> [ Rodrick R. Brown ]
> http://www.rodrickbrown.com
> http://www.linkedin.com/in/rodrickbrown
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: setting unix command through perl script

2008-04-16 Thread Irfan.Sayed
I tried the line : $ENV{CCASE_NO_FILE_HEADER} = 'yes';

But still the value is not getting set.

Please help.

Regards,
Irfan

Project Lead
TSINDIA - Production Line
Individual Software Solutions - UMO
T-Systems India Private Limited, Pune
Telephone: +91-20-30245000/25605000 (Extn: 5271) 
Mobile: +91 9822 854 227
Fax: +91-020 25674090
Internet: http://www.t-systems.com


-Original Message-
From: Rodrick Brown [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 16, 2008 5:04 PM
To: Sayed, Irfan
Cc: beginners@perl.org
Subject: Re: setting unix command through perl script

On Wed, Apr 16, 2008 at 7:05 AM,  <[EMAIL PROTECTED]> wrote:
> Hi All,
>
>
>
>  I need to execute the "export CCASE_NO_FILE_HEADER=yes" command through
>  Perl script.
>
>
>
>  What I did is qx(export CCASE_NO_FILE_HEADER=yes); but still the value
>  for CCASE_NO_FILE_HEADER is not getting set to "yes"
>
>
>
>  Regards,
>
>  Irfan
>
>
>
>

With Perl you can get and set environment variables through using %ENV
ie. $ENV{FOO} = 'bar'

-- 
[ Rodrick R. Brown ]
http://www.rodrickbrown.com
http://www.linkedin.com/in/rodrickbrown

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: setting unix command through perl script

2008-04-16 Thread Rodrick Brown
On Wed, Apr 16, 2008 at 7:05 AM,  <[EMAIL PROTECTED]> wrote:
> Hi All,
>
>
>
>  I need to execute the "export CCASE_NO_FILE_HEADER=yes" command through
>  Perl script.
>
>
>
>  What I did is qx(export CCASE_NO_FILE_HEADER=yes); but still the value
>  for CCASE_NO_FILE_HEADER is not getting set to "yes"
>
>
>
>  Regards,
>
>  Irfan
>
>
>
>

With Perl you can get and set environment variables through using %ENV
ie. $ENV{FOO} = 'bar'

-- 
[ Rodrick R. Brown ]
http://www.rodrickbrown.com
http://www.linkedin.com/in/rodrickbrown

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




setting unix command through perl script

2008-04-16 Thread Irfan.Sayed
Hi All,

 

I need to execute the "export CCASE_NO_FILE_HEADER=yes" command through
Perl script.

 

What I did is qx(export CCASE_NO_FILE_HEADER=yes); but still the value
for CCASE_NO_FILE_HEADER is not getting set to "yes"

 

Regards,

Irfan

 



Re: reg ex

2008-04-16 Thread Paul Johnson
On Wed, Apr 16, 2008 at 12:31:36AM +0100, Rob Dixon wrote:
> Paul Johnson wrote:
> > On Tue, Apr 15, 2008 at 08:38:30PM +0100, Rob Dixon wrote:
> >> Paul Johnson wrote:
> >>> On Wed, Apr 16, 2008 at 12:11:20AM +0530, [EMAIL PROTECTED] wrote:
> >>>
>  I need help in regular expression. I have string as follows.
> 
>  OMS.FD.08.03.000.14
> 
>  I need only OMS.FD.08.03.000 this much part of the string.i want to
>  exclude .14
> >>> That's not much of a spec.  How far have you got?
> >>>
> >>> Perhaps one of these possibilities will help?
> >>>
> >>>  $_ = "OMS.FD.08.03.000";
> >> It was 'OMS.FD.08.03.000.14'
> > 
> > The original was.  I was providing an (admittedly unlikely) potential
> > solution.
> 
> No, the object data in the original post was different from what you
> coded. I don't think you meant to correct his data - that would be a
> little too presumptuous :)

My point, which was obviously not well made (twice!), was that given the
minimal requirement

>  I need only OMS.FD.08.03.000 this much part of the string.

a sort of Reductio ad absurdum argument leads to a solution of

> >>>  $_ = "OMS.FD.08.03.000";

As such I should probably have given the solution last on my list, but that
would have entailed applying some sort of likeliness ordering on the list,
which I didn't really feel like doing.

In any case, perhaps Irfan would like to clarify his intent and let us know
which particular parts of the problem are causing him problems?

> Sure - the problem was understated, but all of your solutions modified
> the object string when a simple regex with a capture could have provided
> a solution with no side effects.
> 
> An analyst's job is to establish the problem as well as the solution,
> not to invent possible problems.

You are correct.  My re-reading of the original post still suggests that
modifying the string is the most likely requirement, but that's hardly
important any more.  And both of us have wasted too much time on this already,
for which I apologise.

Over to you, Irfan.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Troubleshooting SQL server

2008-04-16 Thread aspiritus
On Apr 15, 3:52 am, [EMAIL PROTECTED] (Chas. Owens) wrote:
> On Mon, Apr 14, 2008 at 7:11 PM, Jenda Krynicky <[EMAIL PROTECTED]> wrote:
>
> snip>  >  my $sql = q/SELECT Account,Last_Name,First_Name,Email_Address  FROM
> >  > prospects WHERE Email_Address='?'/;
>
> >  Drop the singlequotes. This way your SQL searches for a literal
> >  questionmark in the Email_Address column.
>
> snip
>
> Are you certain?  DB2, for instance, requires the use of single quotes
> for strings (double quotes are for system objects).  Are you confusing
> placeholders and Perl/shell interpolation?
>
> --
> Chas. Owens
> wonkden.net
> The most important skill a programmer can have is the ability to read.

Most likely Email_Address is set as VARCHAR or whatever. This way "
WHERE Email_Address='?' " does find all email addresses that are ?
and ? only or depending on settings, query craches.

 If you want to find all address containing ?-chart use this: " WHERE
Email_Address like '%?%' ".
 For using placeholder you must remove quotes, so the query is: "
WHERE Email_Address=? " and execution: my $sth = $dbh->prepare($sql);
$sth->execute($email) or die $dbh->errstr;

Of course you can first check if query does anything by:

my $sth = $dbh->prepare($sql);
my $execute_rows = $sth->execute($email); # get affected rows
$sth->execute($email) or die $dbh->errstr;  # execute it


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/