printing from records ?

2002-05-06 Thread Martin A. Hansen

hi

im able to generate records of this kind:


{
  'bleh' => {
  'ISHpix' => [],
  'gelpix' => [],
  'base' => [
  ''
],
  'norm' => [
  ''
],
  'drug' => [
  ''
],
  'organism' => [
  ''
],
  'name' => [
  ''
],
  'cell' => [
  ''
],
  'date' => [
  ''
],
  'tissue' => [
''
  ],
  'quant' => [
   ''
 ],
  'ISH' => [
 ''
   ],
  'bg' => [
''
  ],
  'gel' => [
 ''
   ],
  'primer' => [
''
  ],
  'mt' => [
'bleh'
  ],
  'band' => [
  ''
]
}
}

now, this is very well.

how do i print a specific record?

i would like to be able to check if a record already exist so i dont overwrite it.


:o)

martin

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




Re: printing from records ?

2002-05-06 Thread Felix Geerinckx

on Mon, 06 May 2002 08:32:11 GMT, [EMAIL PROTECTED] (Martin A. Hansen)
wrote: 

> im able to generate records of this kind:
>
my $records = 

> {
>   'bleh' => {
>   'ISHpix' => [],
>   'gelpix' => [],
>   'base' => [
>   ''
>   ],
> [...more keys deleted for brevity...]
>   'mt' => [
> 'bleh'
>   ],
>   'band' => [
>   ''
> ]
> }
> }
> 
> how do i print a specific record?
> 
> i would like to be able to check if a record already exist so i
> dont overwrite it. 

If I understand your datamodel correctly, your first 'bleh' is a 
primary key, and the second-level hash keys are column descriptors.

You can use 

print "key 'bleh' already exists\n" 
if exists $records->{'bleh'};
to check whether a record with a specific primary key already exists.

To print out records, you could use the following subroutine:

print_record($records, 'bleh');

sub print_record {
my $source = shift;
my $key = shift;

return unless exists $source->{$key};
print "Contents of record with primary key $key:\n";
foreach my $field (sort keys %{$source->{$key}}) {
print "\t$field: ";
print "[" . 
  join(", ", @{$source->{$key}{$field}}) . 
  "]\n" ;
}
   print "\n";
return;
}

But I have a question: what is the functional difference between 
"[]" and "['']" in your columns?

-- 
felix

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




To exract data from text file

2002-05-06 Thread en_prashant

I had been assigned a work of extracting data from a text file.The text
file has these datas
193.9.200.123,prashant , ,y,22/04/02,12:09:43, , ,
,http://rediffmail.com.
I have to fetch IP address,uesr name,date,time of log on,site or page
visited.It is the log file created by proxy server to take care about user
onit.
If u would help me i will be thankful to u.
Prashant Mathur


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




Re: To exract data from text file

2002-05-06 Thread Sudarsan Raghavan

Take a look at
perldoc -f open
perldoc -f split


[EMAIL PROTECTED] wrote:

> I had been assigned a work of extracting data from a text file.The text
> file has these datas
> 193.9.200.123,prashant , ,y,22/04/02,12:09:43, , ,
> ,http://rediffmail.com.
> I have to fetch IP address,uesr name,date,time of log on,site or page
> visited.It is the log file created by proxy server to take care about user
> onit.
> If u would help me i will be thankful to u.
> Prashant Mathur
>
> --
> 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: To exract data from text file

2002-05-06 Thread Felix Geerinckx

on Mon, 06 May 2002 09:57:02 GMT, [EMAIL PROTECTED] (En
Prashant) wrote: 

> I had been assigned a work of extracting data from a text file.The
> text file has these datas
> 193.9.200.123,prashant , ,y,22/04/02,12:09:43, , ,
> ,http://rediffmail.com.
> I have to fetch IP address,uesr name,date,time of log on,site or
> page visited.

If you are sure that your data is behaving, you could use:

open FH, "<$yourfile" or die "Cannot open $yourfile: $!";
while () {
my ($ip, $user, $date, $time, $url) = (split /,/)[0,1,4,5,9];
# Do your stuff with the data
}
close FH;

-- 
felix

 


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




Re: printing from records ?

2002-05-06 Thread Martin A. Hansen

hi felix

the exists check works nicely :)

but i cant get the print to work, using my version of your sub:

sub print_record
{
   my ( $record_key ) = @_;
   my $record;
   my $records;

   # read in records
   $records = &read_recordfile;

   foreach $record ( keys %{ $records->{ $record_key } } ) {
  print "debug" . join('', @{ $records->{ $record_key }{ $record } } );
   }

   return $record
}
  
$record_key is passed to the subroutine ok (i did check). and the records are read (i 
did check using Data::Dumper)

> print_record($records, 'bleh');
> 
> sub print_record {
> my $source = shift;
> my $key = shift;
>   
> return unless exists $source->{$key};
> print "Contents of record with primary key $key:\n";
> foreach my $field (sort keys %{$source->{$key}}) {
> print "\t$field: ";
> print "[" . 
>   join(", ", @{$source->{$key}{$field}}) . 
>   "]\n" ;
> }
>  print "\n";
> return;
> }
> 
> But I have a question: what is the functional difference between 
> "[]" and "['']" in your columns?
good question. i have a hash of hashes of arrays. i want to be able, later on, to push 
more values on each secondary hash key - hence the array [''].

martin

> 
> -- 
> felix
> 
> -- 
> 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: To exract data from text file

2002-05-06 Thread bernabe diaz

following your sample If you have only one line in the text file you can 
do as follow:

($ip,$name,$tuff,$stuff,$fecha,$time_log,$junk) = split /,/,$textfile;
print 'The IP address:".$ip."\n";
print "The name:".$name."\n";
.
.
exit;
 OK , I hope it helps you
Bernie Diaz
[EMAIL PROTECTED] wrote:

>I had been assigned a work of extracting data from a text file.The text
>file has these datas
>193.9.200.123,prashant , ,y,22/04/02,12:09:43, , ,
>,http://rediffmail.com.
>I have to fetch IP address,uesr name,date,time of log on,site or page
>visited.It is the log file created by proxy server to take care about user
>onit.
>If u would help me i will be thankful to u.
>Prashant Mathur
>
>



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




Re: printing from records ?

2002-05-06 Thread Felix Geerinckx

on Mon, 06 May 2002 10:21:55 GMT, [EMAIL PROTECTED] (Martin A. Hansen)
wrote: 

> sub print_record
> {
>my ( $record_key ) = @_;
>my $record;
>my $records;
> 
># read in records
>$records = &read_recordfile;
> 
>foreach $record ( keys %{ $records->{ $record_key } } ) {
>   print "debug" . join('', @{ $records->{ $record_key }{
>   $record } } ); 
>}
> 
>return $record
> }

With

sub read_recordfile {
return  { 'bleh' => { a => [1, 2], b => [3, 4]}};
}

print_record('bleh');

I get the following output from your print_record routine, as 
expected:

debug12debug34

If this is what you want, maybe you have an error in your 
read_recordfile?

-- 
felix

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




Re: Quick Database guide

2002-05-06 Thread Felix Geerinckx

on Sun, 05 May 2002 13:29:28 GMT, [EMAIL PROTECTED]
(Arran Ubels) wrote: 

> Can anyone provide a link (or possibly write) a quick start guide
> on databases in perl, i am migrating from Delphi.

See M-J Dominus' "A Short Guide to DBI" at



-- 
felix

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




Re: printing from records ?

2002-05-06 Thread Martin A. Hansen

hi again

im practicing handling structures. im very much a newbie at this so theres prolly 
something wrong with my code.

> If this is what you want, maybe you have an error in your 
> read_recordfile?

sub read_recordfile
{
   my $records;

   {
local ($/) = undef;
open SOURCE, $recordfile or die "Can't open file: $!";
$records = eval ;
die $@ if $@;
close SOURCE;
   }

return $records;
}
  
:-)

martin

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




Re: printing from records ?

2002-05-06 Thread Felix Geerinckx

on Mon, 06 May 2002 10:54:36 GMT, [EMAIL PROTECTED] (Martin A. Hansen)
wrote: 

> sub read_recordfile
> {
>my $records;
> 
>{
> local ($/) = undef;
> open SOURCE, $recordfile or die "Can't open file: $!";
> $records = eval ;
> die $@ if $@;
> close SOURCE;
>}
> 
> return $records;
> }

This looks OK to me. Against your original data, this prints (lines 
wrapped):

debugdebugdebugdebugdebugdebugdebugdebugdebugblehdebugdebug
debugdebugdebugdebugdebugdebug

as expected. (The word 'debug' is printed 17 times, exactly the 
number of subkeys you have.) Note that you cannot expect the subkeys 
to come out in the same order as you put them in your recordfile. 
Hashes by definition have no specific order.

Note that you are only printing values, not keys, and the only value 
you have defined is the 'bleh' of subkey 'mt'. You might want to 
include the (sub)keys themselves, and some newlines in the printout, 
to keep an overview of the situation. 

-- 
felix

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




Re: To exract data from text file

2002-05-06 Thread en_prashant


I haven't a single line .This is a log file which has more than thousands
of line and not each data is of one line it is of two or three lines.The
data is just like

193.9.200.127,prashant , , y,12/04/02,12:09:05, ,http, ,
http://rediffmail.com, , , ,. This line has 23 fields and it may be
possible that the data may exceed the no of lines to three.
Pls reply soon.

Prashant mathur



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




Cut Function

2002-05-06 Thread Zielfelder, Robert

Greetings,

Is there a way to make Perl truncate a single scalar variable by a given
number of characters like the unix cut command can?  For example, I have a
scalar variable that is 7 characters long, but for another purpose I only
want the last 5 characters of this variable.  To do this with the unix cut
command I would issue the following line:

Echo $variable | cut -c3-7

How can this be done in Perl?

Best regards,

Rz



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




Re: Cut Function

2002-05-06 Thread Jeff 'japhy' Pinyan

On May 6, Zielfelder, Robert said:

>Is there a way to make Perl truncate a single scalar variable by a given
>number of characters like the unix cut command can?  For example, I have a
>scalar variable that is 7 characters long, but for another purpose I only
>want the last 5 characters of this variable.  To do this with the unix cut
>command I would issue the following line:
>
>Echo $variable | cut -c3-7

sounds like you want the substr() function.  perldoc -f substr

  $last_5_chars = substr($string, -5);

The cool thing about that is you don't need to worry about the string
length -- whether it be 7 or 100 characters, you'll get the last five.

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
 what does y/// stand for?   why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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




Question Using for loops in incrementations

2002-05-06 Thread Darryl Schnell

Please forgive the stupidity of this question but I'm stumped and need
to get this program finished. I am currently working on a program that
will select information from two databases. The program puts both into
hashes and compares the two lists.

If it finds information in table one but not in table two it is to
perform certain commands to place that user in table two, and vice
versa. I know how to implement this part, however here is my problem. 

Please bear in mind just as a test I am doing print statements.

The Problem.

The two tables are not the same length however my first if statements
will end the process after it reaches the end of the table.

My second and third if's will find the output of the first difference
and then stop. What I need to know is what type of for loop do I need to
continue this program from the beginning instant of the list length on
to the next instances the tell if the user is in the list or not.

The for loops I have now merely prints out a number 3 instead of the
actual username lists. My questions is am I on the right track here with
the for loops? Am I printing the wrong variable? If not does anyone have
any better suggestions?

Thank-You,

 Program Below


#!/usr/local/bin/perl 

use Sybase::DBlib;
use DBI;

# ClienTele Sybase Information

Database & User Name Information Omitted

$i = 0;
$j = 0;

$ctelnew = new Sybase::DBlib $sql_user,$sql_password,$sql_server;
$ctelnew->dbuse ('clientele');
$ctelnew->dbcmd("select EmailName from EmailAccount where AccountNumber
= '012616' "); $ctelnew->dbsqlexec; while ($ctelnew->dbresults !=
NO_MORE_RESULTS) {
  while(@dat = $ctelnew->dbnextrow) {
push @emailname,$dat[0];
  }
}

$dbh = DBI->connect("DBI:mysql:database=$dbase;$dbhost", $dbuser,$dbpw);
$sth = $dbh->prepare("select address from notify_list"); $sth->execute
|| print "Can't execute statement: $DBI::errstr\n"; while (@sub =
$sth->fetchrow_array) {
  $subname = $sub[0];
  ($user,$ext) = split(/@/, $subname);
  push @sub_name,$user;
}
close(SUB);

while ($i <= $#emailname && $j <= $#sub_name) {
  if ($emailname[$i] eq $sub_name[$j]) {
$i++;
$j++;
  } elsif ($emailname[$i] lt $sub_name[$j]) {
foreach ($i=$i;$i <= $#emailname;$i++) {
  print "$i\n";
}
$i++;
  } else {
foreach ($j=$j;$j <= $#sub_name;$j++) {
  print "$j\n";
}
$j++;
  }
}

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




Re: Question Using for loops in incrementations

2002-05-06 Thread Jeff 'japhy' Pinyan

On May 6, Darryl Schnell said:

