Errors installing modules on Solaris 9

2004-07-24 Thread JR Miller
New to loading PERL modules and can't figure this one out.  Running Solaris
9 with current patches, PERL is v5.6.1 built for sun4-solaris-64int.  Most
modules I try to install bomb out with the same errors as the following
ERROR TEXT.  Using gmake and have installed gcc as well (both are in my
PATH).  Are there some other environment variables I'm missing?  Been trying
google searches, but keep coming up short.

Thanks in advance,

-JR Miller

ERROR TEXT:


cpan> install Term::ReadKey
Going to read /.cpan/sources/authors/01mailrc.txt.gz
Going to read /.cpan/sources/modules/02packages.details.txt.gz
  Database was generated on Sat, 24 Jul 2004 21:17:27 GMT
  HTTP::Date not available
Going to read /.cpan/sources/modules/03modlist.data.gz
Running install for module Term::ReadKey
Running make for J/JS/JSTOWE/TermReadKey-2.21.tar.gz

  CPAN: MD5 security checks disabled because Digest::MD5 not installed.
  Please consider installing the Digest::MD5 module.

Scanning cache /.cpan/build for sizes
x TermReadKey-2.21, 0 bytes, 0 tape blocks
x TermReadKey-2.21/genchars.pl, 10688 bytes, 21 tape blocks
x TermReadKey-2.21/README, 6346 bytes, 13 tape blocks
x TermReadKey-2.21/MANIFEST, 92 bytes, 1 tape blocks
x TermReadKey-2.21/test.pl, 6871 bytes, 14 tape blocks
x TermReadKey-2.21/ReadKey.pm, 15489 bytes, 31 tape blocks
x TermReadKey-2.21/Makefile.PL, 1222 bytes, 3 tape blocks
x TermReadKey-2.21/Configure.pm, 27633 bytes, 54 tape blocks
x TermReadKey-2.21/ppport.h, 11683 bytes, 23 tape blocks
x TermReadKey-2.21/ReadKey.xs, 41600 bytes, 82 tape blocks
Removing previously used /.cpan/build/TermReadKey-2.21

  CPAN.pm: Going to build J/JS/JSTOWE/TermReadKey-2.21.tar.gz

Checking if your kit is complete...
Looks good
Writing Makefile for Term::ReadKey
cp ReadKey.pm blib/lib/Term/ReadKey.pm
AutoSplitting blib/lib/Term/ReadKey.pm (blib/lib/auto/Term/ReadKey)
/usr/bin/perl -I/usr/perl5/5.6.1/lib genchars.pl

Writing termio/termios section of cchars.h... Done.
Checking for sgtty...
Sgtty NOT found.
Writing sgtty section of cchars.h... Done.
/usr/bin/perl -I/usr/perl5/5.6.1/lib/sun4-solaris-64int -I/usr/perl5/5.6.1/l
ib /usr/perl5/5.6.1/lib/ExtUtils/xsubpp -noprototypes -typemap
/usr/perl5/5.6.1/lib/ExtUtils/typemap ReadKey.xs > ReadKey.xsc && mv
ReadKey.xsc ReadKey.c
cc -c  -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -xO3 -xdepend   -DVERSION=
\"2.21\" -DXS_VERSION=\"2.21\" -KPIC -I/usr/perl5/5.6.1/lib/sun4-solaris-64i
nt/CORE  ReadKey.c
gmake: cc: Command not found
gmake: *** [ReadKey.o] Error 127
  /opt/sfw/bin/gmake  -- NOT OK
Running make test
  Can't test without successful make
Running make install
  make had returned bad status, install seems impossible


Re: Multiple Parameters

