Skip to search.

Breaking News Visit Yahoo! News for the latest.

×Close this window

perl-beginner · Perl Beginners Mailing List

The Yahoo! Groups Product Blog

Check it out!

Group Information

  • Members: 3765
  • Category: Perl
  • Founded: Aug 2, 1998
  • Language: English
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Messages

Advanced
Messages Help
Messages 15552 - 15581 of 27459   Oldest  |  < Older  |  Newer >  |  Newest
Messages: Show Message Summaries Sort by Date ^  
#15552 From: "joinbng" <joinbng@...>
Date: Tue Jul 1, 2003 7:48 am
Subject: Urgent Req For Saudi Arabia--java,perl 5+yrs
joinbng
Send Email Send Email
 
Req No SSAI-Saudi-26062003-Req1650
Must have skills  Perl, Java and Java Scripts Programming
experience.
Oracle   DB development experience.
Web Development experience on Apache web server.
MOD   Perl Data Base connectivity.
Seismic background
Good to have skills  Knowledge about   XML, XSL and XSLT.
Good experience in SQL and databases particularly Oracle.
Geology & Geophysics
Job Description Develop, enhance and maintain Data Management
Applications. Participate in building, enhancing and populating the
required Data Model for Seisserver application under Oracle Data Base
Job Location Dammam (Daharan)
Required Relevant Experience As above
Required Total Experience As above
Educational Qualification As above
No of positions One
Technical Validation Process  Interview by client if short-listed.
Remarks At least 2 CV's reqd.

#15553 From: "joinbng" <joinbng@...>
Date: Tue Jul 1, 2003 7:49 am
Subject: (No subject)
joinbng
Send Email Send Email
 
Req No SSAI-Saudi-26062003-Req1650
Must have skills  Perl, Java and Java Scripts Programming
experience.
Oracle   DB development experience.
Web Development experience on Apache web server.
MOD   Perl Data Base connectivity.
Seismic background
Good to have skills  Knowledge about   XML, XSL and XSLT.
Good experience in SQL and databases particularly Oracle.
Geology & Geophysics
Job Description Develop, enhance and maintain Data Management
Applications. Participate in building, enhancing and populating the
required Data Model for Seisserver application under Oracle Data Base
Job Location Dammam (Daharan)
Required Relevant Experience As above
Required Total Experience As above
Educational Qualification As above
No of positions One
Technical Validation Process  Interview by client if short-listed.


Rgds,
Ram
ram@...

#15554 From: "Vema Venkata" <venkatsb@...>
Date: Tue Jul 1, 2003 7:55 am
Subject: (No subject)
venkatsb@...
Send Email Send Email
 
For the following script can any one help me to create a  log file
wud be appreciated  help asap


rgds
venkat
********************************************************************************\
***********************************************
xapipgm=srvtst26.pl
pgrep -f $xapipgm > /dev/null
		 # runrc=$?
		 # echo "Return Code is: $?"
if [ $? -eq 0 ]
then
	 set `pgrep -f $xapipgm `
echo "AHD XAPI Server ($xapipgm) Running with Process Id: $1"
else
echo "AHD XAPI Server is now Started Running."
set `date '+%Y %m %d %H %M' `
xapipgm=srvtst26.pl
#echo "log: log/init/ahdxapi.init.$1$2$3.$4$5.log"
#echo "err: log/init/ahdxapi.init.$1$2$3.$4$5.err"
perl -w $xapipgm >log/init/ahdxapi.init.$1$2$3.$4$5.log
2>log/init/ahdxapi.init.$1$2$3.$4$5.err
perl -w $4$5>log/init/ahdxapi.init
fi

********************************************************************************\
***************

#15555 From: "Srikanth Madani" <srikanthm@...>
Date: Tue Jul 1, 2003 8:39 am
Subject: RE: mailx via system sends zen mail
srikanthm@...
Send Email Send Email
 
Greetings, Mongers!

The following code refuses to mail the contents of $resfile to me :
		 if (defined $ARGV[1]) {
		     print "\nDiag:To check if resfile is still defined - $resfile and version
is - $version\n";
		     system qq(mailx -s"checkmr results for $version" $ARGV[1] < $resfile);
		     print "\nNow mailing results to $ARGV[1]\n";
		 }

It prints:
		 Diag:To check if resfile is still defined - /tmp/checkmr.13282 and version is
- v33_0
		 Now mailing results to srikanthm@...

The contents of $resfile (/tmp/checkmr.13282 ) are correct - I checked it.

But the mail I get is empty. Am I missing something obvious?


Thanks much,
Srik.

Srikanth Madani
Software Configuration Management
Voicemail: +357-25-88-6986
Mail: srikanth.madani@...
Larry Wall on Perl 6 : We're working on it, slowly but surely...or not-so-surely
in the spots we're not so sure.
   ----------

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

The information contained in this message is proprietary of Amdocs,
protected from disclosure, and may be privileged.
The information is intended to be conveyed only to the designated recipient(s)
of the message. If the reader of this message is not the intended recipient,
you are hereby notified that any dissemination, use, distribution or copying of
this communication is strictly prohibited and may be unlawful.
If you have received this communication in error, please notify us immediately
by replying to the message and deleting it from your computer.
Thank you.

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


[Non-text portions of this message have been removed]

#15556 From: Mukta Telang <mukta@...>
Date: Tue Jul 1, 2003 3:16 pm
Subject: extract decimal numbers from a string
mukta@...
Send Email Send Email
 
Hi,
I want to extract decimal numbers from a string which contains blanks.
There can be 0-2 such numbers inside the string.
How to do this?
I tried the following:

	 /[0-9]+\.[0-9]+/;
	 $num1=$&;

#  first number gets extracted properly

	 @fields=split('$num1',$_);

	 $n=@fields;

# $n=0 why?
I want to know a nice way to this..
thanks in advance,
Mukta

#15557 From: "nunleva" <nuno.fernandes@...>
Date: Tue Jul 1, 2003 11:26 am
Subject: Ordering a Hash
nunleva
Send Email Send Email
 
Hello everyone,

I´m trying to make a sub that returns an ordered hash where the keys
are numbers!

Ex:

%hash= (
         12=>"Porto",
         1=>"El Boss",
         8=>"Moi",
         7=>"Je",
         4=>"Me"
         );

What i want to do is a function that returns an Hash with:

%ordered_hash= (
         1=>"El Boss",
         4=>"Me",
         7=>"Je",
         8=>"Moi",
         12=>"Porto"
         );