>Please forgive the stupidity of this question but I'm stumped and need
>to get this program finished. I am currently working on a program that
>will select information from two databases. The program puts both into
>hashes and compares the two lists.

You're not using hashes, you're using arrays.  It's a good thing to get
straight.

>The two tables are not the same length however my first if statements
>will end the process after it reaches the end of the table.

That's because of your conditional:

  while ($i <= $#emailname && $j <= $#sub_name) {

Maybe you want || instead of &&?

Also, why not avoid your arrays altogether, and process one element at a
time?  This might be a good tactic if your database queries return a lot
of data.

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
 what does y/// stand for?   why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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




Re: To exract data from text file

2002-05-06 Thread Felix Geerinckx

on Mon, 06 May 2002 11:01:54 GMT, [EMAIL PROTECTED] (En
Prashant) wrote: 

> 
> I haven't a single line .This is a log file which has more than
> thousands of line and not each data is of one line it is of two or
> three lines.The data is just like

This is hard to believe. Are you sure your text-editor is not wrapping 
the lines?

-- 
felix

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




Re: Question Using for loops in incrementations

2002-05-06 Thread Felix Geerinckx

on Mon, 06 May 2002 12:36:49 GMT, [EMAIL PROTECTED] (Darryl
Schnell) wrote: 

> [...]
> If it finds information in table one but not in table two it is to
> perform certain commands to place that user in table two, and vice
> versa. 
> [...]

Why don't you use hashes to collect your information?

my %emailnames = ();
my %sub_names = ();

Instead of

> push @emailname,$dat[0];

write

  $emailnames{$dat[0]}++;

Instead of 

>   push @sub_name,$user;

write 

$sub_names{$user}++;

Now finding information in table one which is not in table two is 
easy:

foreach my $k (keys %emailnames) {
unless ( exists($sub_names{$k}) ) {
# insert info into table two
}   
}

-- 
felix

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




RE: DBI - selectall_arrayref Help!

2002-05-06 Thread Jason Frisvold

Thanks for the help...  I finally figured that out about 30 minutes
later...  (My message to the list had been sent already, but did not
appear on the list, apparently...  )

Anyways, It's working nicely now...  :)  Thanks...

---
Jason H. Frisvold
Senior ATM Engineer
Engineering Dept.
Penteledata
CCNA Certified - CSCO10151622
[EMAIL PROTECTED]
---
"Imagination is more important than knowledge. Knowledge is limited.
Imagination encircles the world." -- Albert Einstein [1879-1955]


-Original Message-
From: bob ackerman [mailto:[EMAIL PROTECTED]] 
Sent: Saturday, May 04, 2002 2:04 PM
To: [EMAIL PROTECTED]
Subject: Re: DBI - selectall_arrayref Help!


On Friday, May 3, 2002, at 12:39  PM, Jason Frisvold wrote:

> Let's see if I can explain what I'm trying to do before I toss code
> out...  I have a database with several columns of data.  I want to
fetch
> all the pertinent info into a single array of arrays and then work on
> each row of the data individually.  (I don't want to use fetch()
because
> there's no telling how long it will take to crunch the data)
>
> So, here's some "simple" code to look at this...
>
> This is in a separate .pm file...
>
> sub getdata {
>my $self = shift;
>my $value = $_[0];
>
># DBHANDLER is defined elsewhere (and is definitely called) ...
It's
> a MySQL database
>$self->{ARRAYLIST} = $self->{DBHANDLER}->selectall_arrayref("select
> row1, row2, row3 from mydb where somevalue=$value");
>$self->{ARRAYCOUNTER} = 0;
>return();
> }
>
> sub loadrow {
>my $self = shift;
>
>if ((defined($self->{ARRAYLIST})) and ($self->{ARRAYCOUNTER} <
> scalar(@{$self->{ARRAYLIST}}))) {
>   ($self->{ROW1}, $self->{ROW2}, $self->{ROW3} =
> ${$self->{ARRAYLIST}[$self->{ARRAYCOUNTER}]};
>

i think you want to deref the expression on the right into an array, not
a 
scalar:
@{$self->{ARRAYLIST}[$self->{ARRAYCOUNTER}]}

so you can assign elements of the array to your 3 scalar list on the
left

>   $self->{ARRAYCOUNTER}++; # Increment the counter
>   return(1);  # And return a 1 to indicate success
>}
>
>return(0);
> }
>
> And the main program has something along the lines of :
>
> $obj->getdata($somevalue);
> while($obj->loadrow()) {
># do stuff with the data rows
> }
>
> My problem is that it appears that $self->{ROW1}, $self->{ROW2}, and
> $self->{ROW3} are not getting any data placed into them.  In fact,
I've
> been getting this error :
>
> Not a SCALAR reference at
> /usr2/local/graphmon/TrendAnalyzer/ClassThreshold.pm line 78.
>
> I'm not sure how to fix this...  Can anyone give me any pointers on
how
> to make this work?
>
> ---
> Jason H. Frisvold
> Senior ATM Engineer
> Engineering Dept.
> Penteledata
> CCNA Certified - CSCO10151622
> [EMAIL PROTECTED]
> ---
> "I love deadlines.  I especially like the whooshing sound they make as
> they go flying by." -- Douglas Adams [1952-2001]
>
>
>
> --
> 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]




Error message

2002-05-06 Thread Ho, Tony

Hi guys,
Has anybody seen the following message before ?
 
Can't locate object method "connect" via package "DBI" (perhaps you
forgot to load "DBI"?) at ./test.pl line 150
 
I would be most grateful with any advice
Thanks in advance
Tony
 

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




Re: Error message

2002-05-06 Thread Felix Geerinckx

on Mon, 06 May 2002 13:54:48 GMT, [EMAIL PROTECTED] (Tony Ho) 
wrote:

> Hi guys,
> Has anybody seen the following message before ?
>  
> Can't locate object method "connect" via package "DBI" (perhaps you
> forgot to load "DBI"?) at ./test.pl line 150

Yes, a few times :-)
Is there a line

use DBI;

in your program, before the line which gives you the error?
What is on line 150?
Do you get other errors?

-- 
felix

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




RE: data structure

2002-05-06 Thread Bob Showalter

> -Original Message-
> From: drieux [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, May 05, 2002 5:14 PM
> To: [EMAIL PROTECTED]
> Subject: Re: data structure
> 
> On Sunday, May 5, 2002, at 12:17 , Jonathan E. Paton wrote:
> 
> > following is a shorter replacement:
> >
> > print join (" : ", $_->{qw}) . "\n" for @$cfgs;
> 
> I have not been able to get any variant of this to work.
> 

@$_{qw} will work.

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




Sorting problem

2002-05-06 Thread Richard Adams

Hello,
 I've got an array of arrays, and want to sort by the 3rd element of the
subarray. I then want to print out the sorted array, showing the index and
values. E.g.,

@AoA = (
[23.56, 65.2, 12.4],
[13, 56, 87],
[45,876, 23],
etc
)


And then the printout should look like:
1:  87
2:  23
3:  12.4

I've tried 
@sorted = {$a ->[2] <=> $b ->[2]} @AoA but this gives a "cannot
modify.."error.
I've a feeling this is really trivial but have got abit bogged down with
it...
Thanks in advance
Richard

-- 
Dr Richard Adams
Chromosome Structure Group

University of Edinburgh
Kings Buildings,
Mayfield Rd,
Edinburgh
EH9 3JR UK


Email [EMAIL PROTECTED]


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




RE: Sorting problem

2002-05-06 Thread Nikola Janceski

take out the spaces

@sorted = {$a->[2] <=> $b->[2]} @AoA but this gives a "cannot
   ^   ^
No spaces should be here


> -Original Message-
> From: Richard Adams [mailto:[EMAIL PROTECTED]]
> Sent: Monday, May 06, 2002 10:18 AM
> To: [EMAIL PROTECTED]
> Subject: Sorting problem
> 
> 
> Hello,
>  I've got an array of arrays, and want to sort by the 3rd 
> element of the
> subarray. I then want to print out the sorted array, showing 
> the index and
> values. E.g.,
> 
> @AoA = (
> [23.56, 65.2, 12.4],
> [13, 56, 87],
> [45,876, 23],
> etc
> )
> 
> 
> And then the printout should look like:
> 1:  87
> 2:  23
> 3:  12.4
> 
> I've tried 
> @sorted = {$a ->[2] <=> $b ->[2]} @AoA but this gives a "cannot
> modify.."error.
> I've a feeling this is really trivial but have got abit 
> bogged down with
> it...
> Thanks in advance
> Richard
> 
> -- 
> Dr Richard Adams
> Chromosome Structure Group
> 
> University of Edinburgh
> Kings Buildings,
> Mayfield Rd,
> Edinburgh
> EH9 3JR UK
> 
> 
> Email [EMAIL PROTECTED]
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




RE: Sorting problem

2002-05-06 Thread Bob Showalter

> -Original Message-
> From: Richard Adams [mailto:[EMAIL PROTECTED]]
> Sent: Monday, May 06, 2002 10:18 AM
> To: [EMAIL PROTECTED]
> Subject: Sorting problem
> 
> 
> Hello,
>  I've got an array of arrays, and want to sort by the 3rd 
> element of the
> subarray. I then want to print out the sorted array, showing 
> the index and
> values. E.g.,
> 
> @AoA = (
> [23.56, 65.2, 12.4],
> [13, 56, 87],
> [45,876, 23],
> etc
> )
> 
> 
> And then the printout should look like:
> 1:  87
> 2:  23
> 3:  12.4
> 
> I've tried 
> @sorted = {$a ->[2] <=> $b ->[2]} @AoA but this gives a "cannot
> modify.."error.
> I've a feeling this is really trivial but have got abit 
> bogged down with
> it...

You forgot the word sort!

   @sorted = sort {$a->[2] <=> $b->[2]} @AoA;
 

Also, your example output indicates you probably want to
sort in descending order, which would be:

   @sorted = sort {$b->[2] <=> $a->[2]} @AoA;

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




Re: Sorting problem

2002-05-06 Thread Felix Geerinckx

on Mon, 06 May 2002 14:17:39 GMT, [EMAIL PROTECTED] (Richard
Adams) wrote: 

[Please don't retype code - cut and paste instead]

> I've tried 
> @sorted = {$a ->[2] <=> $b ->[2]} @AoA 

You forgot the 'sort' function.
You put spaces before the '->'.
You got the sort order reversed.

Try

my @sorted = sort {$b->[2] <=> $a->[2]} @AoA;

for my $i(0..$#sorted) {
print $i+1, ":\t$sorted[$i][2]\n";
}

-- 
felix

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




Re: Sorting problem

2002-05-06 Thread Michael Lamertz

On Mon, May 06, 2002 at 03:17:39PM +0100, Richard Adams wrote:
> Hello,
>  I've got an array of arrays, and want to sort by the 3rd element of the
> subarray. I then want to print out the sorted array, showing the index and
> values. E.g.,

Hmm, works for me with the exception of...

> I've tried 
> @sorted = {$a ->[2] <=> $b ->[2]} @AoA but this gives a "cannot

there's a 'sort' missing before the block:

-- mostly your code --
#!/usr/bin/perl

use strict;
use warnings;

my @AoA = (
[23.56, 65.2, 12.4],
[13, 56, 87],
[45,876, 23],
);

my @sorted = sort {$a->[2] <=> $b->[2]} @AoA;
print "$_->[2]\n" foreach reverse @sorted;
-- mostly your code --

gives me:

-- snip --
nijushiho:/tmp$ perl x.pl
87
23
12.4
nijushiho:/tmp$ 
-- snip --

-- 
   If we fail, we will lose the war.

Michael Lamertz|  +49 221 445420 / +49 171 6900 310
Nordstr. 49|   [EMAIL PROTECTED]
50733 Cologne  | http://www.lamertz.net
Germany|   http://www.perl-ronin.de 

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




Re: Sorting problem

2002-05-06 Thread Richard Adams

Thanks for all your help...I just forgot the sort in my post...

The reason it wasn't working wasn't the sort, it was just that $AoA[0] was
undefined..
But sort {$a->[2] <=> $b->[2]} @AoA[1..$#AoA] works just fine.
Thanks again!


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




use strict

2002-05-06 Thread Jason Frisvold

I have a question about 'use strict'  ...  Yeah, I guess this counts as
a "duh!" question...  :-)

I put 'use strict' at the beginning of one of my scripts...  It
basically "broke" the script...  (or fixed it, if you want to look at it
that way)   The problem is that it wanted explicit package names for
all of the globals...

So, what is the proper way to handle a global?  Do I 'my' all the
globals in the program?

---
Jason H. Frisvold
Senior ATM Engineer
Engineering Dept.
Penteledata
CCNA Certified - CSCO10151622
[EMAIL PROTECTED]
---
"I love deadlines.  I especially like the whooshing sound they make as
they go flying by." -- Douglas Adams [1952-2001]





Re: use strict

2002-05-06 Thread Jeff 'japhy' Pinyan

On May 6, Jason Frisvold said:

>I put 'use strict' at the beginning of one of my scripts...  It
>basically "broke" the script...  (or fixed it, if you want to look at it
>that way)   The problem is that it wanted explicit package names for
>all of the globals...
>
>So, what is the proper way to handle a global?  Do I 'my' all the
>globals in the program?

Globals can cause problems.  It's safer to use properly scoped lexicals.

The general answer is declare all your variables with 'my', and then fix
any scope issues that appear.

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
 what does y/// stand for?   why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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




RE: use strict

2002-05-06 Thread Nikola Janceski

I am going to try to answer this one, (I think I understand it):

use strict;

package Foo;
my $var1;
our $var2;

package Bar;

$Foo::var1; # this how you call var1 from package Foo;
$var2; # this how you call var2 (our makes it global across packages [and
modules?]) [our == use vars qw()]