2004-07-24 Thread James Edward Gray II
On Jul 24, 2004, at 11:38 AM, <[EMAIL PROTECTED]> wrote:
I am trying to write a search and replace script that can accept 
multiple
arguments, but i want the first argument to be the filename to read, 
the
next one to be the string to search for, the next one to be the 
replacement
string, and the last one to be the name of the new file it creates 
with the
new changes, but i can't figure out how to seperate each argument, can 
some
one tell me how to do something like this. Any help is very much
appreciated.
Well, command line arguments come into the program by way of the array 
@ARGV.  So first we should be sure you got the right number of 
arguments:

die "Usage:  script OLD_FILE, SEARCH, REPLACE, NEW_FILE\n"
unless @ARGV == 4;
Then we can use it:
my($old_file, $search, $replace, $new_file) = @ARGV;
Finally, just FYI, you can do what you describe with a one-liner:
perl -pi.bak -e 's/search/replace/g' old_file
Hope that helps.
James
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Help required with DBI

2004-07-24 Thread David Dorward
On Sat, 2004-07-24 at 19:14, NandKishore.Sagi wrote:

> $data_source = "dbi:DriverName:database_name" ;
>  
> Can't locate DBD/DriverName.pm in

Change "DriveName" to the name of the driver you want to use (e.g.
mysql)

Change "database_name" to the name of the database you want to use.

-- 
David Dorward      


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




Help required with DBI

2004-07-24 Thread NandKishore.Sagi
Hi All ,
 
I need some help with DBI. This is the first time I am working
with DBI module and am pretty new to perl too. I am trying to connect to
a database to execute some queries. I had written a code which is shown
below (It is actually a partial code for just connecting to database). I
am getting errors which I have pasted below. I believe that it might be
due to my lacking some modules but I have turned to you gurus to confirm
that and how can I overcome that. Actually this code would be executed
at multiple boxes so installing the absent packages may not be a
feasible solution. 
 
Thanks for any help.
 
Code

 
#!/opt/3d/bin/perl
 
use strict ;
use warnings ;
use DBI ;
 
my $database_name ;
my $data_source  ;
my $dbh ;
my $username  ;
my $password ;
 
## I have got my username and password here ##
 
$database_name = $ENV{ORACLE_SID} ;  #This contains the ORACLE_SID to
which I need to connect
 
$data_source = "dbi:DriverName:database_name" ;
 
$dbh = DBI->connect($data_source , $username , $password)
or die $DBI::errstr ;
 
$dbh->disconnect ;

 
Errors
-
 
install_driver(DriverName) failed: Can't locate DBD/DriverName.pm in
@INC (@INC contains: /opt/3d/dc0579/lib/perl5/5.8.0/aix-thread-
multi /opt/3d/dc0579/lib/perl5/5.8.0 /opt/3d/dc0579/lib/perl5
/opt/3d/dc0579/lib/perl5/site_perl/5.8.0/aix-thread-multi /opt/3d/dc05
79/lib/perl5/site_perl/5.8.0 /opt/3d/dc0579/lib/perl5/site_perl
/opt/3d/lib/perl5/5.8.0/aix-thread-multi /opt/3d/lib/perl5/5.8.0 /op
t/3d/lib/perl5/site_perl/5.8.0/aix-thread-multi
/opt/3d/lib/perl5/site_perl/5.8.0 /opt/3d/lib/perl5/site_perl .) at
(eval 1) line 3.
Perhaps the DBD::DriverName perl module hasn't been fully installed,
or perhaps the capitalisation of 'DriverName' isn't right.
Available drivers: CSV, ExampleP, File, Oracle, Proxy.
 at ./sql_exec.pl line 20
 
Thanks and Regards
Nand Kishore S
 
Nand Kishore Sagi
ART Support Team
612-304-6917/612-375-2364


Multiple Parameters

2004-07-24 Thread mafioso1823
I am trying to write a search and replace script that can accept multiple
arguments, but i want the first argument to be the filename to read, the
next one to be the string to search for, the next one to be the replacement
string, and the last one to be the name of the new file it creates with the
new changes, but i can't figure out how to seperate each argument, can some
one tell me how to do something like this. Any help is very much
appreciated.


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