I made this function, but the returned hash is not ordered!??


sub order_hash{

   my(%hash)=@_;
   my @keys;
   my $value;
   my %hash_ordered;
   my $key;
   @keys=sort {$a<=>$b} (keys %hash);
   foreach $key (@keys) {
     $value=$hash{$key};
     $hash_ordered{$key}=$value;
   }
     return %hash_ordered;
}

Can someone help me??

Thanks!

Nuno

#15558 From: Gordon Stewart <gordon52@...>
Date: Tue Jul 1, 2003 11:33 am
Subject: Re: [PBML] Ordering a Hash
gordonisnz
Send Email Send Email
 
At 11:26 PM 7/1/03 nunleva wrote:-

>Hello everyone,
>
>I´m trying to make a sub that returns an ordered hash where the keys
>are numbers!
>
>Ex:
>     return %hash_ordered;
>Can someone help me??
>Thanks!


foreach $line (sort keys %hash){
   print $line<BR>\n";
}


>Nuno
>
>
>Yahoo! Groups Sponsor
><http://rd.yahoo.com/M=249982.3512844.4795476.1261774/D=egroupweb/S=1705006951:\
HM/A=1524963/R=0/SIG=12o72ctft/*http://hits.411web.com/cgi-bin/autoredir?camp=55\
6&lineid=3512844&prop=egroupweb&pos=HM>691fc3.jpg
>
>692052.jpg
>
>Unsubscribing info is here:
><http://help.yahoo.com/help/us/groups/groups-32.html>http://help.yahoo.com/help\
/us/groups/groups-32.html
>
>
>Your use of Yahoo! Groups is subject to the
><http://docs.yahoo.com/info/terms/>Yahoo! Terms of Service.
>---
>Incoming mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.493 / Virus Database: 292 - Release Date: 6/25/03



[Non-text portions of this message have been removed]

#15559 From: "Srikanth Madani" <srikanthm@...>
Date: Tue Jul 1, 2003 11:44 am
Subject: RE: flush file buffers associated with (was mailx via system sends zen mail)
srikanthm@...
Send Email Send Email
 
Hi all,

I found the problem (a friend helped me out!) - I use the IO:Tee module as :

         $tee = IO::Tee->new ( ">$resfile", ">&1");

And when I try to do something with the contents of $resfile, I don't get
anywhere as it's not yet written to disk. When I exit the script, all buffers
are flushed, and the file contains the correct data.

The question (an important one for me!) is how do I now explicitly flush this
buffer? I'm not sure if I'm phrasing the question correctly, so please be
tolerant, and tell me how do I ensure that everything written to $tee [via a
statement like print $tee "\nThis will go into $resfile as well as STDOUT";] is
finally written to disk?

Thanks,



Srikanth Madani
Software Configuration Management
Voicemail:      +357-25-88-6986
Mail: srikanth.madani@...
Larry Wall on Perl 6 : We're working on it, slowly but surely...or not-so-surely
in the spots we're not so sure.

-----Original Message-----
From: Srikanth Madani
Sent: Tuesday, July 01, 2003 11:40 AM
To: perl-beginner@yahoogroups.com
Subject: [PBML] RE: mailx via system sends zen mail


Greetings, Mongers!

The following code refuses to mail the contents of $resfile to me :
             if (defined $ARGV[1]) {
                 print "\nDiag:To check if resfile is still defined - $resfile
and version is - $version\n";
                 system qq(mailx -s"checkmr results for $version" $ARGV[1] <
$resfile);
                 print "\nNow mailing results to $ARGV[1]\n";
             }

It prints:
             Diag:To check if resfile is still defined - /tmp/checkmr.13282 and
version is - v33_0
             Now mailing results to srikanthm@...

The contents of $resfile (/tmp/checkmr.13282 ) are correct - I checked it.

But the mail I get is empty. Am I missing something obvious?


Thanks much,
Srik.

Srikanth Madani
Software Configuration Management
Voicemail:      +357-25-88-6986
Mail: srikanth.madani@...
Larry Wall on Perl 6 : We're working on it, slowly but surely...or not-so-surely
in the spots we're not so sure.
   ----------




   ----------

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

The information contained in this message is proprietary of Amdocs,
protected from disclosure, and may be privileged.
The information is intended to be conveyed only to the designated recipient(s)
of the message. If the reader of this message is not the intended recipient,
you are hereby notified that any dissemination, use, distribution or copying of
this communication is strictly prohibited and may be unlawful.
If you have received this communication in error, please notify us immediately
by replying to the message and deleting it from your computer.
Thank you.

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


[Non-text portions of this message have been removed]

#15560 From: "Srikanth Madani" <srikanthm@...>
Date: Tue Jul 1, 2003 12:13 pm
Subject: RE: [PBML] RE: flush file buffers associated with IO:Tee
srikanthm@...
Send Email Send Email
 
I found the solution on cpan:

$tee->flush();

[http://theoryx5.uwinnipeg.ca/CPAN/data/IO-Tee/Tee.html]

I'll make sure I read the perltoot man before posting any other queries about
OOPS.

Have a nice day!

Srikanth Madani
Software Configuration Management
Voicemail:      +357-25-88-6986
Mail: srikanth.madani@...
Larry Wall on Perl 6 : We're working on it, slowly but surely...or not-so-surely
in the spots we're not so sure.

-----Original Message-----
From: Srikanth Madani
Sent: Tuesday, July 01, 2003 2:45 PM
To: perl-beginner@yahoogroups.com
Cc: Anuj Seth
Subject: [PBML] RE: flush file buffers associated with (was mailx via system
sends zen mail)


Hi all,

I found the problem (a friend helped me out!) - I use the IO:Tee module as :

         $tee = IO::Tee->new ( ">$resfile", ">&1");

And when I try to do something with the contents of $resfile, I don't get
anywhere as it's not yet written to disk. When I exit the script, all buffers
are flushed, and the file contains the correct data.

The question (an important one for me!) is how do I now explicitly flush this
buffer? I'm not sure if I'm phrasing the question correctly, so please be
tolerant, and tell me how do I ensure that everything written to $tee [via a
statement like print $tee "\nThis will go into $resfile as well as STDOUT";] is
finally written to disk?

Thanks,



Srikanth Madani
Software Configuration Management
Voicemail:      +357-25-88-6986
Mail: srikanth.madani@...
Larry Wall on Perl 6 : We're working on it, slowly but surely...or not-so-surely
in the spots we're not so sure.

-----Original Message-----
From: Srikanth Madani
Sent: Tuesday, July 01, 2003 11:40 AM
To: perl-beginner@yahoogroups.com
Subject: [PBML] RE: mailx via system sends zen mail


Greetings, Mongers!

The following code refuses to mail the contents of $resfile to me :
             if (defined $ARGV[1]) {
                 print "\nDiag:To check if resfile is still defined - $resfile
and version is - $version\n";
                 system qq(mailx -s"checkmr results for $version" $ARGV[1] <
$resfile);
                 print "\nNow mailing results to $ARGV[1]\n";
             }

It prints:
             Diag:To check if resfile is still defined - /tmp/checkmr.13282 and
version is - v33_0
             Now mailing results to srikanthm@...

The contents of $resfile (/tmp/checkmr.13282 ) are correct - I checked it.

But the mail I get is empty. Am I missing something obvious?


Thanks much,
Srik.

Srikanth Madani
Software Configuration Management
Voicemail:      +357-25-88-6986
Mail: srikanth.madani@...
Larry Wall on Perl 6 : We're working on it, slowly but surely...or not-so-surely
in the spots we're not so sure.
   ----------




   ----------

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

The information contained in this message is proprietary of Amdocs,
protected from disclosure, and may be privileged.
The information is intended to be conveyed only to the designated recipient(s)
of the message. If the reader of this message is not the intended recipient,
you are hereby notified that any dissemination, use, distribution or copying of
this communication is strictly prohibited and may be unlawful.
If you have received this communication in error, please notify us immediately
by replying to the message and deleting it from your computer.
Thank you.

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


[Non-text portions of this message have been removed]



Yahoo! Groups Sponsor
 
<http://rd.yahoo.com/M=251812.3170658.4537139.1261774/D=egroupweb/S=1705006951:H\
M/A=1564415/R=0/SIG=11t6t7kdo/*http://www.netflix.com/Default?mqso=60164784&part\
id=3170658>
  
<http://us.adserver.yahoo.com/l?M=251812.3170658.4537139.1261774/D=egroupmail/S=\
:HM/A=1564415/rand=547953303>

Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
<http://docs.yahoo.com/info/terms/> .



   ----------

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

The information contained in this message is proprietary of Amdocs,
protected from disclosure, and may be privileged.
The information is intended to be conveyed only to the designated recipient(s)
of the message. If the reader of this message is not the intended recipient,
you are hereby notified that any dissemination, use, distribution or copying of
this communication is strictly prohibited and may be unlawful.
If you have received this communication in error, please notify us immediately
by replying to the message and deleting it from your computer.
Thank you.

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


[Non-text portions of this message have been removed]

#15561 From: "Damien Carbery" <daymobrew@...>
Date: Tue Jul 1, 2003 12:34 pm
Subject: Re: [PBML] Ordering a Hash
daymobrew
Send Email Send Email
 
--- In perl-beginner@yahoogroups.com, Gordon Stewart <gordon52@s...>
wrote:
> At 11:26 PM 7/1/03 nunleva wrote:-
>
> >Hello everyone,
> >
> >I´m trying to make a sub that returns an ordered hash where the keys
> >are numbers!
> >
> >Ex:
> >     return %hash_ordered;
> >Can someone help me??
> >Thanks!
>
>
> foreach $line (sort keys %hash){
>   print $line<BR>\n";
> }
>
>
> >Nuno
> >

You can't order a hash. If you go through each of the keys of a hash,
the order the keys are seen is not defined. You can only do as Gordon
has demonstrated, sort the keys as you reference them.

As your keys are numbers and (I believe) 'sort' by default does string
comparisons, you can use:

foreach my $key (sort { $a <=> $b } keys %hash){
   print "$key = $hash{$key}\n";
}

to do numeric comparisons.
I think 'sort keys %hash' is shorthand for:
'sort { $a cmp $b } keys %hash' because 'cmp' is for string comparisons.

See:
http://www.perldoc.com/perl5.8.0/pod/perlop.html#Equality-Operators

#15562 From: Gordon Stewart <gordon52@...>
Date: Tue Jul 1, 2003 1:21 pm
Subject: REGEX - Please de-confuse me please
gordonisnz
Send Email Send Email
 
if ($subj !~ m/$subject/i){
   while ($subject =~ m/^ /i){ $subject =~ s/^ //i; }
   print "Subject 1A: '$subject' - '$subj'\n\n";
$subject = "$subj $subject";
   print "Subject 1B: '$subject' - '$subj'\n\n";

}


Ok the above :-

$subject  = "Subject line test 5" (without quotes)
$subj = "[gordontest123]" (no quotes)

I want to test if $subj exists in $subject

if it DOESNT - it is added to the front

- If it DOES - Nothing changes...

(i'm doing an email system..)

Basically - if I do (as above)  - I get MULTIPLE '$subj' - If I reply to
the emails

If I put $subject !~ $subj  etc..

Nothing happens (I dont get anything appended...)

am I losing my mind,Or just short of sleep...  ???

G

#15563 From: Gordon Stewart <gordon52@...>
Date: Tue Jul 1, 2003 1:25 pm
Subject: PS Re: [PBML] REGEX - Please de-confuse me please
gordonisnz
Send Email Send Email
 
At 01:21 AM 7/2/03 Gordon Stewart wrote:-


>if ($subj !~ m/$subject/i){
>   while ($subject =~ m/^ /i){ $subject =~ s/^ //i; }
>   print "Subject 1A: '$subject' - '$subj'\n\n";
>$subject = "$subj $subject";
>   print "Subject 1B: '$subject' - '$subj'\n\n";
>
>}

PS - if I change :-

while ($subject =~ m/^ /i){ $subject =~ s/^ //i; }

to :-

$subject =~ s/^\s+//i;

Then if i put a subject beginning with a letter 's' - That 's' also gets
dropped :-(


G



[Non-text portions of this message have been removed]

#15564 From: <greg.hering@...>
Date: Tue Jul 1, 2003 3:09 pm
Subject: RE: [PBML] RE: mailx via system sends zen mail
glhering
Send Email Send Email
 
Dear Srik,

Pass $resfile to one of these as the second argument.



package Mycommon;

use strict;
use vars qw($VERSION);
$VERSION = '0.01';
use MIME::Lite;
use strict;


#uses MIME::Lite to send mail
sub sendMail
{
     my $subject = @_ > 0 ? $_[0] : "undefined";
     my $message = @_ > 1 ? $_[1] : "undefined";
     my $contact = @_ > 2 ? $_[2] : " srikanthm\@amdocs.com";

     printf "Sending mail to: $contact\n";

     my $dateTime = `date`;
     $message .= "\n" . $dateTime;


     my $mailmsg = new MIME::Lite
             From    =>'my mailer program, Mycommon::sendMail',
             To      =>"$contact",
             Subject =>"$subject",
             Type    =>'TEXT',
             Data    =>"$message";

     $mailmsg->send;
}



# just open a pipe to 'sendmail'
sub sendSMTPMail
{
     my $subject = @_ > 0 ? $_[0] : "undefined";
     my $message = @_ > 1 ? $_[1] : "undefined";
     my $contact = @_ > 2 ? $_[2] : " srikanthm\@amdocs.com";

     my $dateTime = `date`;
     printf "$dateTime\nSending mail to: $contact\n";

     my $mailer = "/usr/lib/sendmail -t $contact";
     open MAILER, "| $mailer";

     print MAILER <<END_OF_MESSAGE;
From: my mailer program, Mycommon::sendSMTPMail
To: $contact
Subject: $subject

Current time: $dateTime
$message
END_OF_MESSAGE
     close(MAILER);

}


Gregory L. Hering
(256) 722-6420
4807 Bradford Dr
Benchmark Electronics, Inc.
Huntsville, Al 35805

-----Original Message-----
From: Srikanth Madani [mailto:srikanthm@...]
Sent: Tuesday, July 01, 2003 3:40 AM
To: perl-beginner@yahoogroups.com
Subject: [PBML] RE: mailx via system sends zen mail

Greetings, Mongers!

The following code refuses to mail the contents of $resfile to me :
            if (defined $ARGV[1]) {
                print "\nDiag:To check if resfile is still defined - $resfile
and version is - $version\n";
                system qq(mailx -s"checkmr results for $version" $ARGV[1] <
$resfile);
                print "\nNow mailing results to $ARGV[1]\n";
            }

It prints:
            Diag:To check if resfile is still defined - /tmp/checkmr.13282 and
version is - v33_0
            Now mailing results to srikanthm@...

The contents of $resfile (/tmp/checkmr.13282 ) are correct - I checked it.

But the mail I get is empty. Am I missing something obvious?


Thanks much,
Srik.

Srikanth Madani
Software Configuration Management
Voicemail:      +357-25-88-6986
Mail: srikanth.madani@...                         
Larry Wall on Perl 6 : We're working on it, slowly but surely...or not-so-surely
in the spots we're not so sure.
  ----------

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

The information contained in this message is proprietary of Amdocs,
protected from disclosure, and may be privileged.
The information is intended to be conveyed only to the designated recipient(s)
of the message. If the reader of this message is not the intended recipient,
you are hereby notified that any dissemination, use, distribution or copying of
this communication is strictly prohibited and may be unlawful.
If you have received this communication in error, please notify us immediately
by replying to the message and deleting it from your computer.
Thank you.

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


[Non-text portions of this message have been removed]



Yahoo! Groups Sponsor



Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

#15565 From: Gordon Stewart <gordon52@...>
Date: Tue Jul 1, 2003 3:23 pm
Subject: FIXED Re: PS Re: [PBML] REGEX - Please de-confuse me please
gordonisnz
Send Email Send Email
 
FIXED

if ($subj !~ m/$subject/i){
print "TEST 2 - $subj NOT included in $subject\n";


   while ($subject =~ m/^ /i){ $subject =~ s/^ //i; }
   print "Subject 1A: '$subject' - '$subj'\n\n";
$subject = "$subj $subject";
   print "Subject 1B: '$subject' - '$subj'\n\n";


}



LOL - over 1600 people on this group &  no one is awake when I am (i'm off
to bed..)

G


[Non-text portions of this message have been removed]

#15566 From: <greg.hering@...>
Date: Tue Jul 1, 2003 2:39 pm
Subject: RE: [Cpanplus-bugs] file dups?
glhering
Send Email Send Email
 
Dear Jos,

	 Thanks for writing back.  I don't think I understand your suggestion. 
Admittedly, I am a beginner, but this is not what I had expected from reading
the docs.  I've already learned at least two things since reading your reply,
but please help me get to the end of this.

	 The problem is that CPANPLUS (also CPAN) doesn't see some up-to-date modules. 
From your reply, I believe that it is because of older ones being found first
via @INC path order.  Are you saying that I should modify CPANPLUS.pm and put
some kind of 'push(@INC,...)' statement at the beginning so it finds the "rogue"
modules?

	 Correct me here too; if I run 'cpanp' or 'perl -MCPANPLUS -eshell' I either
have to change the default perl library search order or modify the CPANPLUS.pm
module, right?  Changing the default perl library search order means setting
PERL5LIB environment variable, right?  But to set the right path I have to do a
'find' on the module that doesn't update correctly, check the version on both
(assuming has gotten me into trouble before), and then put the path to the
module that is newer ahead of the path of the older module.

	 All that so I can leave the older module installed and have CPANPLUS detect the
newer one.  But I don't really want the older module around, so, for me, this is
an exercise in futility.  I like 'find -exec grep VERSION; rm ... better because
I only want the latest one.

	 Maybe it more rightly should be called a bug in the individual modules.  They
install in one place one time, and then later in another place.  I can see how
this is not the responsibility of CPANPLUS.  CPAN also exhibited this behavior,
which is actually why I decided to try CPANPLUS.

	 It could also be claimed that it is a bug in the way perl is distributed.  I
think that some of the "problem" modules are installed with the perl
distribution and that they are put in the "wrong" place.  Then when a newer
version is detected and in is put in the place designated by the author, or the
architecture dependent location, whichever, the other (distribution installed)
version remains and is higher up in the priority of search paths.

	 I suppose that technically that is not a 'bug' for either party, but when you
put the two of them together it becomes a problem for me (and I would guess,
other perl users).

	 I'll bet that there are a LOT of perl users that don't even know they are using
out of date modules.  Other users know that they can't update some modules even
though they run 'install'.  They don't know the reason that the install
succeeded but the modules are still out of date.  That's how I got started down
this dark path.  It happens on two different platforms too, RH9 on Intel and
Solaris8 on sparc.

	 I suppose there could be a legitimate reason for having two versions of a
module installed in a single perl installation, but for me it is kaos.  Someone
could write a utility to search for multiple installations and offer to resolve
the issue, were it not the desire of the user to have multiple module versions. 
It's just that CPANPLUS seems to me like the perfect place to resolve this kind
of confusion, since it is the 'installer of choice'.

	 Sorry I offended you by calling it a 'bug'.  It's really a wonderful package.


Sincerely,

Greg


Gregory L. Hering
(256) 722-6420
4807 Bradford Dr
Benchmark Electronics, Inc.
Huntsville, Al 35805


-----Original Message-----
From: Jos I. Boumans [mailto:kane@...]
Sent: Tuesday, July 01, 2003 7:55 AM
To: Hering, Greg
Cc: cpanplus-bugs@...
Subject: Re: [Cpanplus-bugs] file dups?


On Wednesday, Jun 25, 2003, at 17:02 Europe/Amsterdam,
<Greg.Hering@...> wrote:

> Does anybody have some code to find duplicate files in a file system?
from reading the rest of your mail, you're not looking for duplicate
files, but for files that come from the same modules, with alternate
version numbers.

also, this is /not/ a cpanplus bug, so this mailing list is probably
not the best place for your question.

> Then if I do a 'find /usr/local/lib/perl5 -name Util.pm' I get
[...]
> You can see List/Util.pm in two places

and perl will use the first one it finds according to it's @INC array.
type perl -V to see the contents.

also read perldoc -f require to see how it's used.

again, this is not a bug but perhaps the above manuals will shed some
light on this for you.

--

Jos Boumans

	 "We are not far from the kind of moral decay that has brought on the
	 fall of other nations and peoples" - Senator Barry Goldwater, 1964

	 CPANPLUS http://cpanplus.sf.net

#15567 From: <greg.hering@...>
Date: Tue Jul 1, 2003 4:28 pm
Subject: RE: [PBML] XML parsing
glhering
Send Email Send Email
 
You is super-cool and you ain't no fool!

Or, to be more precise, your response to my inquiry was insightful and accurate.
It seems that the second form produces the same results, but is more 'anonymous'
because you don't have to know the name of the hash key.

Thanks!

My Homework Assignment:  Delving into the @$ and $$ signs of the world.

Gregory L. Hering
(256) 722-6420
4807 Bradford Dr
Benchmark Electronics, Inc.
Huntsville, Al 35805

-----Original Message-----
From: Mark Reed [mailto:intensity_guy@...]
Sent: Monday, June 30, 2003 11:56 PM
To: perl-beginner@yahoogroups.com
Subject: Re: [PBML] XML parsing

If I understand, your only having problems when $type
is an array correct?

In the case that $type is an array, The array will
contain hash references. Each hash will have a key of
'name', and a 'value' of the directory.

I think this is the loop your looking for:

if ($type eq "ARRAY") {
        foreach my $hash (@$dirs) {
                print "$$hash{name}\n";
        }
}

Or:
if ($type eq "ARRAY") {
        foreach my $hash (@$dirs) {
                foreach my $value ( values %$hash ) {
                        print "$value \n";
                }
        }
}

<SNIPPed>

#15568 From: Jeff 'japhy' Pinyan <japhy@...>
Date: Tue Jul 1, 2003 4:43 pm
Subject: Re: [PBML] REGEX - Please de-confuse me please
evilffej
Send Email Send Email
 
On Jul 2, Gordon Stewart said:

>if ($subj !~ m/$subject/i){

This checks to see if $subject (as a regex) can be found
case-insensitively in $subj.  Is this what you are trying to do?  Please
be more clear.

>  while ($subject =~ m/^ /i){ $subject =~ s/^ //i; }

That /i modifier is a complete waste here, and this line should be
rewritten as

   s/^ +//;

or perhaps

   s/^\s+//;

if you want to remove all forms of leading whitespace.

--
Jeff "japhy" Pinyan      japhy@...      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]

#15569 From: Jeff 'japhy' Pinyan <japhy@...>
Date: Tue Jul 1, 2003 4:45 pm
Subject: Re: [PBML] REGEX - Please de-confuse me please
evilffej
Send Email Send Email
 
On Jul 2, Gordon Stewart said:

>I want to test if $subj exists in $subject
>
>if it DOESNT - it is added to the front
>
>- If it DOES - Nothing changes...

This sounds like the job for a hash, not a string with regexes on it!

   for $new_subj (@list_of_subjects) {
     $subjects{$new_subj} = 1;
   }

or even

   @subjects{ @list_of_subjects } = (1) x @list_of_subjects;

--
Jeff "japhy" Pinyan      japhy@...      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]

#15570 From: "perlmedian" <perlmedian@...>
Date: Tue Jul 1, 2003 7:31 pm
Subject: Need some Module recommendations
perlmedian
Send Email Send Email
 
Well I have a project I want to make better. I need to make a program
that can show a tree/web relationship between items. The
relationships are easy to acquire. It's displaying the relationship
in a meaningful way that eludes me.

I want it to be user-friendly so that a person can look general
things or details or a mix in between.

I know some Perl Tk, but it's to cumbursome to hand this complex
idea. The program is pretty complex itself without the display
portion, but that will just make it worse.

Basically it's should look like an expandable flowchart to the user.
Something like, Box1 relates to Box 2, 3, 4. Box1 really has details -
  Items 1, 2. If Box1 is expanded/detailed it shows how Box1 relates
to the others. Item 1 relates to Box 2, 3; Item 2 relates to Box 4.
and each Item has it's own details

QUESTION: Is there any modules out there that could make this easier
to program other than Tk?

Thanx,
Nik

#15571 From: <greg.hering@...>
Date: Tue Jul 1, 2003 9:16 pm
Subject: Object member - error.
glhering
Send Email Send Email
 
I have a class derived off Net::FTP.

My class gets a remote XML file, parses it, and sticks the results in a local
member so it can be used from other member calls.

my $remHost = HCom->new( host, user, pass );

HCom->getConfigFile();    #create member with 'bless($self, ref(shift));'

The constructor makes the FTP connection.
A class method gets the file, parses it and creates the member variable.

When my class goes out of scope I get an error:

	 (in cleanup) Not a GLOB reference at /usr/local/lib/perl5/5.8.0/Net/FTP.pm line
1090.

Is this maybe because I created the member variable in a method and not in the
constructor?
Or maybe I'm supposed to do something explicit to deallocate the member variable
before going out of scope?

Thanks,

Greg


Gregory L. Hering
(256) 722-6420
4807 Bradford Dr
Benchmark Electronics, Inc.
Huntsville, Al 35805

#15572 From: "Richard Crawford" <rcrawford@...>
Date: Tue Jul 1, 2003 10:54 pm
Subject: File::Find troubles
rscrawford
Send Email Send Email
 
This script is supposed to open an FTP connection from a Unix server
to a Windows server and pull files in to the Unix server.  The
directory structures on both servers are slightly difference -- hence
the storm of regexp's in the move subroutine.

The problem is this: in each subdirectory on both servers there is a
subdirectory called "messages"; but when the program is running,
File::Find seems unable to descend to that directory.  I can't find
any errors, and the permissions on the directories seem to be appropriate.

If anyone has suggestions or comments, I would greatly appreciate it.

#!/usr/local/bin/perl -w

# FILE:  vton.pl
# PURPOSE: Retrieve current discussion board messages
#  from Vader and put them on Neo
# AUTHOR: Richard Crawford (rcrawford@...)
# CREATED: 25 June 2003
# EDIT HISTORY:
# ===============================================================
# DATE          AUTHOR  EDIT
# 07/01/03 RC Updated script to retrieve multiple files
# ===============================================================

use strict;
use File::Find;
use Net::FTP;




my $vaderIP = "xxx.xxx.xxx.xxx";

my $start_dir = shift or die "Usage: $0 <start_dir>\n";

unless (-d $start_dir) {
   die "Start files $start_dir is not a directory.\n";
}

# Connect to Vader
my $VaderConnect = Net::FTP->new($vaderIP) or die ("VTON: Can't
connect to Vader: $!\n");

$VaderConnect->login('Richard','mypassword') or die ("VTON: Can't log
in to Vader: $!\n");
$VaderConnect->ascii();

print "\nVTON: Successfully connected to Vader.\n\n";

# traverse directory tree and move files
find (\&move, $start_dir);

# Disconnect from Vader
$VaderConnect->quit();

sub move { #subroutine to move files

   print "\n\nMOVE subr output:\n\n";

   my $neoIP='unexdlc.ucdavis.edu';

   # Find the current directory
   my $neoDir = $File::Find::dir;
   print "\$neoDir: $neoDir\n";

   # Move to the equivalent directory on Vader
   my $baseDir = $neoDir;
   $baseDir =~ s#/space/usr/jrun4/servers/default/cfusion/DLC/##g;
   print "\$baseDir: $baseDir\n";
   my $vaderDir = "/HTTPHome/$baseDir";
   $vaderDir =~ s#/extras##g;
   print "\$vaderDir: $vaderDir\n";

   # Switch to equivalent directory on Vader
   $VaderConnect->cwd($vaderDir) or die ("Directory $vaderDir does not
exist! $!\n");

   # Get all the files on Vader in this directory

   my @VaderFiles = $VaderConnect->ls("*.*") or die ("Cannot get list
of files: $!\n");

   # Now get each item from Vader and process them

   foreach my $currentFile (@VaderFiles)
   {

     if (($currentFile =~ m/[0-9]+.html$/) || ($currentFile =~
m/data.txt$/) || ($currentFile =~ m/wwwboard.html$/) || ($currentFile
=~ m/wwwboard.pl$/))
     {
       # $currentFile =~ s(^.*/)();

       print "Fixing $currentFile\n";

       # Get the file from Vader
       $VaderConnect->get("$currentFile");

       # Replace "action=wwwboard.pl" with direct path to wwwboard.pl
       # Create an absolute path to wwwboard.pl
       $neoDir =~ s#/space/usr/jrun4/servers/default/cfusion/##g;

       my $URL="http://$neoIP/DLC/$baseDir/wwwboard.pl";
       $URL =~ s#/messages##g;
       my $VaderURL="http://$vaderIP/$baseDir/wwwboard.pl";
       $VaderURL =~ s#/messages##g;
       unless (open IN, $currentFile) {
         die "VTON: Can't open file $currentFile for reading: $!\n";
       }
       unless (open OUT, "> fixedfile") {
         die "VTON: Can't open output file: $!\n";
       }
       while (<IN>) {
         # Fix form action tags.
         s/action="wwwboard\.pl"/action="$URL"/gi;
         s/action="$VaderURL"/action="$URL"/gi;
         # Fix style sheet call:
         s#href="../../../../Library/#href="../../../../../Library/#g;
         if ($currentFile =~ m#[0-9]+.html$#) {

s#href="../../../../../Library/#href="../../../../../../Library/#g;
         }
         print(OUT $_) or die "VTON: Can't write to fixedfile: $!\n";
       }
       close (IN);  close (OUT);
       rename("fixedfile","$currentFile");

       chmod 0777, $currentFile;

       print "VTON: Copied and fixed $File::Find::dir/$currentFile\n\n";
     } else {
       print "VTON: $currentFile not fixed.\n";
     }
   }
}