__END__

so yes you must initialize any global vars.

Any corrections? (I am not that great, I know I probably made a mistake).


> -Original Message-
> From: Jason Frisvold [mailto:[EMAIL PROTECTED]]
> Sent: Monday, May 06, 2002 11:19 AM
> To: [EMAIL PROTECTED]
> Subject: use strict
> 
> 
> I have a question about 'use strict'  ...  Yeah, I guess this 
> counts as
> a "duh!" question...  :-)
> 
> I put 'use strict' at the beginning of one of my scripts...  It
> basically "broke" the script...  (or fixed it, if you want to 
> look at it
> that way)   The problem is that it wanted explicit 
> package names for
> all of the globals...
> 
> So, what is the proper way to handle a global?  Do I 'my' all the
> globals in the program?
> 
> ---
> Jason H. Frisvold
> Senior ATM Engineer
> Engineering Dept.
> Penteledata
> CCNA Certified - CSCO10151622
> [EMAIL PROTECTED]
> ---
> "I love deadlines.  I especially like the whooshing sound they make as
> they go flying by." -- Douglas Adams [1952-2001]
> 
> 
> 



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




RE: use strict

2002-05-06 Thread Bob Showalter

> -Original Message-
> From: Jason Frisvold [mailto:[EMAIL PROTECTED]]
> Sent: Monday, May 06, 2002 11:19 AM
> To: [EMAIL PROTECTED]
> Subject: use strict
> 
> 
> I have a question about 'use strict'  ...  Yeah, I guess this 
> counts as
> a "duh!" question...  :-)
> 
> I put 'use strict' at the beginning of one of my scripts...  It
> basically "broke" the script...  (or fixed it, if you want to 
> look at it
> that way)   The problem is that it wanted explicit 
> package names for
> all of the globals...
> 
> So, what is the proper way to handle a global?  Do I 'my' all the
> globals in the program?

probably, yes.

"use strict" is there to help you catch typos, by forcing you to
either declare all variables or use explicit package names.

Generally you will want to declare your globals with "my" at the
top of your script. This creates file-scoped lexicals, which are
similar to globals in terms of visibility, but do not live in the
symbol table.

If you really need symbol table (i.e. "package") variables, then 
use "our" instead of "my". The main reason you would need a package
variable is if the variable needs to be accessed from another
file or module directly, instead of being passed as an argument.

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




Re: Sorting problem-part2

2002-05-06 Thread Richard Adams

Now I've got an array of hashes, where each hash can have  different keys
e.g.,

@aoh = ( {H3 =>234, H1 =>127, DNA =>1, p135 =>167},
{H4=>24,  H3=>1550, DNA =>25, p39 =>67},
{H3 =>34, H2A =>125, DNA =>5, p32 =>7},
{H3 =>24, H4 =>156, DNA =>123, p12 =>13}
) 
And I'd like to order the array elements by virtue of the biggest value in
the hash. 

1. H3 1550
2. H3 234
3. H4 156
4. H2A 125

Is there a quick one liner for this or do I need to find the max in each
hash, store them in an array, and then sort the "array of hash maxima"
separately, while maintaining the key/value associations?

Thanks a lot for any suggestions!
Richard


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




RE: rmtree

2002-05-06 Thread David Gray

> I have a directory "Abs" with a file "abc" in it.
> I am using rmtree to rm this dir as follows
> 
> use File::Path;
> rmtree("Abs",1,1) or die "dir not del";
> print "done";
> 
> 
> The output is
> 
> unlink ../htdocs/store/newpages/Abstract/abc
> 
> 
> It neither prints the die statement nor the done - ofcourse 
> it doesn't 
> actually delete the file and the dir at all.

You might want to try putting a hard return in your die to make sure it
flushes (even if that's not the problem, it's a good habit), and also
checking the actual error message, like so:

my $dir = 'Abs';
rmtree("$dir",1,1) or die "couldn't rmtree [$dir]: $!\n";

HTH,

 -dave



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




Re: data structure

2002-05-06 Thread Chas Owens

On Sun, 2002-05-05 at 18:47, drieux wrote:
> 
> On Sunday, May 5, 2002, at 03:07 , Jonathan E. Paton wrote:
> [..]
> > print join (" ", @hash{qw});
> 
> sick, but it works

No, this is sick:

#array interpolation uses ' ' to join
print "@hash{qw}\n"; 


> 
> > Appears the array symbol is required, and probably the above would need to
> > be changed to:
> >
> > print join (" : ", @{%$_}->{qw}) . "\n" for @$cfgs;
> 
> One Clump over the line - needed to be:
> 
> print join (" : ", @{$_}{qw}) . "\n" for @$cfgs;

Which makes this:

{
local $" = ' : ';
print "@{$_}{qw}\n" for @$cfgs;
}

or better yet

our @fields = qw(dir tpl ext rgx);
..
..
..
{
local $" = ' : ';
print "@{$_}{@fields}\n" for @$cfgs;
}

> 
> since:
>   $cfgs = $tplCfg{'category1'}{'cat1type1'};
> 
> pulls out
> 
>  [
>  {
>  dir =>  "cat1type1dir1",
>  tpl =>  "cat1type1tpl1",
>  ext =>  "cat1type1ext1",
>  rgx =>  "cat1type1rgx1",
>  },
>  ],
> 
> which is an array of hashes - hence $_ is itself a reference
> to the autonomous hash
> 
> hence since we are playing the
> 
>   @hash{@keys_oh_hash};
> 
> game we don't want to get that confused with the "->" component
> 
> 
>http://www.wetware.com/drieux/CS/lang/Perl/Beginners/BenchMarks/complexArrayHash_v_loop.
> txt
> 
> for the details on the comparison
> 
> looks like the double loop is faster but it may not be
> in some other configuration of data...
> 
> ciao
> drieux
> 
> ---
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
-- 
Today is Sweetmorn the 53rd day of Discord in the YOLD 3168
Or not.

Missile Address: 33:48:3.521N  84:23:34.786W


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




RE: use strict

2002-05-06 Thread Jason Frisvold

Actually, I'm not writing a package, per se, here...  (I do use 'use
strict' in my packages) ...  This is the main program that I'm writing
in which I use globals...  I'll start playing with the use strict stuff
in my main program since that appears to be the "proper" way to do
things...  :)

---
Jason H. Frisvold
Senior ATM Engineer
Engineering Dept.
Penteledata
CCNA Certified - CSCO10151622
[EMAIL PROTECTED]
---
"Imagination is more important than knowledge. Knowledge is limited.
Imagination encircles the world." -- Albert Einstein [1879-1955]


-Original Message-
From: Bob Showalter [mailto:[EMAIL PROTECTED]] 
Sent: Monday, May 06, 2002 11:34 AM
To: Jason Frisvold; [EMAIL PROTECTED]
Subject: RE: use strict

> -Original Message-
> From: Jason Frisvold [mailto:[EMAIL PROTECTED]]
> Sent: Monday, May 06, 2002 11:19 AM
> To: [EMAIL PROTECTED]
> Subject: use strict
> 
> 
> I have a question about 'use strict'  ...  Yeah, I guess this 
> counts as
> a "duh!" question...  :-)
> 
> I put 'use strict' at the beginning of one of my scripts...  It
> basically "broke" the script...  (or fixed it, if you want to 
> look at it
> that way)   The problem is that it wanted explicit 
> package names for
> all of the globals...
> 
> So, what is the proper way to handle a global?  Do I 'my' all the
> globals in the program?

probably, yes.

"use strict" is there to help you catch typos, by forcing you to
either declare all variables or use explicit package names.

Generally you will want to declare your globals with "my" at the
top of your script. This creates file-scoped lexicals, which are
similar to globals in terms of visibility, but do not live in the
symbol table.

If you really need symbol table (i.e. "package") variables, then 
use "our" instead of "my". The main reason you would need a package
variable is if the variable needs to be accessed from another
file or module directly, instead of being passed as an argument.

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




Re: data structure

2002-05-06 Thread drieux


On Sunday, May 5, 2002, at 11:24 , Jonathan E. Paton wrote:
>>
>> 
>http://www.wetware.com/drieux/CS/lang/Perl/Beginners/BenchMarks/complexArrayHash_v_loop.
>> txt
>>
>> for the details on the comparison
>>
>> looks like the double loop is faster but it may not be
>> in some other configuration of data...
>
> The dereference is probably wasting cycles, why not bring that outside 
> the loop and save some time.  I suspect that puts the double loop even 
> further ahead.

Benchmark: timing 100 iterations of doubleLoop, dullWay, pushList...
doubleLoop:  242130.75/s (n=100) # $hash->{key}
dullWay:  238663.48/s (n=100) # $hash{$key}

which is not what I had expected

ciao
drieux

---


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




RE: A very beginner

2002-05-06 Thread David Gray

Good Lord, you're gonna scare away the beginners who have questions
about perl!


> > Hi,
> > I'm a beginner that doesn't even have perl yet.
> > I woul like to know whether Perl is faster or Java for business 
> > applications.
> 
> Paul has already provided the correct Party Line from the 
> typical Perl Advocate. So I'll be stuck trying to defend the 
> grey beards position.
> 
> As for KH's variation on the theme, now we start to move 
> towards the place where we have some parameters to really work with.
> 
> To save some space I will try to 'speak in uri' -
> 
> One of the places I have been ranting on this is:
> 
>   http://www.wetware.com/drieux/CS/SoftEng/GP/funcOrNotFunc.html
> 
> Where I discuss the matters of "code reuse" - the OO process 
> by means of 'class/sub_class' - in Proceduralist languages 
> this is the library - in Perl it is the Module - the problem 
> in perl is that the perl5 OO implementation is not as good as 
> it can be, perl6 may 'solve all of that' - and we will see at 
> what costs.
> 
> If you want to be way trendy then you of course want to be 
> looking at the Objective Caml Language:
> 
>   cf: http://www.ocaml.org/
> 
> Since this is a language where first order functionality 
> exists and it allows for the use of OO in the few possible 
> edge cases where that may actually have some 'requiredNeff'.
> 
> Assuming that one were truly seeking 'ubiquity' for 'human 
> interface' then of course one has already come to understand 
> that one is either going to be writing CGI or mod_perl and/or 
> apache modules - since of course no 'real Operating System' 
> can exist but that it is fully integrated into a webBrowser. 
> { and we thought the emacs folks were a bit over the edge. } 
> At which point one is really talking in terms of what 
> specific type of Tomcat Servlet v. mod_perl v. apache module 
> were you really planning to write
> 
> { old guys of course will be thinking in terms of Perl/Tk - 
> because they do not understand that Operating Systems that 
> are not a part of a webBrowser are passe and still have 
> this irrational belief that there were kernels that were not 
> browser plug-ins. }
> 
> { for those of you new to writing device drivers - please, do 
> not assume that simply because your VB based device driver 
> allowed you to use 'standard IO' reads of flat files for 
> configurations - that this will allowed in an adult Operating 
> System - and no, you can not put 'printf()' or 'fprintf()' 
> statements in to do your kernel debugging. Nope - Not an option. }
> 
> As for the specific question of Large Database - we of course 
> must pause and ask whether or not the system is a 'data 
> mining' project where it will be used for secondary 'decision 
> matrix analysis' - and speed is not the issue - or are we 
> talking in terms of an OLTP - at which point the real 
> question is who is doing the database design and shielding 
> the running daemons from the DB itself by doing the 
> appropriate "stored procedures" and transaction abstractions 
> - at which point we're also wondering why you want to do the 
> API to that in anything but 'c' because you really want to 
> have the most portable 'assembler code' processing system 
> that works from statically linked compile time code re-use - 
> because you are not at all interested in engaging in the 
> run-time dynamically loadable link level library hassles of 
> version skew as the libfoo.2.so really is not backwardly 
> compatible with the libfoo.1.so and you are not too sure how 
> to fully back out all of the code that needs to use the old 
> form since the process installed them as
> 
>   libfoo.so -> libfoo..so
> 
> and there can only be ONE!
> 
> At which point we could get into the discussions about 
> whether polymorphism is a good idea, as well as whether or 
> not java - which expressly avoids multiple class inheritance 
> - fully got away from all of that with the 'implements' that 
> allows the maze of twisty little passages as you find that 
> there are 'structural' issues getting the extends stuff to 
> work and play well with the implements stuff
> 
> We should of course write up the problems associated with the 
> whole process of 'kargo kulting' - In which the blind pass 
> along what they heard to help the deaf find a way to smell a 
> fart... Which has more to do with whether or not you 
> personally should be wearing the trendy T-shirt that says:
> 
>   "WARNING: does not work and play well with others."
> 
> Especially if you keep hacking out work arounds for what the 
> 'realCoders[tm]'
> were supposedly 'developing' and finding that this is so much 
> more pathetically stoopidly implemented and maintained in 
> perl than in one of those 'real coding languages' that are 
> the topic of hotBuzz.
> 
> Hence - just as you should have learned at least one 
> assembler language to know why you write that stuff in 'c' - 
> you need to know Perl so that you know w