Re: Trying to understand sort and anonymous sub

2004-07-24 Thread Paul Johnson
On Sat, Jul 24, 2004 at 08:57:56AM -0400, Dalton Marris wrote:

> I am trying to understand the use of "sub" in the second "foreach 
> $daynum" loop in the code shown below.  I know it's an anonymous sub, 
> but can't figure out why it's needed, if it indeed is.  I have read the 
> perlref and perlsub documents, and googled for information, to no avail.
> 
> Some things I have noticed regarding the first and second "foreach 
> $daynum" loops:
> 
> When I step through the first "foreach $daynum" loop with Komodo, it 
> seems to hang on the "foreach" as each combination of $a and $b values 
> is sorted.  Stepping continues after everything is sorted.  The 
> resultant output file contains the following (as expected):
> 
> 946684800|Holiday 1|Holiday 2
> 950486400|Holiday 3
> 954547200|Holiday 5
> 977702400|Holiday 7|Holiday 8
> 
> When stepping through the second "foreach $daynum" loop, it only takes 
> one step before it continues on, so it appears to be faster.  However, 
> it also results in an extra key, for some reason.  The resultant output 
> file contains the following:
> 
> 946684800|Holiday 1|Holiday 2
> 950486400|Holiday 3
> 954547200|Holiday 5
> 977702400|Holiday 7|Holiday 8
> CODE(0x198f04c)
> 
> My questions:
> 
> (1) What should the "sub" be doing?

It is a bug.  It shouldn't be there.

> (2) Where is the "CODE(0x198f04c)" coming from?

The first sort is using the specified subroutine {$a<=>$b} to sort
numerically.  The second sort is using the default sort subroutine
({$a cmp $b }), but also sorting the sub {$a<=>$b} along with what you
want to sort.  "CODE(0x198f04c)" is what you are getting when the sub is
stringified.

In your case the <=> and cmp sorts are the same, but try changing adding
99 and 10 as keys and you will see the problem.

> #!/usr/bin/perl -w
> use strict;
> 
> my $dayentry;
> my $daynum;
> my $dbrow;
> 
> my %dayinfo = (
> 977702400 => [ "Holiday 7",
>"Holiday 8" ],
> 950486400 => [ "Holiday 3" ],
> 946684800 => [ "Holiday 1",
>"Holiday 2" ],
> 954547200 => [ "Holiday 5" ],
> );
> 
> open( DBFILE, ">dbfile1.txt" ) or die("Error: could not open 
> \"dbfile1.txt\"\n" );
> 
> foreach $daynum (sort{$a<=>$b} keys %dayinfo ) {
> $dbrow = "$daynum";
> foreach $dayentry (@{$dayinfo{$daynum}}) {
> $dbrow = join('|',$dbrow,$dayentry);
> }
> # write new data to output file
> print( DBFILE "$dbrow\n" );
> }
> close( DBFILE );
> 
> open( DBFILE, ">dbfile2.txt" ) or die("Error: could not open 
> \"dbfile2.txt\"\n" );
> 
> foreach $daynum (sort(sub{$a<=>$b}, keys %dayinfo)) {
> $dbrow = "$daynum";
> foreach $dayentry (@{$dayinfo{$daynum}}) {
> $dbrow = join('|',$dbrow,$dayentry);
> }
> # write new data to output file
> print( DBFILE "$dbrow\n" );
> }
> close( DBFILE );

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

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




Trying to understand sort and anonymous sub

2004-07-24 Thread Dalton Marris
I am trying to understand the use of "sub" in the second "foreach 
$daynum" loop in the code shown below.  I know it's an anonymous sub, 
but can't figure out why it's needed, if it indeed is.  I have read the 
perlref and perlsub documents, and googled for information, to no avail.

Some things I have noticed regarding the first and second "foreach 
$daynum" loops:

When I step through the first "foreach $daynum" loop with Komodo, it 
seems to hang on the "foreach" as each combination of $a and $b values 
is sorted.  Stepping continues after everything is sorted.  The 
resultant output file contains the following (as expected):

946684800|Holiday 1|Holiday 2
950486400|Holiday 3
954547200|Holiday 5
977702400|Holiday 7|Holiday 8
When stepping through the second "foreach $daynum" loop, it only takes 
one step before it continues on, so it appears to be faster.  However, 
it also results in an extra key, for some reason.  The resultant output 
file contains the following:

946684800|Holiday 1|Holiday 2
950486400|Holiday 3
954547200|Holiday 5
977702400|Holiday 7|Holiday 8
CODE(0x198f04c)
My questions:
(1) What should the "sub" be doing?
(2) Where is the "CODE(0x198f04c)" coming from?
TIA,
Dalton
#!/usr/bin/perl -w
use strict;
my $dayentry;
my $daynum;
my $dbrow;
my %dayinfo = (
977702400 => [ "Holiday 7",
   "Holiday 8" ],
950486400 => [ "Holiday 3" ],
946684800 => [ "Holiday 1",
   "Holiday 2" ],
954547200 => [ "Holiday 5" ],
);
open( DBFILE, ">dbfile1.txt" ) or die("Error: could not open 
\"dbfile1.txt\"\n" );

foreach $daynum (sort{$a<=>$b} keys %dayinfo ) {
$dbrow = "$daynum";
foreach $dayentry (@{$dayinfo{$daynum}}) {
$dbrow = join('|',$dbrow,$dayentry);
}
# write new data to output file
print( DBFILE "$dbrow\n" );
}
close( DBFILE );
open( DBFILE, ">dbfile2.txt" ) or die("Error: could not open 
\"dbfile2.txt\"\n" );

foreach $daynum (sort(sub{$a<=>$b}, keys %dayinfo)) {
$dbrow = "$daynum";
foreach $dayentry (@{$dayinfo{$daynum}}) {
$dbrow = join('|',$dbrow,$dayentry);
}
# write new data to output file
print( DBFILE "$dbrow\n" );
}
close( DBFILE );
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Count the occurence of a character

2004-07-24 Thread John W. Krahn
David Storrs wrote:
On Fri, Jul 23, 2004 at 12:13:48PM +0200, Paul Johnson wrote:
On Fri, Jul 23, 2004 at 03:12:22PM +0530, Jaffer Shaik wrote:
I have the below strig
$str = "abckdweqadidkisdikda";
In the above string, I want to count the occurrences of character 'a',
i.e I should get count of a = 7.
How can i achieve this in Perl.
$count = $str =~ tr/a//;
Note that this modifiees the string.  You might want to do 

 $count = $str =~ tr/a/a/;
instead.
They both modify the string and in fact they both do exactly the same thing.
perldoc perlop
[snip]
   Otherwise, if the REPLACEMENTLIST is
 shorter than the SEARCHLIST, the final character is replicated till
 it is long enough.  If the REPLACEMENTLIST is empty, the SEARCHLIST
 is replicated.  This latter is useful for counting characters in a
 class or for squashing character sequences in a class.

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



Re: Count the occurence of a character

2004-07-24 Thread David Storrs

On Fri, Jul 23, 2004 at 12:13:48PM +0200, Paul Johnson wrote:
> On Fri, Jul 23, 2004 at 03:12:22PM +0530, Jaffer Shaik wrote:
> 
> > I have the below strig
> > 
> > $str = "abckdweqadidkisdikda";
> > 
> > In the above string, I want to count the occurrences of character 'a',
> > i.e I should get count of a = 7.
> > 
> > How can i achieve this in Perl.
> 
> $count = $str =~ tr/a//;

Note that this modifiees the string.  You might want to do 

 $count = $str =~ tr/a/a/;

instead.

--Dks


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