#15573 From: "Gordon Stewart" <Gordon.Stewart@...>
Date: Wed Jul 2, 2003 12:20 am
Subject: stripping / duplicated headers
Gordon.Stewart@...
Send Email Send Email
 
Just tested from work today

The script (I thought was fixed last night) now allows duplicates of subject
header tags :-(

(same as yahoogroups..) -  it SHOULD  insert a subject tag only if there is none
already in the subject.

- Now - testing a few messages - from work - It just adds more & more -
eg :- [test] [test] [test] [test] Subject here

I was on nomail here- will read any replies at home

G

#15574 From: "yolina24" <yolina24@...>
Date: Wed Jul 2, 2003 7:27 am
Subject: Oracle Datbase
yolina24
Send Email Send Email
 
Hi there,

i want to work with an Oracle Database. When i was programming in VB
i used ODBC. Is there something similar in perl?

It would be really nice if someone could give me some tips, what i
need, when i want to work with a databas: what modules and so on.

Ok thanx a lot!

Peace. Helena

#15575 From: richardb@...
Date: Wed Jul 2, 2003 8:30 am
Subject: sorting a hash using its value
richardb@...
Send Email Send Email
 
I'm having difficulty in getting the first 3 highest values in a hash, can
somebody help me (spending many hours, figuring this out)
e.g
%hash=(
1=>2,
2=>10,
3=>4,
4=>3,
5=>12
);

I want to get only the values 12, 10 & 4. This actually came from test
data, one column is the bin number(which is unique) and
another column(which is the count), then from this two parameters, I
created a hash (like the example above), the bin number
is the key and count is the value..

Appreciate your help..

Thanks..



BRgds,
--
Richard Bornay
Test Product Engineering
Test Data Management Group
ST Assembly Test Services
6824-1367

[Non-text portions of this message have been removed]

#15576 From: "Damien Carbery" <daymobrew@...>
Date: Wed Jul 2, 2003 8:44 am
Subject: Re: File::Find troubles
daymobrew
Send Email Send Email
 
--- In perl-beginner@yahoogroups.com, "Richard Crawford"
<rcrawford@u...> wrote:
> This script is supposed to open an FTP connection from a Unix server
> to a Windows server and pull files in to the Unix server.  The
> directory structures on both servers are slightly difference -- hence
> the storm of regexp's in the move subroutine.
>
> The problem is this: in each subdirectory on both servers there is a
> subdirectory called "messages"; but when the program is running,
> File::Find seems unable to descend to that directory.  I can't find
> any errors, and the permissions on the directories seem to be
appropriate.
>
> If anyone has suggestions or comments, I would greatly appreciate it.
>
> <snip>

I don't think File::Find will work on FTP sites.
I had a script that downloaded a directory tree from an FTP site. I
think I issued a 'ls -R' command through Net::FTP and it returned a
list with a file on each line for all the subdirectories.
I then parse each item in the list and downloaded the files as necessary.

#15577 From: "Damien Carbery" <daymobrew@...>
Date: Wed Jul 2, 2003 8:48 am
Subject: Re: sorting a hash using its value
daymobrew
Send Email Send Email
 
--- In perl-beginner@yahoogroups.com, richardb@s... wrote:
> I'm having difficulty in getting the first 3 highest values in a
hash, can
> somebody help me (spending many hours, figuring this out)
> e.g
> %hash=(
> 1=>2,
> 2=>10,
> 3=>4,
> 4=>3,
> 5=>12
> );
>
> I want to get only the values 12, 10 & 4. This actually came from test
> data, one column is the bin number(which is unique) and
> another column(which is the count), then from this two parameters, I
> created a hash (like the example above), the bin number
> is the key and count is the value..
>
> Appreciate your help..
>
> Thanks..
>
>
>
> BRgds,
> --
> Richard Bornay
> Test Product Engineering
> Test Data Management Group
> ST Assembly Test Services
> 6824-1367
>
> [Non-text portions of this message have been removed]

Use 'values( %hash )'
It returns a list of the values from the hash.

So, this untested code might work:
# The '$a <=> $b' does a numeric sort of the values.
my @SortedList = sort { $a <=> $b } values %hash;
# Drop elements 3+ i.e. keep top 3 values.
splice( @SortedList, 2 );

#15578 From: richardb@...
Date: Wed Jul 2, 2003 9:01 am
Subject: Re: [PBML] Re: sorting a hash using its value
richardb@...
Send Email Send Email
 
Hi Damien,
Thanks, it worked, but I need also to know the corresponding key of that
first 3 values?

BRgds,
Richard



"Damien Carbery" <daymobrew@...>        02/07/2003 04:48 PM
Please respond to perl-beginner

To:     perl-beginner@yahoogroups.com
cc:     (bcc: BORNAY Richard/Engr/STATS/ST Group)
Subject: [PBML] Re: sorting a hash using its value








--- In perl-beginner@yahoogroups.com, richardb@s... wrote:
> I'm having difficulty in getting the first 3 highest values in a
hash, can
> somebody help me (spending many hours, figuring this out)
> e.g
> %hash=(
> 1=>2,
> 2=>10,
> 3=>4,
> 4=>3,
> 5=>12
> );
>
> I want to get only the values 12, 10 & 4. This actually came from test
> data, one column is the bin number(which is unique) and
> another column(which is the count), then from this two parameters, I
> created a hash (like the example above), the bin number
> is the key and count is the value..
>
> Appreciate your help..
>
> Thanks..
>
>
>
> BRgds,
> --
> Richard Bornay
> Test Product Engineering
> Test Data Management Group
> ST Assembly Test Services
> 6824-1367
>
> [Non-text portions of this message have been removed]

Use 'values( %hash )'
It returns a list of the values from the hash.

So, this untested code might work:
# The '$a <=> $b' does a numeric sort of the values.
my @SortedList = sort { $a <=> $b } values %hash;
# Drop elements 3+ i.e. keep top 3 values.
splice( @SortedList, 2 );




Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/






[Non-text portions of this message have been removed]

#15579 From: Gordon Stewart <gordon52@...>
Date: Wed Jul 2, 2003 9:54 am
Subject: Re: [PBML] REGEX - Please de-confuse me please
gordonisnz
Send Email Send Email
 
At 04:43 AM 7/2/03 Jeff 'japhy' Pinyan wrote:-

>On Jul 2, Gordon Stewart said:
>
> >if ($subj !~ m/$subject/i){
>
>This checks to see if $subject (as a regex) can be found
>case-insensitively in $subj.  Is this what you are trying to do?  Please
>be more clear.

Is anyone online ?

ive got  (text of my log file) :-

Subject 1: ' Good MOrning mummy' - '[NZ]'

Subject 2: ' Good MOrning mummy' - '[NZ]'

That is in my log file -

the [NZ] thing is $subj
the  Good MOrning mummy is $subject


Now -  as $subject does NOT contain [NZ]
I want $subject to CHANGE to  " [NZ]  Good MOrning mummy " (no quotes)

As the regex you quoted above DOES NOT work, Ive changed it to :-



   print "Subject 1: '$subject' - '$subj'\n\n";

if ($subject !~ m/$subj/i){
print "TEST 2 - $subj NOT included in $subject\n";

   $subject =~ s/^ +//;
   print "Subject 1A: '$subject' - '$subj'\n\n";
$subject = "$subj $subject";
   print "Subject 1B: '$subject' - '$subj'\n\n";
}

   print "Subject 2: '$subject' - '$subj'\n\n";


It clearly displays the two "Subject" prints - however does NOT print the
'test' fields..

Today, Ive tested it (at work - a few emails)  & it puts '[NZ]' multiple
times - one extra each time I reply to the message :-

RULES :-

1) If it doesnt containt "[NZ]" - add it to the front of the subject
2) if it contains "[NZ]" - do nothing..