foreach, my, and arrays

2002-05-06 Thread Jason Frisvold

Here's another simple question  I have an array of arrays and I want
to use a foreach to do something with each entry...  currently I do this
:

foreach my $item (@myarray) {
my ($item1, $item2) = @$item;

}

Is there a way to combine the first 2 lines?  Is it any faster and less
memory intensive?  (granted it's not much now, but hey, I like
optimizing things to death...)

Something along the lines of :

foreach my ($item1, $item2) (@myarray) {

}

That doesn't seem to work for me, so I'm at a loss as to how to do
this...

Thanks,

---
Jason H. Frisvold
Senior ATM Engineer
Engineering Dept.
Penteledata
CCNA Certified - CSCO10151622
[EMAIL PROTECTED]
---
"I love deadlines.  I especially like the whooshing sound they make as
they go flying by." -- Douglas Adams [1952-2001]





RE: Running PubDrills - Re: dynamic variable declaration?

2002-05-06 Thread David Gray

> > To appease the powers that be, does anyone know if you can bind 
> > columns to a hash:
> >
> > i.e. $sth->bind_columns(undef,\$val{a},\$val{b},\$val{c}); # ?

> All of which leaves me scritching my head as to why that would be
> a case of 'dynamic variable declaration'

If I didn't ask a question whose answer would provide an alternative to
the dynamic variable solution, that wouldn't be very open-minded, now
would it? ;)

Don't ask, don't tell.

 -dave



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




RE: Sorting problem-part2

2002-05-06 Thread David Gray

> Now I've got an array of hashes, where each hash can have  
> different keys e.g.,
> 
> @aoh = ( {H3 =>234, H1 =>127, DNA =>1, p135 =>167},
> {H4=>24,  H3=>1550, DNA =>25, p39 =>67},
> {H3 =>34, H2A =>125, DNA =>5, p32 =>7},
> {H3 =>24, H4 =>156, DNA =>123, p12 =>13}
> ) 
> And I'd like to order the array elements by virtue of the 
> biggest value in the hash. 
> 
> 1. H3 1550
> 2. H3 234
> 3. H4 156
> 4. H2A 125
> 
> Is there a quick one liner for this or do I need to find 
> the max in each hash, store them in an array, and then sort 
> the "array of hash maxima" separately, while maintaining the 
> key/value associations?

perldoc -q "sort a hash"

 -dave



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




Re: data structure

2002-05-06 Thread Jonathan E. Paton

> >> 
>http://www.wetware.com/drieux/CS/lang/Perl/Beginners/BenchMarks/complexArrayHash_v_loop.
> >> txt
> >>
> >> for the details on the comparison
> >>
> >> looks like the double loop is faster but it may not be
> >> in some other configuration of data...
> >
> > The dereference is probably wasting cycles, why not bring that outside 
> > the loop and save some time.  I suspect that puts the double loop even 
> > further ahead.
> 
> Benchmark: timing 100 iterations of doubleLoop, dullWay, pushList...
> doubleLoop:  242130.75/s (n=100) # $hash->{key}
> dullWay:  238663.48/s (n=100) # $hash{$key}
> 
> which is not what I had expected

You sure about that?  Seems very counter-intutive, you did remember that
deferencing should save clock cycles when in a loop.  E.g.

my %hash = %{ $hash };
print $hash{$_} for 0..1000;

Unless, of course, that the -> case is optimised in some devious way or
dereferencing is deliberately crippled for our enjoyment.  use Benchmark

Jonathan Paton

__
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

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




Re: A very beginner

2002-05-06 Thread drieux


On Monday, May 6, 2002, at 09:07 , David Gray wrote:

> Good Lord, you're gonna scare away the beginners who have questions
> about perl!

my apologies - that was clearly not my intentions

Rather it was to re-assure those who are new to perl that
yes all the generalized rules about how one should do
software development still apply to Perl - and that perl
hauls along a whole lot of support to make it possible
in more than one way

I was responding to folks who are not new, or so they
alledged, to the general software development cycle, hence
had aimed my response to that general level

Again, was not meaning to scare anyone .


ciao
drieux

---


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




Re: foreach, my, and arrays

2002-05-06 Thread Michael Lamertz

On Mon, May 06, 2002 at 12:04:14PM -0400, Jason Frisvold wrote:
> Here's another simple question  I have an array of arrays and I want
> to use a foreach to do something with each entry...  currently I do this
> :
> 
> foreach my $item (@myarray) {
>   my ($item1, $item2) = @$item;
>   
> }
> 
> Is there a way to combine the first 2 lines?  Is it any faster and less
> memory intensive?  (granted it's not much now, but hey, I like
> optimizing things to death...)
> 
> Something along the lines of :
> 
> foreach my ($item1, $item2) (@myarray) {
>   
> }

Now, You are a very nasty person :-)

Nope, at least by my knowledge that's not possible, but advocating to
find the balance between readability and shortness you're left with

a. accessing

$item->[0], $item->[1]

   for very short loops without repetitive use if $item->[nn]

b. using what you already do

my ($item1, $item2) = @$item

   but - ignoring the fact that you probably just normalized your
   problem - you should use more specific names like

my ($name, $id) = @user_info;

   for longer functions

Since you're thinking about that way of shortening your code, I guess
you're a more or less experienced programmer that is used to - and not
afraid of - using the language's idioms.  So consider above reply as a
guide for the *real* beginners and not necessary for you.  :-)

-- 
   If we fail, we will lose the war.

Michael Lamertz|  +49 221 445420 / +49 171 6900 310
Nordstr. 49|   [EMAIL PROTECTED]
50733 Cologne  | http://www.lamertz.net
Germany|   http://www.perl-ronin.de 

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




Re: foreach, my, and arrays

2002-05-06 Thread Dave K

Jason,
Play with the script below:
my @a1 = qw( one ace );
my @a2 = qw( two deuce );
my @a3 = qw( thr tri );
my @a4 = qw( fou quad );
my @a5 = qw( fiv quat );
my @myarray = (\@a1, \@a2, \@a3, \@a4, \@a5);
foreach my $item (@myarray) {
   my($item1, $item2) = @$item;
   print "$item1 and $item2\n";
}
my @item;
foreach ( @myarray ) {
   print "$$_[0] and $$_[1]\n";
}

"Jason Frisvold" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
Here's another simple question  I have an array of arrays and I want
to use a foreach to do something with each entry...  currently I do this
:

foreach my $item (@myarray) {
my ($item1, $item2) = @$item;

}

Is there a way to combine the first 2 lines?  Is it any faster and less
memory intensive?  (granted it's not much now, but hey, I like
optimizing things to death...)

Something along the lines of :

foreach my ($item1, $item2) (@myarray) {

}

That doesn't seem to work for me, so I'm at a loss as to how to do
this...

Thanks,

---
Jason H. Frisvold
Senior ATM Engineer
Engineering Dept.
Penteledata
CCNA Certified - CSCO10151622
[EMAIL PROTECTED]
---
"I love deadlines.  I especially like the whooshing sound they make as
they go flying by." -- Douglas Adams [1952-2001]






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




RE: foreach, my, and arrays

2002-05-06 Thread Jason Frisvold

Yeah, I thought of doing it that way too  However, my purpose was to
skip the "unnecessary" step and pump the data right into variables.
This way I "drop" the memory needed to go that extra step and I retain
readability of code...

I can live with it the way it is now, I guess...  Just one of those
things I like to try to optimize... :)

---
Jason H. Frisvold
Senior ATM Engineer
Engineering Dept.
Penteledata
CCNA Certified - CSCO10151622
[EMAIL PROTECTED]
---
"Imagination is more important than knowledge. Knowledge is limited.
Imagination encircles the world." -- Albert Einstein [1879-1955]


-Original Message-
From: Dave K [mailto:[EMAIL PROTECTED]] 
Sent: Monday, May 06, 2002 12:41 PM
To: [EMAIL PROTECTED]
Subject: Re: foreach, my, and arrays

Jason,
Play with the script below:
my @a1 = qw( one ace );
my @a2 = qw( two deuce );
my @a3 = qw( thr tri );
my @a4 = qw( fou quad );
my @a5 = qw( fiv quat );
my @myarray = (\@a1, \@a2, \@a3, \@a4, \@a5);
foreach my $item (@myarray) {
   my($item1, $item2) = @$item;
   print "$item1 and $item2\n";
}
my @item;
foreach ( @myarray ) {
   print "$$_[0] and $$_[1]\n";
}

"Jason Frisvold" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
Here's another simple question  I have an array of arrays and I want
to use a foreach to do something with each entry...  currently I do this
:

foreach my $item (@myarray) {
my ($item1, $item2) = @$item;

}

Is there a way to combine the first 2 lines?  Is it any faster and less
memory intensive?  (granted it's not much now, but hey, I like
optimizing things to death...)

Something along the lines of :

foreach my ($item1, $item2) (@myarray) {

}

That doesn't seem to work for me, so I'm at a loss as to how to do
this...

Thanks,

---
Jason H. Frisvold
Senior ATM Engineer
Engineering Dept.
Penteledata
CCNA Certified - CSCO10151622
[EMAIL PROTECTED]
---
"I love deadlines.  I especially like the whooshing sound they make as
they go flying by." -- Douglas Adams [1952-2001]






-- 
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: foreach, my, and arrays

2002-05-06 Thread Chas Owens

On Mon, 2002-05-06 at 12:04, Jason Frisvold wrote:
> Here's another simple question  I have an array of arrays and I want
> to use a foreach to do something with each entry...  currently I do this
> :
> 
> foreach my $item (@myarray) {
>   my ($item1, $item2) = @$item;
>   
> }
> 
> Is there a way to combine the first 2 lines?  Is it any faster and less
> memory intensive?  (granted it's not much now, but hey, I like
> optimizing things to death...)


Since you seem interested in having named variables instead of indexes
into an array you may be better served by an array of hashes.  The code
would look like this:

my @myarray = (
{
count => 10,
type  => 'apple'
},
{
count => 5,
type  => 'oranges'
}
);

foreach my $item (@myarray) {
print "The are $item->{'count'} $item->{'type'}(s)\n";
}
 
-- 
Today is Sweetmorn the 53rd day of Discord in the YOLD 3168
Umlaut Zebra über alles!

Missile Address: 33:48:3.521N  84:23:34.786W


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




Re: Sorting problem-part2

2002-05-06 Thread Michael Lamertz

On Mon, May 06, 2002 at 12:22:15PM -0400, David Gray wrote:
> > Now I've got an array of hashes, where each hash can have  
> > different keys e.g.,
> > 
> > @aoh = ( {H3 =>234, H1 =>127, DNA =>1, p135 =>167},
> > {H4=>24,  H3=>1550, DNA =>25, p39 =>67},
> > {H3 =>34, H2A =>125, DNA =>5, p32 =>7},
> > {H3 =>24, H4 =>156, DNA =>123, p12 =>13}
> > ) 
> > And I'd like to order the array elements by virtue of the 
> > biggest value in the hash. 



> perldoc -q "sort a hash"

Nope, he's looking for a *nested* sort, since he has to find the largest
value 'values %$a' and 'values %$b'.

And as a nice addon, he mentions that the keys of the hashes can vary.

-- 
   If we fail, we will lose the war.

Michael Lamertz|  +49 221 445420 / +49 171 6900 310
Nordstr. 49|   [EMAIL PROTECTED]
50733 Cologne  | http://www.lamertz.net
Germany|   http://www.perl-ronin.de 

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




make test of Text::Reflow

2002-05-06 Thread Deb

Hello,

I installed perl module Text::Reflow on perl v5.6.1 for Solaris.

It built fine, but "make test" fails in that it hangs on the 
first test.  

cpan> test Text::Reflow
Running test for module Text::Reflow
Running make for M/MW/MWARD/Text-Reflow-1.04.tar.gz
  Is already unwrapped into directory /usr/local/cpan/build/Text-Reflow-1.04
  Has already been processed within this session
Running make test
Use of uninitialized value in scalar assignment at 
/usr/local/pkg/perl-5.6.1/lib/5.6.1/CPAN.pm line 4658.
Use of uninitialized value in hash dereference at 
/usr/local/pkg/perl-5.6.1/lib/5.6.1/CPAN.pm line 801.
PERL_DL_NONLAZY=1 /usr/local/pkg/perl-5.6.1/bin/perl -Iblib/arch -Iblib/lib 
-I/usr/local/pkg/perl-5.6.1/lib/5.6.1/sun4-solaris 
-I/usr/local/pkg/perl-5.6.1/lib/5.6.1 test.pl
1..20
ok 1
^C  /usr/ccs/bin/make test -- NOT OK


I don't know how to troubleshoot this, and find out wherein lies
the problem.  Any and all help would be appreciated, or even
pointers to the appropriate email list(s).

Thanks,

deb

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




[OT] Re: Serious problem with perl -pi -e

2002-05-06 Thread Shawn

Setting this variable will be helpful, and will make the FS behave more
like a std unix one. It will support things like sticky bit, 000 perms,
etc etc by mapping NTFS acl stuff.

However, the cygwin files you have in your system, after setting this,
will be like rwxrwxrwx.

This is because when your files were created, and when their permissions
were set, ACL mapping was not being done, and the NTFS acls were not
set.

You know, anyone on your system as it is can just do 
'export CYGWIN=ntsec' and enjoy practically full access to your box even
if this variable is not set at the system level, so you might as well do
it and fix what you can.

On 05/06, Sharan Hiremath said something like:
> Thanks a log Shawn,
> 
> But setting of this variable, now (after installation), will it be helpful.
> 
> Thanks and Regards
> Sharan Hiremath.
> 
--
Shawn Leas
[EMAIL PROTECTED]

I saw a man with a wooden leg, and a real foot.
-- Stephen Wright

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




Re: make test of Text::Reflow

2002-05-06 Thread Jonathan E. Paton

 --- Deb <[EMAIL PROTECTED]> wrote:
> Hello,

Hiya!

> I installed perl module Text::Reflow on perl v5.6.1 for Solaris.
>
> It built fine, but "make test" fails in that it hangs on the 
> first test.  

Okay, try again... does it still fail?  If yes, then download the
module manually and follow the install instructions.  If it still
fails the problem is with Text::Reflow, otherwise it is the CPAN
module.

Whichever it is, you can use 'rt.cpan.org' to submit a bug report...
and the information you gave below is probably enough to make them
happy.  Try upgrading CPAN before you do, but with Perl 5.6.1 you
shouldn't have to.  Include any platform information as well.

If you have spare time, try using the CPANPLUS module instead.  It
was announced on 'www.perl.com' recently.

Jonathan Paton

__
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

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




Re: make test of Text::Reflow

2002-05-06 Thread Deb

Meanwhile, =?iso-8859-1?q?Jonathan=20E.=20Paton?= says:
| 
|  --- Deb <[EMAIL PROTECTED]> wrote:
| > Hello,
| 
| Hiya!

:-)  Thanks for the swift reply.

| > I installed perl module Text::Reflow on perl v5.6.1 for Solaris.
| >
| > It built fine, but "make test" fails in that it hangs on the 
| > first test.  
| 
| Okay, try again... does it still fail?  If yes, then download the
| module manually and follow the install instructions.  

Did this.  Same results.

| If it still
| fails the problem is with Text::Reflow, otherwise it is the CPAN
| module.

Well, not quite.  New wrinkle, on another system running 5.6.1,
same Solaris (5.7), make test runs just fine:

cpan> test Text::Reflow
Running test for module Text::Reflow
Running make for M/MW/MWARD/Text-Reflow-1.04.tar.gz
  Is already unwrapped into directory /home/deb/.cpan/build/Text-Reflow-1.04
  Has already been processed within this session
Running make test
Use of uninitialized value in scalar assignment at /usr/local/lib/perl5/5.6.1/CPAN.pm 
line 4658.
Use of uninitialized value in hash dereference at /usr/local/lib/perl5/5.6.1/CPAN.pm 
line 801.
PERL_DL_NONLAZY=1 /bin/perl -Iblib/arch -Iblib/lib 
-I/usr/local/lib/perl5/5.6.1/sun4-solaris -I/usr/local/lib/perl5/5.6.1 test.pl
1..20
ok 1
ok 2
ok 3
ok 4
ok 5
ok 6
ok 7
ok 8
ok 9
ok 10
ok 11
ok 12
ok 13
ok 14
ok 15
ok 16
ok 17
ok 18
ok 19
ok 20
  /usr/ccs/bin/make test -- OK

| Whichever it is, you can use 'rt.cpan.org' to submit a bug report...
| and the information you gave below is probably enough to make them

Okay, can do.

| happy.  Try upgrading CPAN before you do, but with Perl 5.6.1 you
| shouldn't have to.  Include any platform information as well.

I just upgraded recently to 1.60.
 
| If you have spare time, try using the CPANPLUS module instead.  It
| was announced on 'www.perl.com' recently.

I'll try anything at this point.  HOWEVER, I would still like to 
be able to troubleshooot this.  But, I'm having heck of a time getting
anywhere.
 
| Jonathan Paton

deb
 
| __
| Do You Yahoo!?

Me?  No never...

| Everything you'll ever need on one web page

| from News and Sport to Email and Music Charts
| http://uk.my.yahoo.com
| 
| -- 
| To unsubscribe, e-mail: [EMAIL PROTECTED]
| For additional commands, e-mail: [EMAIL PROTECTED]
| 
| 

"If it dies, it's biology.  If it blows up, it's chemistry,
and if it doesn't work, it's physics."
 -- University bathroom graffito
ô¿ô
 ~ 

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




Unique list

2002-05-06 Thread Lance Prais

I would like to create a unique list.  For example, I have two separate
lists of solution ids and there is the potential of over lapping results.
How would I best eliminate the duplicates and have a unique list of results.
Does anyone have an example of some code they used to do this?

I am trying to use the following code but is not working, just hoping
someone has a better way to do this.
sub createUniquePartitionFile {
my %args = (
PARTITION => '',
PARTITIONFILE => '',
OUTPUTFILENAME => '',
@_,
);
$status = 0;
$partitionFile = $args{PARTITIONFILE};
$outputFileName = $args{OUTPUTFILENAME};
# Message
print "topten: Creating a unique solution file for [$partition].\n";
# Remove existing output file
$command_string = "/usr/bin/rm -f " . $outputFileName;
$status = `$command_string`;

$command_string = "sort -u " . $partitionFile . " \> " . $outputFileName;
$status = `$command_string`;

return  $status;
}

Thank you in advance


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




Re: Sorting problem-part2

2002-05-06 Thread Michael Lamertz

Took me some time, but...

On Mon, May 06, 2002 at 04:41:03PM +0100, Richard Adams wrote:
> Now I've got an array of hashes, where each hash can have  different keys
> e.g.,
> 
> @aoh = ( {H3 =>234, H1 =>127, DNA =>1, p135 =>167},
> {H4=>24,  H3=>1550, DNA =>25, p39 =>67},
> {H3 =>34, H2A =>125, DNA =>5, p32 =>7},
> {H3 =>24, H4 =>156, DNA =>123, p12 =>13}
> ) 
> And I'd like to order the array elements by virtue of the biggest value in
> the hash. 
> 
> 1. H3 1550
> 2. H3 234
> 3. H4 156
> 4. H2A 125

I'll call it the "Partial Schwartzian Transformation on Acid" ;-)

Ok, ok, two messages ago I called Jason Friswold evil, but I just
couldn't resist.  >:->


So, this one's not for the faint of heart (tm), and for educational
purposes only:

-- snip --
#!/usr/bin/perl

use strict;
use warnings;
use Data::Dumper;

my @aoh = (
{H3 =>234, H1 =>127, DNA =>1, p135 =>167},
{H4=>24,  H3=>1550, DNA =>25, p39 =>67},
{H3 =>34, H2A =>125, DNA =>5, p32 =>7},
{H3 =>24, H4 =>156, DNA =>123, p12 =>13}
);

my @xsorted = sort {
$b->[0]{$b->[1]} <=> $a->[0]{$a->[1]};
} map {
[ $_, (sort { $_->{$b} <=> $_->{$a} } keys %$_)[0] ]
} @aoh;
print Dumper(\@xsorted);

print "$_->[1]: $_->[0]{$_->[1]}\n" foreach @xsorted;
-- snip --

Let's dissect that a littlebit:

First of all, the Schwartzian Transformation is usually used as an
optimization for sorting.  You use it if the 'per-compare' computation
is rather difficult.  For an array @l it goes like this:

A. create a temp list from @l with
a. the actual data from @l
b. the precomputed data from @l that's used for comparing 2
   elements during sorting.

B. sort that temp list using the precomputed field.

C. create the sorted list by extracting the 'pure' data from @l from
  the now sorted temp list

D. do it all in a fat combination of map sort map >:->

We need to skip step C, since we'd lose the information about the
highest hash value if we just put all the data into the resulting array
again.

If you reverse-read above '@xsorted = ...' code you find

A. create a temp list from @l..:

map {
[
  # ...with the actual data from @l...
  $_,
  # ...and the precomputed...
  (sort { $_->{$b} <=> $_->{$a} } keys %$_)[0]
]
} @aoh

   For each element in @aoh we're sorting the keys of that hash by
   comparing the hash's value at that key.

   Then we use only the first element of that resulting sorted list
   of hash keys, since that has the highest value.

   So, now we have a list
(
  [ original_item, highest_hash_key_for_that_item ],
  ...
)


B. sort that temp list using the precomputed fields...

sort {
$b->[0]{$b->[1]} <=> $a->[0]{$a->[1]}
}

   We can split that up and be a bit more verbose:

sort {
my ($a_orig_item, $a_key) = @$a;
my ($b_orig_item, $b_key) = @$b;

$b_orig_item->{$b_key} <=> $a_orig_item->{$a_key}
}

   which is a bit longer but doesn't scare the kids that much.

Now on for the questions and flames...

-- 
   If we fail, we will lose the war.

Michael Lamertz|  +49 221 445420 / +49 171 6900 310
Nordstr. 49|   [EMAIL PROTECTED]
50733 Cologne  | http://www.lamertz.net
Germany|   http://www.perl-ronin.de 

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




compare dates

2002-05-06 Thread Lance Prais



Hello,
  How do you compare dates to see if dates are "between"?
For example in SQL I would do it like this to find the values between now
and seven days prior:.
X is Between(sysdate-7) and sysdate
Thank you,



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




Re: Unique list

2002-05-06 Thread Jonathan E. Paton

> I would like to create a unique list.

Buy the Cookbook or search the archives, since this is a common
question.  Basically one of the following two solutions is best.

%seen = ();
@unique = grep { not $seen{$_}++ } @list_A, @list_B;

OR:

%seen = ();
$seen{$_}++ for @list_A, @list_B;
@unique = keys %seen;

I think you'll agree they are simplier than your code!

Jonathan Paton

__
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

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




Re: compare dates

2002-05-06 Thread Jonathan E. Paton

[Cross-posted reply to cross-posted article... to avoid]
[further duplication only '[EMAIL PROTECTED]' should  ]
[be used for further correspondence on this thread.]
[Remove PBML from the header before replying!  Jonathan]

Hi,

Please don't cross post questions between PBML and [EMAIL PROTECTED]  All my 
beginners mail gets
filtered into the same folder, and it's obvious and annoying to see cross posts.  
You'll find
either list is active enough to have most questions answered within a few hours.  
Cross posting is
a waste of time, when people spend time re-answering questions others already give 
answers to -
but didn't see because they were posted on a different list.

This is again another commonly asked question upon these lists, so you may wish to 
look at:

http://perldoc.com/perl5.6.1/pod/perlfaq4.html#Data--Dates

Jonathan Paton

__
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

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




Re: compare dates

2002-05-06 Thread Sean O'Leary

On Mon, 2002-05-06 at 13:53, Lance Prais wrote:
> 
> 
> Hello,
>   How do you compare dates to see if dates are "between"?
> For example in SQL I would do it like this to find the values between now
> and seven days prior:.
> X is Between(sysdate-7) and sysdate
> Thank you,
> 

Use a Date:: module to make sure it's valid date and all that jazz.  I'd
use Date::Calc because it's fairly fast, as far as the Date modules go,
and has a recipe for doing exactly what you described.  Check out the
Date::Calc here:

http://search.cpan.org/doc/STBEY/Date-Calc-5.0/Calc.pod

Later,

Sean.





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




Re: Unique list

2002-05-06 Thread drieux


On Monday, May 6, 2002, at 10:34 , Lance Prais wrote:

> sub createUniquePartitionFile {
>   my %args = (
>   PARTITION => '',
>   PARTITIONFILE => '',
>   OUTPUTFILENAME => '',
>   @_,
>   );
>   $status = 0;
>   $partitionFile = $args{PARTITIONFILE};
>   $outputFileName = $args{OUTPUTFILENAME};
>   # Message
>   print "topten: Creating a unique solution file for [$partition].\n";
>   # Remove existing output file
>   $command_string = "/usr/bin/rm -f " . $outputFileName;
>   $status = `$command_string`;
>
>   $command_string = "sort -u " . $partitionFile . " \> " . 
> $outputFileName;
>   $status = `$command_string`;
>
>   return  $status;
> }


the benchmarks for jonathan's proposals are at:

http://www.wetware.com/drieux/CS/lang/Perl/Beginners/BenchMarks/uniqDeList.
txt

but think a bit about what your 'function' here should be doing..