pretty simple - & ive been doing regexes for a while
However im totally bamboozled as to why this simple regex doesnt do what I
want..

<getting a "little" fustrated >

G



[Non-text portions of this message have been removed]

#15580 From: "Damien Carbery" <daymobrew@...>
Date: Wed Jul 2, 2003 9:58 am
Subject: [PBML] Re: sorting a hash using its value
daymobrew
Send Email Send Email
 
--- In perl-beginner@yahoogroups.com, richardb@s... wrote:
>
> "Damien Carbery" <daymobrew@y...>        02/07/2003 04:48 PM
> Please respond to perl-beginner
>
> To:     perl-beginner@yahoogroups.com
> cc:     (bcc: BORNAY Richard/Engr/STATS/ST Group)
> Subject: [PBML] Re: sorting a hash using its value
>
>
>
>
>
>
>
>
> --- In perl-beginner@yahoogroups.com, richardb@s... wrote:
> > I'm having difficulty in getting the first 3 highest values in a
> hash, can
> > somebody help me (spending many hours, figuring this out)
> > e.g
> > %hash=(
> > 1=>2,
> > 2=>10,
> > 3=>4,
> > 4=>3,
> > 5=>12
> > );
> >
> > I want to get only the values 12, 10 & 4. This actually came from
test
> > data, one column is the bin number(which is unique) and
> > another column(which is the count), then from this two parameters, I
> > created a hash (like the example above), the bin number
> > is the key and count is the value..
> >
> > Appreciate your help..
> >
> > Thanks..
> >
> >
> >
> > BRgds,
> > --
> > Richard Bornay
> > Test Product Engineering
> > Test Data Management Group
> > ST Assembly Test Services
> > 6824-1367
> >
> > [Non-text portions of this message have been removed]
>
> Use 'values( %hash )'
> It returns a list of the values from the hash.
>
> So, this untested code might work:
> # The '$a <=> $b' does a numeric sort of the values.
> my @SortedList = sort { $a <=> $b } values %hash;
> # Drop elements 3+ i.e. keep top 3 values.
> splice( @SortedList, 2 );
>
>
> Hi Damien,
> Thanks, it worked, but I need also to know the corresponding key of
that
> first 3 values?
>
> BRgds,
> Richard
>