I'm very confused by the idea of

my %args = (
PARTITION => '',
PARTITIONFILE => '',
OUTPUTFILENAME => '',
@_,
);

why not the simpler

my ( $outputFile, $partitionFile, $partition) = @_;

and save on the re-assignment to those variables from the
way interesting %arg???

also you are using perl as if it were /bin/sh -


$command_string = "/usr/bin/rm -f " . $outputFileName;
$status = `$command_string`;

vice say

unlink $outputFileName if ( -f $outputFileName );

which does not require a fork of an external command...

If you have the dope already in memory, why not stay in memory
rather than buying the file IO AND the forks???

ciao
drieux

---


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




Doing a little formatting

2002-05-06 Thread Batchelor, Scott

I am listing several variables...but I would like to make them all a certain
length to keep the format of the report somewhat...well formatted.

Is there an easy way to do this?

Right now I am just doing"

prprint "$ext_id\t$lastname,
$firstname\t$mailaddr\t$status\t$deptexp\t$dept\t$buildroom\t$phone\n";

Thanks in advance!!

Scott M. Batchelor 




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




RE: Doing a little formatting

2002-05-06 Thread Nikola Janceski

perldoc -f printf

it's just like C's printf.

> -Original Message-
> From: Batchelor, Scott [mailto:[EMAIL PROTECTED]]
> Sent: Monday, May 06, 2002 3:14 PM
> To: '[EMAIL PROTECTED]'
> Subject: Doing a little formatting
> 
> 
> I am listing several variables...but I would like to make 
> them all a certain
> length to keep the format of the report somewhat...well formatted.
> 
> Is there an easy way to do this?
> 
> Right now I am just doing"
> 
> prprint "$ext_id\t$lastname,
> $firstname\t$mailaddr\t$status\t$deptexp\t$dept\t$buildroom\t$
> phone\n";
> 
> Thanks in advance!!
> 
> Scott M. Batchelor 
> 
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




RE: Doing a little formatting

2002-05-06 Thread Timothy Johnson


Check out the format command.

perldoc -f format
perldoc perlform

-Original Message-
From: Batchelor, Scott [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 06, 2002 12:14 PM
To: '[EMAIL PROTECTED]'
Subject: Doing a little formatting


I am listing several variables...but I would like to make them all a certain
length to keep the format of the report somewhat...well formatted.

Is there an easy way to do this?

Right now I am just doing"

prprint "$ext_id\t$lastname,
$firstname\t$mailaddr\t$status\t$deptexp\t$dept\t$buildroom\t$phone\n";

Thanks in advance!!

Scott M. Batchelor 




-- 
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]




Creating an interactive calendar

2002-05-06 Thread Ron

I'm in the midst of writing a PERL script that will display a calendar in
table form.  I have a database (mySQL) with the events sorted by date.  I'm
trying to write the calendar to place a hyperlink on those days that an
event is listed in the database.

So far I have no problem creating the calendar or a text listings of events,
but I have run into a snag only linking those db dates to the corresponding
calendar numbers.  I can make every calendar number linked to the
corresponding day a display no event listed, but I prefer to only have event
days active.

I am using both Date::Calendar & Date::Calc.  I want to know if anyone knows
of a good reference that can advise me and help me along?

I  use cspan.org all the time, other than that reference.  Thank you in
advance.

Ron



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




@INC

2002-05-06 Thread Seth Lilly









I am brand spanking new to Perl,
and I’m working with Plain Black’s WebGUI
software.  I’m having difficulty
specifying the directories for some of my *.pm files.  Is there a way to edit a @INC file of some
type (if such a thing exists) to include those directories?  Thanks, everyone, for helping out the new
guy.

 











Seth Lilly

Help Desk Technician

West Virginia Higher Education Policy Commission

1018 Kanawha
  Blvd E Suite 700

Charleston WV  25301

304.558.2101

[EMAIL PROTECTED]

http://www.hepc.wvnet.edu 



 










Sorry for the format confusion...

2002-05-06 Thread Seth Lilly

Sorry for sending out that last message in HTML...plain text from now
on...


Seth Lilly
Help Desk Technician
West Virginia Higher Education Policy Commission
1018 Kanawha Blvd E Suite 700
Charleston WV  25301
304.558.2101
[EMAIL PROTECTED]
http://www.hepc.wvnet.edu 


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




Re: Unique list

2002-05-06 Thread drieux


On Monday, May 6, 2002, at 10:34 , Lance Prais wrote:

> Thank you in advance

http://www.wetware.com/drieux/CS/lang/Perl/Beginners/BenchMarks/FileWayuniqDeList.
txt

may help see the complications of doing this with File IO

I can understand the habit of 'directly porting' from /bin/sh
models of doing things - been there - so I do hope that you
take this in the spirit of understanding

ciao
drieux

---


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




Re: @INC

2002-05-06 Thread drieux


On Monday, May 6, 2002, at 12:45 , Seth Lilly wrote:


> I am brand spanking new to Perl, and I’m working with Plain Black’s 
> WebGUI software. I’m having difficulty specifying the directories for 
> some of my *.pm files. Is there a way to edit a @INC file of some type 
> (if such a thing exists) to include those directories? Thanks, everyone, 
> for helping out the new guy.

the easiest trick is

a) perldoc h2xs  - so that you start with the simple way for
churning up the basic PM context:

cf: http://www.wetware.com/drieux/CS/lang/Perl/PM/

b) opt to just install them in whereEver the site_perl will
land them when you do the

make install

TRUST ME - it is much simpler that way

Unless you really need to 'get funky' - just don't:

cf: http://www.wetware.com/drieux/CS/lang/Perl/PM/useLibHack.html

and yes you could try the PERLLIB5 environmental variable, but
that is like so retrogressive. I mean like so "vintage 80's"!!!

ciao
drieux

---

{ you are clearly taking the wrong turn - you are thinking of
perl as a coding language hence that PM's are the logical
consequence of that conclusion... So just step on down the
yellow brick road one more pace. Do it like you were
really planning on sending it to the CPAN... }


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




unfamiler errors

2002-05-06 Thread Lance Prais


I am using the following code to extract data from a db and write to a file
and getting errors that I am not familiar with:  Does anyone know what I am
doing wrong?

#!/usr/local/bin/perl

#ENVIRONMENT VARIABLES
$CUSTOM = "/data/verity/custom-kb";
$SERVICE= "xxx";
$oracle_user= "xxx";
$oracle_password= "";
$unique_sr_list = "$CUSTOM/scripts/unique_sr_list.txt";
use strict;
use DBI;

open(TEXTFILE,">$unique_sr_list");
print "Checking for updated Service Requests: " . `date`;

$connect_string="DBI:Oracle:$SERVICE";

my $dbh = DBI->connect($connect_string,$oracle_user,$oracle_password,
{ AutoCommit=> 0,  LongTruncOk=> TRUE, PrintError => 1, ChopBlanks=>
TRUE,LongTruncOk=> TRUE,LongReadLen=> 5, RaiseError => 1 }) or die
"connecting: $DBI::errstr";

# find the SR
my $sql = qq{select distinct(nvl((c.sr_num),0))  from s_evt_act a, s_srv_req
c where a.sra_sr_id = c.row_id and a.priv_flg = 'N' and a.last_upd between
(sysdate-7) and sysdate intersect select (nvl((sr_num),0)) from s_srv_req b
where b.x_cp_updated between (sysdate-1) and sysdate};
my $sth = $dbh->prepare ( $sql );
$sth->execute();

 while( @row = $sth->fetchrow_array )
   {
   $oid=$row[0];

 print TEXTFILE"$oid\n";

   }
$sth->finish();
$dbh->disconnect();

Error message:


Global symbol "@row" requires explicit package name at ./daily_sr.pl line
25.
Global symbol "$oid" requires explicit package name at ./daily_sr.pl line
27.
Global symbol "@row" requires explicit package name at ./daily_sr.pl line
27.
Global symbol "$oid" requires explicit package name at ./daily_sr.pl line
29.
Bareword "TRUE" not allowed while "strict subs" in use at ./daily_sr.pl line
17.
Bareword "TRUE" not allowed while "strict subs" in use at ./daily_sr.pl line
17.
Bareword "TRUE" not allowed while "strict subs" in use at ./daily_sr.pl line
17.
Execution of ./daily_sr.pl aborted due to compilation errors.




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




RE: unfamiler errors

2002-05-06 Thread Shah, Urmil

add 'my' in front of these variables..

my @row;
my $oid;

Urmil

-Original Message-
From: Lance Prais [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 06, 2002 3:15 PM
To: [EMAIL PROTECTED]
Subject: unfamiler errors



I am using the following code to extract data from a db and write to a file
and getting errors that I am not familiar with:  Does anyone know what I am
doing wrong?

#!/usr/local/bin/perl

#ENVIRONMENT VARIABLES
$CUSTOM = "/data/verity/custom-kb";
$SERVICE= "xxx";
$oracle_user= "xxx";
$oracle_password= "";
$unique_sr_list = "$CUSTOM/scripts/unique_sr_list.txt";
use strict;
use DBI;

open(TEXTFILE,">$unique_sr_list");
print "Checking for updated Service Requests: " . `date`;

$connect_string="DBI:Oracle:$SERVICE";

my $dbh = DBI->connect($connect_string,$oracle_user,$oracle_password,
{ AutoCommit=> 0,  LongTruncOk=> TRUE, PrintError => 1, ChopBlanks=>
TRUE,LongTruncOk=> TRUE,LongReadLen=> 5, RaiseError => 1 }) or die
"connecting: $DBI::errstr";

# find the SR
my $sql = qq{select distinct(nvl((c.sr_num),0))  from s_evt_act a, s_srv_req
c where a.sra_sr_id = c.row_id and a.priv_flg = 'N' and a.last_upd between
(sysdate-7) and sysdate intersect select (nvl((sr_num),0)) from s_srv_req b
where b.x_cp_updated between (sysdate-1) and sysdate};
my $sth = $dbh->prepare ( $sql );
$sth->execute();

 while( @row = $sth->fetchrow_array )
   {
   $oid=$row[0];

 print TEXTFILE"$oid\n";

   }
$sth->finish();
$dbh->disconnect();

Error message:


Global symbol "@row" requires explicit package name at ./daily_sr.pl line
25.
Global symbol "$oid" requires explicit package name at ./daily_sr.pl line
27.
Global symbol "@row" requires explicit package name at ./daily_sr.pl line
27.
Global symbol "$oid" requires explicit package name at ./daily_sr.pl line
29.
Bareword "TRUE" not allowed while "strict subs" in use at ./daily_sr.pl line
17.
Bareword "TRUE" not allowed while "strict subs" in use at ./daily_sr.pl line
17.
Bareword "TRUE" not allowed while "strict subs" in use at ./daily_sr.pl line
17.
Execution of ./daily_sr.pl aborted due to compilation errors.




-- 
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: @INC

2002-05-06 Thread Mike Rapuano

As an alternative, how about this... short sweet and lazy;)
 
 
BEGIN {
 $current_dir = 'd:\\my_directory';
 push(@INC, $current_dir);
}
 
print "@INC\n";
 
 

-Original Message- 
From: drieux 
Sent: Mon 5/6/2002 4:07 PM 
To: [EMAIL PROTECTED] 
Cc: 
Subject: Re: @INC




On Monday, May 6, 2002, at 12:45 , Seth Lilly wrote:


> I am brand spanking new to Perl, and I’m working with Plain
Black’s
> WebGUI software. I’m having difficulty specifying the
directories for
> some of my *.pm files. Is there a way to edit a @INC file of
some type
> (if such a thing exists) to include those directories? Thanks,
everyone,
> for helping out the new guy.

the easiest trick is

a) perldoc h2xs  - so that you start with the simple way
for
churning up the
basic PM context:

cf: http://www.wetware.com/drieux/CS/lang/Perl/PM/

b) opt to just install them in whereEver the site_perl
will
land them when you do the

make install

TRUST ME - it is much simpler that way

Unless you really need to 'get funky' - just don't:

cf:
http://www.wetware.com/drieux/CS/lang/Perl/PM/useLibHack.html

and yes you could try the PERLLIB5 environmental variable, but
that is like so retrogressive. I mean like so "vintage
80's"!!!

ciao
drieux

---

{ you are clearly taking the wrong turn - you are
thinking of
perl as a coding language hence that PM's are the
logical
consequence of that conclusion... So just step on down
the
yellow brick road one more pace. Do it like you were
really planning on sending it to the CPAN... }


--
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: unfamiler errors

2002-05-06 Thread drieux


On Monday, May 6, 2002, at 01:15 , Lance Prais wrote:
[..]
>
>  while( @row = $sth->fetchrow_array )
>{
>$oid=$row[0];
>
>  print TEXTFILE"$oid\n";
>
>  }
[..]
> Error message:
>
>
> Global symbol "@row" requires explicit package name at ./daily_sr.pl line
> 25.
> Global symbol "$oid" requires explicit package name at ./daily_sr.pl line
> 27.
> Global symbol "@row" requires explicit package name at ./daily_sr.pl line
> 27.
> Global symbol "$oid" requires explicit package name at ./daily_sr.pl line
> 29.

notice your loop there - you need to resolve the scope of these variables

while ( my @row =  ) { # just for the length of this loop

my $oid =   # use it and blow it

}

when you get in the habit of this - you know that you have
done the scope of the variables that you really wanted - and then
you get to find where you are trying to redeclare a variable that
is still 'in scope' - but those are actually cuter error messages...

> Bareword "TRUE" not allowed while "strict subs" in use at ./daily_sr.pl 
> line
> 17.
> Bareword "TRUE" not allowed while "strict subs" in use at ./daily_sr.pl 
> line
> 17.
> Bareword "TRUE" not allowed while "strict subs" in use at ./daily_sr.pl 
> line
> 17.

look at line '17' - and ask yourself what a 'bare word' looks like
as opposed to say

"TRUE" or 'TRUE'

in perl

ciao
drieux

---


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




problems with libwww-perl module

2002-05-06 Thread Pedro A Reche Gallardo

Hi all,  one more time I need some help. In the past I have used the
libwww-perl module  to execute and get the information from that remote
web server. This was actually quite simple because I did not have to
post any data. Now I wrote an script that it will have to post some data
to the server and then retrieve the information. However, I am a little
bit lost because the server in question
(http://www.cbs.dtu.dk/services/TMHMM/) runs the job in the background,
and then it  sends you to a result page latter, and I do not know how to
get there.   The site I am working with is at the url
http://www.cbs.dtu.dk/services/TMHMM/, and here is my script:

#!/usr/sbin/perl -w
use strict;
require HTTP::Message;
use HTTP::Request::Common;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $FILE = shift @ARGV;


my $res =$ua->request(POST 'http://www.cbs.dtu.dk/cgi-bin/nph-webface',
Content_Type => 'form-data',
Content  => [configfile
=>'/home/genome2/www/Public_html/services/TMHMM-2.0/TMHMM2.cf',
outform   => '-short',
seqfile   => ["$FILE"]],);


my $req =$ua->request(GET
'http://www.cbs.dtu.dk/cgi-bin/nph-webface?jobid=TMHMM2,$res&opt=none');#

my @lines = split(/\n/, $ua->request($req)->as_string);
my $count = @lines;


for (my $y = 0; $y < $count; $y++) {
if  ($lines[$y] =~ /^Sequence/) {
print $lines[$y],"\n";

}
}



I am running the script as it follows:
%script.pl file; where  file is:
>gi|75188|pir||QQIVE1 hypothetical 18K protein - influenza A virus
(strain A/PR/8/ 34)
MLFAQNYSLLSSVCVSLLQSTILFLQTSDLIVPAISRFCFGVSGGLPFSQANLCRVSETRTVLSFH
SSPPMRTPTAFLTSSAVCPGREGNGEISPTIAPSSVKALSNIRVSSRSKITLKFAFSMMFLSMIAWSILI
QRGPATFCLGMSMDQSLDISSRVMSVR*

When I run the script I got the following message:
You need a request object, not a HTTP::Response object at ./ranseq.pl
line 19

As I said  I am a little bit lost, and I will be very happy for any help
on the subject.


Cheers
***
PEDRO A. RECHE , pHDTL: 617 632 3824
Dana-Farber Cancer Institute,   FX: 617 632 4569
Harvard Medical School, EM: [EMAIL PROTECTED]
44 Binney Street, D1510A,   EM: [EMAIL PROTECTED]
Boston, MA 02115URL:
http://www.reche.org
***




RE: @INC

2002-05-06 Thread Hanson, Robert

There are a few ways listed in the FAQ's.  "perldoc -q " will
search the FAQ's on a specific word.  Below is what was found when I
searched on the word "library".  Depending on your needs using the PERL5LIB
environment variable might be the best option (Just create a new environment
variable in Windows or Unix named PERL5LIB and point it to the directory
with the modules).

[perldoc output]
$ perldoc -q library
=head1 Found in /opt/perl5.005_03/lib/5.00503/pod/perlfaq8.pod

=head2 How do I keep my own module/library directory?

When you build modules, use the PREFIX option when generating
Makefiles:

perl Makefile.PL PREFIX=/u/mydir/perl

then either set the PERL5LIB environment variable before you run
scripts that use the modules/libraries (see L) or say

use lib '/u/mydir/perl';

This is almost the same as:

BEGIN {
unshift(@INC, '/u/mydir/perl');
}

except that the lib module checks for machine-dependent subdirectories.
See Perl's L for more information.

=head2 How do I add the directory my program lives in to the module/library
search path?

use FindBin;
use lib "$FindBin::Bin";
use your_own_modules;



-Original Message-
From: Seth Lilly [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 06, 2002 3:46 PM
To: [EMAIL PROTECTED]
Subject: @INC


 
I am brand spanking new to Perl, and I'm working with Plain Black's WebGUI
software.  I'm having difficulty specifying the directories for some of my
*.pm files.  Is there a way to edit a @INC file of some type (if such a
thing exists) to include those directories?  Thanks, everyone, for helping
out the new guy.
 



Seth Lilly
Help Desk Technician
West Virginia Higher Education Policy Commission
1018 Kanawha Blvd E Suite 700
Charleston WV  25301
304.558.2101
[EMAIL PROTECTED]
http://www.hepc.wvnet.edu 
 

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




Re: Unique list

2002-05-06 Thread Michael Lamertz

On Mon, May 06, 2002 at 11:40:10AM -0700, drieux wrote:
> 
> I'm very confused by the idea of
> 
>   my %args = (
>   PARTITION => '',
>   PARTITIONFILE => '',
>   OUTPUTFILENAME => '',
>   @_,
>   );
> 
> why not the simpler
> 
>   my ( $outputFile, $partitionFile, $partition) = @_;

I guess he over-idiomized:  I use the above frequently to preinitialize
objects:

sub new {
my $context = shift
my $class = ref($context) || $context;
bless {
a_number  => 42,
some_text => 'I have a value',
@_
}, $class
}

That way, one can do the following:

my $obj = TheClass->new(some_other_value => 57,
a_number => 12);

Now, some OO_Bigott would most probably jump right into my face for
allowing some user from the mob to add 'some_other_value' to our holy
moly class object, but in most cases I don't consider that a problem -
the OO_Bigott jumping, that is ;-)

-- 
   If we fail, we will lose the war.

Michael Lamertz|  +49 221 445420 / +49 171 6900 310
Nordstr. 49|   [EMAIL PROTECTED]
50733 Cologne  | http://www.lamertz.net
Germany|   http://www.perl-ronin.de 

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




connection error

2002-05-06 Thread Lance Prais

I am getting a connection error. I used this same connection string all
though out my scripts in this application without problems except in this
case.  Does anyone know why I could be getting this error?

Connection String:
use DBI;

my $connect_string="DBI:Oracle:$SERVICE";

my $dbh = DBI->connect(my $connect_string,my $oracle_user,my
$oracle_password,
{ AutoCommit=> 0,  LongTruncOk=> 'TRUE', PrintError => 1,
ChopBlanks=> 'TRUE',LongTruncOk=> 'TRUE',LongReadLen=> 5, RaiseError =>
1 }) or die "connecting: $DBI::errstr";


Error Message:
Can't connect(   HASH(0xf696c)), no database driver specified and DBI_DSN
env var not set at ./daily_sr.pl line 19

Thank you,

Lance Prais
Check Point Software Technologies, Inc.
817-606-6505
[EMAIL PROTECTED]



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




Re: connection error

2002-05-06 Thread John W. Krahn

Lance Prais wrote:
> 
> I am getting a connection error. I used this same connection string all
> though out my scripts in this application without problems except in this
> case.  Does anyone know why I could be getting this error?
> 
> Connection String:
> use DBI;
> 
> my $connect_string="DBI:Oracle:$SERVICE";
  ^^
You are creating a new variable $connect_string and assigning a value to
it.


> my $dbh = DBI->connect(my $connect_string,my $oracle_user,my $oracle_password,
 ^^
The my() here is redeclaring the variable $connect_string, in other
words it is setting it's value to undef.  The same is happening to
$oracle_user and $oracle_password.


> { AutoCommit=> 0,  LongTruncOk=> 'TRUE', PrintError => 1,
> ChopBlanks=> 'TRUE',LongTruncOk=> 'TRUE',LongReadLen=> 5, RaiseError =>
> 1 }) or die "connecting: $DBI::errstr";
> 
> Error Message:
> Can't connect(   HASH(0xf696c)), no database driver specified and DBI_DSN
> env var not set at ./daily_sr.pl line 19



John
-- 
use Perl;
program
fulfillment

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




backquoted return values

2002-05-06 Thread HENRY,MARK (HP-Roseville,ex1)

Hi All,

A question regarding process mgmt.

Using the system() call, you can call an os command a test for the return
value of the command in question, proceeding based on the return value.

However, using backquotes, is there a way to do the same?  This method
returns the output of the program back to the script, but not the return
value..  any suggestions?

Many thanks,

Mark

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




Re: connection error

2002-05-06 Thread drieux


On Monday, May 6, 2002, at 02:36 , Lance Prais wrote:
[..]
>  Does anyone know why I could be getting this error?

not sure - you might want to also re-read

  http://search.cpan.org/doc/TIMB/DBI-1.21/DBI.pm

> Connection String:
> use DBI;
>
> my $connect_string="DBI:Oracle:$SERVICE";
>
> my $dbh = DBI->connect(my $connect_string,my $oracle_user,my
> $oracle_password,
> { AutoCommit=> 0,  LongTruncOk=> 'TRUE', PrintError => 1,
> ChopBlanks=> 'TRUE',LongTruncOk=> 'TRUE',LongReadLen=> 5, RaiseError 
> =>
> 1 }) or die "connecting: $DBI::errstr";
>
>
> Error Message:
> Can't connect(   HASH(0xf696c)), no database driver specified and DBI_DSN
> env var not set at ./daily_sr.pl line 19


I think we may have over my'd this

you are 'declaring variables' in the method call
Hence sending in uninitialized data into the connect method...

how about:

#--untested--
use DBI;
# where did $SERVICE get defined

my  ($service, $user, $auth) =
("DBI:Oracle:$SERVICE" , 'theOracleGuy', 'theOneTruePw');

my %dbi_con_attr  = (
AutoCommit=> 0, LongTruncOk=> 'TRUE', PrintError => 1,
ChopBlanks=> 'TRUE',LongTruncOk=> 'TRUE',LongReadLen=> 5,
RaiseError => 1,
) ;


my $dbh = DBI->connect($service, $user, $auth, \%dbi_con_attr )
or die "connecting: $DBI::errstr :$!\n";

#--untested--

boy if that doesn't have template written all over it

ciao
drieux

---


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




RE: connection error

2002-05-06 Thread Lance Prais

One more issue:

When using this:

use DBI;

my $connect_string="DBI:Oracle:$SERVICE";

my $dbh = DBI->connect($connect_string,$oracle_user,$oracle_password,
{ AutoCommit=> 0,  LongTruncOk=> 'TRUE', PrintError => 1,
ChopBlanks=> 'TRUE',LongTruncOk=> 'TRUE',LongReadLen=> 5, RaiseError =>
1 }) or die "connecting: $DBI::errstr";


I and getting this annoying message:

 You must install a Solaris patch to run this version of the Java runtime.
 Please see the README and release notes for more information.
 Exiting

I am jdk1.3.  I have installed all the recommended patches in the
README.sparc file but no luck.  Also this connect string works in other
scripts with in the application.




-Original Message-
From: John W. Krahn [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 06, 2002 4:55 PM
To: [EMAIL PROTECTED]
Subject: Re: connection error

Lance Prais wrote:
>
> I am getting a connection error. I used this same connection string all
> though out my scripts in this application without problems except in this
> case.  Does anyone know why I could be getting this error?
>
> Connection String:
> use DBI;
>
> my $connect_string="DBI:Oracle:$SERVICE";
  ^^
You are creating a new variable $connect_string and assigning a value to
it.


> my $dbh = DBI->connect(my $connect_string,my $oracle_user,my
$oracle_password,
 ^^
The my() here is redeclaring the variable $connect_string, in other
words it is setting it's value to undef.  The same is happening to
$oracle_user and $oracle_password.


> { AutoCommit=> 0,  LongTruncOk=> 'TRUE', PrintError => 1,
> ChopBlanks=> 'TRUE',LongTruncOk=> 'TRUE',LongReadLen=> 5, RaiseError
=>
> 1 }) or die "connecting: $DBI::errstr";
>
> Error Message:
> Can't connect(   HASH(0xf696c)), no database driver specified and DBI_DSN
> env var not set at ./daily_sr.pl line 19



John
--
use Perl;
program
fulfillment

--
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: backquoted return values

2002-05-06 Thread drieux


On Monday, May 6, 2002, at 03:09 , HENRY,MARK (HP-Roseville,ex1) wrote:

> Hi All,
>
> A question regarding process mgmt.
>
> Using the system() call, you can call an os command a test for the return
> value of the command in question, proceeding based on the return value.
>
> However, using backquotes, is there a way to do the same?  This method
> returns the output of the program back to the script, but not the return
> value..  any suggestions?

my $cmd = 'theUseualsHere 2>&1; echo $?';

and parse it out of the stream

or you can just try the old fashion way:

my $ret = `$cmd`;
 my $error_code_Oh_Last_cmd = $?;

I got bit by the fact that this worked, what a couple of weeks ago?

ciao
drieux

---


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




Summary: make test of Text::Reflow

2002-05-06 Thread Deb

Answering myself here - found out it was the perl
binary.  For some reason the binary compiled for 64-bit
execution would not make this module properly, but
the 32-bit does.  Go figure.  

Someone else is looking into why this might be the case.
For now, I'm happy to use the 32-bit version.

deb


Meanwhile, Deb says:
| 
| Hello,
| 
| I installed perl module Text::Reflow on perl v5.6.1 for Solaris.
| 
| It built fine, but "make test" fails in that it hangs on the 
| first test.  
| 
| cpan> test Text::Reflow
| Running test for module Text::Reflow
| Running make for M/MW/MWARD/Text-Reflow-1.04.tar.gz
|   Is already unwrapped into directory /usr/local/cpan/build/Text-Reflow-1.04
|   Has already been processed within this session
| Running make test
| Use of uninitialized value in scalar assignment at 
|/usr/local/pkg/perl-5.6.1/lib/5.6.1/CPAN.pm line 4658.
| Use of uninitialized value in hash dereference at 
|/usr/local/pkg/perl-5.6.1/lib/5.6.1/CPAN.pm line 801.
| PERL_DL_NONLAZY=1 /usr/local/pkg/perl-5.6.1/bin/perl -Iblib/arch -Iblib/lib 
|-I/usr/local/pkg/perl-5.6.1/lib/5.6.1/sun4-solaris 
|-I/usr/local/pkg/perl-5.6.1/lib/5.6.1 test.pl
| 1..20
| ok 1
| ^C  /usr/ccs/bin/make test -- NOT OK
| 
| 
| I don't know how to troubleshoot this, and find out wherein lies
| the problem.  Any and all help would be appreciated, or even
| pointers to the appropriate email list(s).
| 
| Thanks,
| 
| deb
| 
| -- 
| To unsubscribe, e-mail: [EMAIL PROTECTED]
| For additional commands, e-mail: [EMAIL PROTECTED]
| 
| 

"If it dies, it's biology.  If it blows up, it's chemistry,
and if it doesn't work, it's physics."
 -- University bathroom graffito
ô¿ô
 ~ 

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




Re: Summary: make test of Text::Reflow

2002-05-06 Thread drieux


On Monday, May 6, 2002, at 04:58 , Deb wrote:

> Answering myself here - found out it was the perl
> binary.  For some reason the binary compiled for 64-bit
> execution would not make this module properly, but
> the 32-bit does.  Go figure.

I presume that you are working in solaris 8 or higher?

ciao
drieux

---


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




Taking data from the screen to a file

2002-05-06 Thread Melissa.Cama

Hi, 

I'm just new to Perl and have no idea where to start with the task that I have to 
complete.  Any help would be appreciated.

Currently when a particular .exe is run, the following is displayed in the command 
window - 

License server on host "kronos".
Running since Monday 4/04/96 15:53:13.

LICENSES:
 Max-Users   Expires   Password [status]
19   none  2aae4b60.b4ac4f0f.02 [Valid]

 Maximum active users allowed: 19
 Current active users: 6
 Available licenses: 13

ACTIVE users:
UserPriority   Time-out in
rdc 2  59 minutes (at 10:44:20)
chris   1  26 minutes (at 10:10:45)
cheryl   none  23 minutes (at 10:07:27)

License Usage Statistics:
2 licenses revoked today 4/14/96.
0 license requests denied.
0 active users bumped by preferred user.

>From this i need to extract "just" the user names and place them into an external 
>file.  How do I go about this?

Thanks heaps
Melissa


--
This message and any attachment is confidential and may be privileged or otherwise 
protected from disclosure.  If you have received it by mistake please let us know by 
reply and then delete it from your system; you should not copy the message or disclose 
its contents to anyone.





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




Re: Taking data from the screen to a file

2002-05-06 Thread drieux


On Monday, May 6, 2002, at 10:04 , <[EMAIL PROTECTED]> 
wrote:

> ACTIVE users:

that's rather the key - its a reasonably clear line
or build up the regular expression from the next line
either way

cf: perldoc perlre

I presume you can do something in windows that is the equivolent
of a pipe hence all you really need is the perl filter that
fixates on the regular expression.

so we know that until we hit the regEx we can toss the junk -
hence we want to use
next unless /$findPat/

The problem is that none of the things we want to read match
the regular expression - so lets have the old foundFlag trick

my $found = 0
while() {
if ( $found == 0 ) { # bite me PerlFascists - this is Demo
next unless /$findPat/;
$found++
} else {
#we found it
# we need a new simple replacement for awk
/^\s*(\w+)\s*\w+/;  # a bit over but we grab the first word
# if the line has at 
least two words

my $player = $1 ;   # save the match if it occurred
if($player) {
push(@userName , $player);
}else{
$found = 0; # Not in the Found Place
}   # since the match fails
}



ciao
drieux

---
If you get really stuck, You may also peek at:
http://www.wetware.com/drieux/CS/lang/Perl/Beginners/funkyParsing.txt


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




Re: Taking data from the screen to a file

2002-05-06 Thread Sudarsan Raghavan

>
>
> I'm just new to Perl and have no idea where to start with the task that I have to 
>complete.  Any help would be appreciated.
>
> Currently when a particular .exe is run, the following is displayed in the command 
>window -
>
> License server on host "kronos".
> Running since Monday 4/04/96 15:53:13.
>
> LICENSES:
>  Max-Users   Expires   Password [status]
> 19   none  2aae4b60.b4ac4f0f.02 [Valid]
>
>  Maximum active users allowed: 19
>  Current active users: 6
>  Available licenses: 13
>
> ACTIVE users:
> UserPriority   Time-out in
> rdc 2  59 minutes (at 10:44:20)
> chris   1  26 minutes (at 10:10:45)
> cheryl   none  23 minutes (at 10:07:27)
>
> License Usage Statistics:
> 2 licenses revoked today 4/14/96.
> 0 license requests denied.
> 0 active users bumped by preferred user.
>
> >From this i need to extract "just" the user names and place them into an external 
>file.  How do I go about this?
>

Give this a try
#!/usr/local/bin/perl -w
use strict;
my $seen_user;
open (EXE_OUT, " |") or die "Exe execution failed : $!\n";
while () {
$seen_user = 0 if ($seen_user && m/^$/);
$seen_user = 1, , next if (m/^ACTIVE users:/);
#Use ACTIVE users: as a marker, read out the next line containing the headers 
and next
s/^\s+//, (print "user is ", (split (/\s+/))[0], "\n") if ($seen_user);
#Remove the leading white spaces and split, index 0 is the user name
}
close (EXE_OUT);



>
> Thanks heaps
> Melissa


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




Piping mail spool through a Perl script?

2002-05-06 Thread jc

Hello,

I inherited a project where we use a procmail filter to filter emails as 
they come to our web server and pipe them through a perl script.  The 
script called "filterme" goes through the email line by line and grabs 
information on the email, puts it into an array, and when it is finished, 
it appends the data collected to a file, (a log file of sorts).

I have to redo this script to grab a different set of information, but I 
need to filter existing emails already in the mail spool.  It was suggested 
to me that I could go to the mail folder (var/users/mail) and grab the 
folder and then pipe all the files in the mail folder through the 
"filterme" script.  However, when I look at the mailspool folder, I only 
see one file that contains all the emails.  I was wondering if there was a 
way to somehow parse this file and pipe the results through the "filterme" 
script.

I realize I need more education in how email works and I am slowly picking 
through the sendmail book by O'Reilly.  But if anyone knows a simple answer 
to this, I would be much obliged.

Thanks in advance,

Joan Chyun


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




RE: Taking data from the screen to a file

2002-05-06 Thread Timothy Johnson

 
Here's one take on this off the top of my head(I haven't tested it, but I
_think_ it will work).  The text you are looking for is bordered by a line
that starts with the word User after some spaces, and a line that has only
white space.  It seems like there should be a better way somewhere, but
until we know what that is...



my @output = `myApp.exe`; #using backticks to get output
my @users = '';

foreach(@output){
   my $found = '';
   if($_ =~ /^\s*User/i){
  $found = 1;
   }elsif($_ =~ /^\s+$/){
  $found = 0;
   }
   if($found){
  my @temp = split /\s+/,$_;
  push @users,$temp[1];
   }
}

shift @users; #get rid of the word 'User'

print "These are my users:\n";
foreach(@users){
   print "   $_\n";
}

###



-Original Message-
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: 5/6/02 10:04 PM
Subject: Taking data from the screen to a file

Hi, 

I'm just new to Perl and have no idea where to start with the task that
I have to complete.  Any help would be appreciated.

Currently when a particular .exe is run, the following is displayed in
the command window - 

License server on host "kronos".
Running since Monday 4/04/96 15:53:13.

LICENSES:
 Max-Users   Expires   Password [status]
19   none  2aae4b60.b4ac4f0f.02 [Valid]

 Maximum active users allowed: 19
 Current active users: 6
 Available licenses: 13

ACTIVE users:
UserPriority   Time-out in
rdc 2  59 minutes (at 10:44:20)
chris   1  26 minutes (at 10:10:45)
cheryl   none  23 minutes (at 10:07:27)

License Usage Statistics:
2 licenses revoked today 4/14/96.
0 license requests denied.
0 active users bumped by preferred user.

>From this i need to extract "just" the user names and place them into an
external file.  How do I go about this?

Thanks heaps
Melissa



--
This message and any attachment is confidential and may be privileged or
otherwise protected from disclosure.  If you have received it by mistake
please let us know by reply and then delete it from your system; you
should not copy the message or disclose its contents to anyone.





-- 
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: Piping mail spool through a Perl script?

2002-05-06 Thread Sudarsan Raghavan

jc wrote:

> Hello,
>
> I inherited a project where we use a procmail filter to filter emails as
> they come to our web server and pipe them through a perl script.  The
> script called "filterme" goes through the email line by line and grabs
> information on the email, puts it into an array, and when it is finished,
> it appends the data collected to a file, (a log file of sorts).
>
> I have to redo this script to grab a different set of information, but I
> need to filter existing emails already in the mail spool.  It was suggested
> to me that I could go to the mail folder (var/users/mail) and grab the
> folder and then pipe all the files in the mail folder through the
> "filterme" script.  However, when I look at the mailspool folder, I only
> see one file that contains all the emails.  I was wondering if there was a
> way to somehow parse this file and pipe the results through the "filterme"
> script.

#This assumes that filterme can executed and is in the PATH
open (FILTERME, "| filterme) or die "Failed to get handle to write to filterme
: $!\n";
print FILTERME "some stuff" #piping "some stuff" to filterme
close (FILTERME)

Is this what you are looking for
perldoc -f open

>
>
> I realize I need more education in how email works and I am slowly picking
> through the sendmail book by O'Reilly.  But if anyone knows a simple answer
> to this, I would be much obliged.
>
> Thanks in advance,
>
> Joan Chyun
>
> --
> 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: Piping mail spool through a Perl script?

2002-05-06 Thread Timothy Johnson

 
Is there a particular line or lines of text that delimits each email?

-Original Message-
From: jc
To: [EMAIL PROTECTED]
Sent: 5/6/02 11:03 PM
Subject: Piping mail spool through a Perl script?

Hello,

I inherited a project where we use a procmail filter to filter emails as

they come to our web server and pipe them through a perl script.  The 
script called "filterme" goes through the email line by line and grabs 
information on the email, puts it into an array, and when it is
finished, 
it appends the data collected to a file, (a log file of sorts).

I have to redo this script to grab a different set of information, but I

need to filter existing emails already in the mail spool.  It was
suggested 
to me that I could go to the mail folder (var/users/mail) and grab the 
folder and then pipe all the files in the mail folder through the 
"filterme" script.  However, when I look at the mailspool folder, I only

see one file that contains all the emails.  I was wondering if there was
a 
way to somehow parse this file and pipe the results through the
"filterme" 
script.

I realize I need more education in how email works and I am slowly
picking 
through the sendmail book by O'Reilly.  But if anyone knows a simple
answer 
to this, I would be much obliged.

Thanks in advance,

Joan Chyun


-- 
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: Taking data from the screen to a file

2002-05-06 Thread Felix Geerinckx

on Tue, 07 May 2002 05:04:56 GMT, [EMAIL PROTECTED]
(Melissa Cama) wrote: 

> [...]
> From this i need to extract "just" the user names and place them
> into an external file.  How do I go about this? 

#! perl -w
use strict;
my @users;
open (IN, "particular.exe |") or die "Cannot pipe: $!";
while () {
last if /^ACTIVE users:$/;
}
while () {
last unless /\s+(\w+)\s+/;
push @users, $1 unless $1 eq 'User';
}
close(IN);

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