# Exchange the keys and values.
my %newhash = map { $hash{ $_ } => $_ } keys %hash;
# %newhash = ( 2=>1, 10=>2, 4=>3, 3=>4, 12=>5 );

You can now sort the on the keys
   my @SortedList = reverse sort { $a <=> $b } values %hash;
and use the value to find out what the original key was.

I'm sure Jeff, Charles and Jenda will have nicer, less confusing,
solutions.
It would be good to know what you want to do with the results and why
  you need the keys.

#15581 From: richardb@...
Date: Wed Jul 2, 2003 10:24 am
Subject: Re: [PBML] Re: sorting a hash using its value
richardb@...
Send Email Send Email
 
Hi Damien,
I'm actually extracting these data(bin num and corresponding value) from a
testing summary files, these parameters
are being used for test analysis. The 3 most highest values need to be
reported, the actual format of the report
will look like this,


#### sample report format #####
1st_bin_num | 1st_highest_bin_num_qty | 2nd_bin_num | 2nd_highest_bin_num
| 3rd_bin_num | 3rd_highest_bin_num

note: | - delimiter

So once I know the first three highest values, I need also the
corresponding bin number (w/c is the key) and will
be printed in a report file with the above format..

I usually do this kind of scripting but there's a lot of summary file
format which for this one I'm having
difficulty..

Thank you very much for your time...

Hi Jeff, Charles and Jenda,
Hope you can help me with this, will appreciate it very much....thanks in
advance..

BRgds,
--
Richard Bornay
Test Product Engineering
Test Data Management Group
ST Assembly Test Services
6824-1367


"Damien Carbery" <daymobrew@...>        02/07/2003 05:58 PM
Please respond to perl-beginner

To:     perl-beginner@yahoogroups.com
cc:     (bcc: BORNAY Richard/Engr/STATS/ST Group)
Subject: [PBML] Re: sorting a hash using its value








--- In perl-beginner@yahoogroups.com, richardb@s... wrote:
>
> "Damien Carbery" <daymobrew@y...>        02/07/2003 04:48 PM
> Please respond to perl-beginner
>
> To:     perl-beginner@yahoogroups.com
> cc:     (bcc: BORNAY Richard/Engr/STATS/ST Group)
> Subject: [PBML] Re: sorting a hash using its value
>
>
>
>
>
>
>
>
> --- In perl-beginner@yahoogroups.com, richardb@s... wrote:
> > I'm having difficulty in getting the first 3 highest values in a
> hash, can
> > somebody help me (spending many hours, figuring this out)
> > e.g
> > %hash=(
> > 1=>2,
> > 2=>10,
> > 3=>4,
> > 4=>3,
> > 5=>12
> > );
> >
> > I want to get only the values 12, 10 & 4. This actually came from
test
> > data, one column is the bin number(which is unique) and
> > another column(which is the count), then from this two parameters, I
> > created a hash (like the example above), the bin number
> > is the key and count is the value..
> >
> > Appreciate your help..
> >
> > Thanks..
> >
> >
> >
> > BRgds,
> > --
> > Richard Bornay
> > Test Product Engineering
> > Test Data Management Group
> > ST Assembly Test Services
> > 6824-1367
> >
> > [Non-text portions of this message have been removed]
>
> Use 'values( %hash )'
> It returns a list of the values from the hash.
>
> So, this untested code might work:
> # The '$a <=> $b' does a numeric sort of the values.
> my @SortedList = sort { $a <=> $b } values %hash;
> # Drop elements 3+ i.e. keep top 3 values.
> splice( @SortedList, 2 );
>
>
> Hi Damien,
> Thanks, it worked, but I need also to know the corresponding key of
that
> first 3 values?
>
> BRgds,
> Richard
>

# Exchange the keys and values.
my %newhash = map { $hash{ $_ } => $_ } keys %hash;
# %newhash = ( 2=>1, 10=>2, 4=>3, 3=>4, 12=>5 );

You can now sort the on the keys
   my @SortedList = reverse sort { $a <=> $b } values %hash;
and use the value to find out what the original key was.

I'm sure Jeff, Charles and Jenda will have nicer, less confusing,
solutions.
It would be good to know what you want to do with the results and why
  you need the keys.




Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/






[Non-text portions of this message have been removed]

Messages 15552 - 15581 of 27459   Oldest  |  < Older  |  Newer >  |  Newest
Add to My Yahoo!      XML What's This?

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help